diff options
-rw-r--r-- | lld/ELF/InputSection.cpp | 2 | ||||
-rw-r--r-- | lld/ELF/InputSection.h | 6 | ||||
-rw-r--r-- | lld/ELF/OutputSections.cpp | 16 |
3 files changed, 9 insertions, 15 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 980466b61f9..f5b86763ca5 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -76,7 +76,7 @@ template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) { ObjectFile<ELFT> *File = getFile(); ELFFile<ELFT> &EObj = File->getObj(); uint8_t *Base = Buf + OutputSectionOff; - uintX_t BaseAddr = OutSec->getVA() + OutputSectionOff; + uintX_t BaseAddr = OutputSection->getVA() + OutputSectionOff; // Iterate over all relocation sections that apply to this section. for (const Elf_Shdr *RelSec : RelocSections) { if (RelSec->sh_type == SHT_RELA) diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index e65232fd277..249c09dc00d 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -48,15 +48,13 @@ public: return std::max<uintX_t>(Header->sh_addralign, 1); } - void setOutputSection(OutputSection<ELFT> *O) { OutSec = O; } - OutputSection<ELFT> *getOutputSection() const { return OutSec; } - // Relocation sections that refer to this one. SmallVector<const Elf_Shdr *, 1> RelocSections; // The offset from beginning of the output sections this section was assigned // to. The writer sets a value. uint64_t OutputSectionOff = 0; + OutputSection<ELFT> *OutputSection = nullptr; static InputSection<ELFT> Discarded; @@ -70,8 +68,6 @@ private: // The file this section is from. ObjectFile<ELFT> *File; - OutputSection<ELFT> *OutSec = nullptr; - const Elf_Shdr *Header; }; diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 5f489997f39..b5a3d2589c7 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -113,7 +113,6 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) { const InputSection<ELFT> &C = Rel.C; const Elf_Rel &RI = Rel.RI; - OutputSection<ELFT> *OutSec = C.getOutputSection(); uint32_t SymIndex = RI.getSymbol(IsMips64EL); const ObjectFile<ELFT> &File = *C.getFile(); SymbolBody *Body = File.getSymbolBody(SymIndex); @@ -143,7 +142,7 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) { } else { if (IsRela) Addend += static_cast<const Elf_Rela &>(RI).r_addend; - P->r_offset = RI.r_offset + C.OutputSectionOff + OutSec->getVA(); + P->r_offset = RI.r_offset + C.OutputSection->getVA() + C.OutputSectionOff; if (CanBePreempted) P->setSymbolAndType(Body->getDynamicSymbolTableIndex(), Type, IsMips64EL); @@ -385,7 +384,7 @@ OutputSection<ELFT>::OutputSection(StringRef Name, uint32_t sh_type, template <class ELFT> void OutputSection<ELFT>::addSection(InputSection<ELFT> *C) { Sections.push_back(C); - C->setOutputSection(this); + C->OutputSection = this; uint32_t Align = C->getAlign(); if (Align > this->Header.sh_addralign) this->Header.sh_addralign = Align; @@ -409,8 +408,7 @@ typename ELFFile<ELFT>::uintX_t lld::elf2::getSymVA(const SymbolBody &S) { case SymbolBody::DefinedRegularKind: { const auto &DR = cast<DefinedRegular<ELFT>>(S); const InputSection<ELFT> *SC = &DR.Section; - OutputSection<ELFT> *OS = SC->getOutputSection(); - return OS->getVA() + SC->OutputSectionOff + DR.Sym.st_value; + return SC->OutputSection->getVA() + SC->OutputSectionOff + DR.Sym.st_value; } case SymbolBody::DefinedCommonKind: return Out<ELFT>::Bss->getVA() + cast<DefinedCommon<ELFT>>(S).OffsetInBSS; @@ -453,8 +451,8 @@ lld::elf2::getLocalRelTarget(const ObjectFile<ELFT> &File, if (Section == &InputSection<ELFT>::Discarded) return 0; - OutputSection<ELFT> *OutSec = Section->getOutputSection(); - return OutSec->getVA() + Section->OutputSectionOff + Sym->st_value; + return Section->OutputSection->getVA() + Section->OutputSectionOff + + Sym->st_value; } // Returns true if a symbol can be replaced at load-time by a symbol @@ -628,7 +626,7 @@ void SymbolTableSection<ELFT>::writeLocalSymbols(uint8_t *&Buf) { &Sym, File->getSymbolTable(), File->getSymbolTableShndx()); ArrayRef<InputSection<ELFT> *> Sections = File->getSections(); const InputSection<ELFT> *Section = Sections[SecIndex]; - const OutputSection<ELFT> *OutSec = Section->getOutputSection(); + const OutputSection<ELFT> *OutSec = Section->OutputSection; ESym->st_shndx = OutSec->getSectionIndex(); VA += OutSec->getVA() + Section->OutputSectionOff; } @@ -696,7 +694,7 @@ void SymbolTableSection<ELFT>::writeGlobalSymbols(uint8_t *&Buf) { ESym->st_value = getSymVA<ELFT>(*Body); if (Section) - OutSec = Section->getOutputSection(); + OutSec = Section->OutputSection; if (isa<DefinedAbsolute<ELFT>>(Body)) ESym->st_shndx = SHN_ABS; |