From f43d15009c50522fac917b669bf367fb592cc6cd Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 30 Mar 2016 00:43:49 +0000 Subject: [PATCH] Fix comments. The original comments were separated by new code that is irrelevant to the comment. This patch moves the comment to the right place and update it. llvm-svn: 264816 --- lld/ELF/InputSection.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 8039d7878582e..d79aad8f865a6 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -307,25 +307,24 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, template void InputSection::writeTo(uint8_t *Buf) { if (this->Header->sh_type == SHT_NOBITS) return; - // Copy section contents from source object file to output file. - ArrayRef Data = this->getSectionData(); ELFFile &EObj = this->File->getObj(); - // That happens with -r. In that case we need fix the relocation position and - // target. No relocations are applied. + // If -r is given, then an InputSection may be a relocation section. if (this->Header->sh_type == SHT_RELA) { - this->copyRelocations(Buf + OutSecOff, EObj.relas(this->Header)); + copyRelocations(Buf + OutSecOff, EObj.relas(this->Header)); return; } if (this->Header->sh_type == SHT_REL) { - this->copyRelocations(Buf + OutSecOff, EObj.rels(this->Header)); + copyRelocations(Buf + OutSecOff, EObj.rels(this->Header)); return; } + // Copy section contents from source object file to output file. + ArrayRef Data = this->getSectionData(); memcpy(Buf + OutSecOff, Data.data(), Data.size()); - uint8_t *BufEnd = Buf + OutSecOff + Data.size(); // Iterate over all relocation sections that apply to this section. + uint8_t *BufEnd = Buf + OutSecOff + Data.size(); for (const Elf_Shdr *RelSec : this->RelocSections) { if (RelSec->sh_type == SHT_RELA) this->relocate(Buf, BufEnd, EObj.relas(RelSec));