diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 9f66c12193d3..3e97f0567678 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -526,7 +526,7 @@ static void writeCieFde(uint8_t *Buf, ArrayRef D) { write32(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4); } -template void EhFrameSection::finalize() { +template void EhFrameSection::finalizeContents() { if (this->Size) return; // Already finalized. @@ -651,7 +651,7 @@ GotSection::getGlobalDynOffset(const SymbolBody &B) const { return B.GlobalDynIndex * sizeof(uintX_t); } -template void GotSection::finalize() { +template void GotSection::finalizeContents() { Size = NumEntries * sizeof(uintX_t); } @@ -831,7 +831,7 @@ unsigned MipsGotSection::getLocalEntriesNum() const { LocalEntries32.size(); } -template void MipsGotSection::finalize() { +template void MipsGotSection::finalizeContents() { PageEntriesNum = 0; for (std::pair &P : PageIndexMap) { // For each output section referenced by GOT page relocations calculate @@ -1068,7 +1068,7 @@ template void DynamicSection::addEntries() { } // Add remaining entries to complete .dynamic contents. -template void DynamicSection::finalize() { +template void DynamicSection::finalizeContents() { if (this->Size) return; // Already finalized. @@ -1258,7 +1258,7 @@ template unsigned RelocationSection::getRelocOffset() { return this->Entsize * Relocs.size(); } -template void RelocationSection::finalize() { +template void RelocationSection::finalizeContents() { this->Link = In::DynSymTab ? In::DynSymTab->OutSec->SectionIndex : In::SymTab->OutSec->SectionIndex; @@ -1293,7 +1293,7 @@ static bool sortMipsSymbols(const SymbolBody *L, const SymbolBody *R) { return L->GotIndex < R->GotIndex; } -template void SymbolTableSection::finalize() { +template void SymbolTableSection::finalizeContents() { this->OutSec->Link = this->Link = StrTabSec.OutSec->SectionIndex; this->OutSec->Entsize = this->Entsize; @@ -1512,7 +1512,7 @@ unsigned GnuHashTableSection::calcMaskWords(unsigned NumHashed) { return NextPowerOf2((NumHashed - 1) / sizeof(Elf_Off)); } -template void GnuHashTableSection::finalize() { +template void GnuHashTableSection::finalizeContents() { unsigned NumHashed = Symbols.size(); NBuckets = calcNBuckets(NumHashed); MaskWords = calcMaskWords(NumHashed); @@ -1625,7 +1625,7 @@ HashTableSection::HashTableSection() this->Entsize = sizeof(Elf_Word); } -template void HashTableSection::finalize() { +template void HashTableSection::finalizeContents() { this->OutSec->Link = this->Link = In::DynSymTab->OutSec->SectionIndex; this->OutSec->Entsize = this->Entsize; @@ -1770,7 +1770,7 @@ template void GdbIndexSection::readDwarf(InputSection *I) { } } -template void GdbIndexSection::finalize() { +template void GdbIndexSection::finalizeContents() { if (Finalized) return; Finalized = true; @@ -1795,7 +1795,7 @@ template void GdbIndexSection::finalize() { } template size_t GdbIndexSection::getSize() const { - const_cast *>(this)->finalize(); + const_cast *>(this)->finalizeContents(); return StringPoolOffset + StringPool.getSize(); } @@ -1918,7 +1918,7 @@ static StringRef getFileDefName() { return Config->OutputFile; } -template void VersionDefinitionSection::finalize() { +template void VersionDefinitionSection::finalizeContents() { FileDefNameOff = In::DynStrTab->addString(getFileDefName()); for (VersionDefinition &V : Config->VersionDefinitions) V.NameOff = In::DynStrTab->addString(V.Name); @@ -1971,7 +1971,7 @@ VersionTableSection::VersionTableSection() : SyntheticSection(SHF_ALLOC, SHT_GNU_versym, sizeof(uint16_t), ".gnu.version") {} -template void VersionTableSection::finalize() { +template void VersionTableSection::finalizeContents() { this->OutSec->Entsize = this->Entsize = sizeof(Elf_Versym); // At the moment of june 2016 GNU docs does not mention that sh_link field // should be set, but Sun docs do. Also readelf relies on this field. @@ -2066,7 +2066,7 @@ template void VersionNeedSection::writeTo(uint8_t *Buf) { Verneed[-1].vn_next = 0; } -template void VersionNeedSection::finalize() { +template void VersionNeedSection::finalizeContents() { this->OutSec->Link = this->Link = In::DynStrTab->OutSec->SectionIndex; this->OutSec->Info = this->Info = Needed.size(); } @@ -2138,7 +2138,7 @@ template void MergeSyntheticSection::finalizeNoTailMerge() { Builder.finalizeInOrder(); } -template void MergeSyntheticSection::finalize() { +template void MergeSyntheticSection::finalizeContents() { if (Finalized) return; Finalized = true; @@ -2150,7 +2150,7 @@ template void MergeSyntheticSection::finalize() { template size_t MergeSyntheticSection::getSize() const { // We should finalize string builder to know the size. - const_cast *>(this)->finalize(); + const_cast *>(this)->finalizeContents(); return Builder.getSize(); } diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index 513a70f3a40d..69f5cc81494e 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -42,7 +42,7 @@ public: virtual ~SyntheticSection() = default; virtual void writeTo(uint8_t *Buf) = 0; virtual size_t getSize() const = 0; - virtual void finalize() {} + virtual void finalizeContents() {} virtual bool empty() const { return false; } uint64_t getVA() const; @@ -71,7 +71,7 @@ template class EhFrameSection final : public SyntheticSection { public: EhFrameSection(); void writeTo(uint8_t *Buf) override; - void finalize() override; + void finalizeContents() override; bool empty() const override { return Sections.empty(); } size_t getSize() const override { return Size; } @@ -106,7 +106,7 @@ public: GotSection(); void writeTo(uint8_t *Buf) override; size_t getSize() const override { return Size; } - void finalize() override; + void finalizeContents() override; bool empty() const override; void addEntry(SymbolBody &Sym); @@ -166,7 +166,7 @@ public: MipsGotSection(); void writeTo(uint8_t *Buf) override; size_t getSize() const override { return Size; } - void finalize() override; + void finalizeContents() override; bool empty() const override; void addEntry(SymbolBody &Sym, int64_t Addend, RelExpr Expr); bool addDynTlsEntry(SymbolBody &Sym); @@ -363,14 +363,14 @@ template class DynamicSection final : public SyntheticSection { : Tag(Tag), Sym(Sym), Kind(SymAddr) {} }; - // finalize() fills this vector with the section contents. finalize() - // cannot directly create final section contents because when the - // function is called, symbol or section addresses are not fixed yet. + // finalizeContents() fills this vector with the section contents. + // finalizeContents()cannot directly create final section contents because + // when the function is called, symbol or section addresses are not fixed yet. std::vector Entries; public: DynamicSection(); - void finalize() override; + void finalizeContents() override; void writeTo(uint8_t *Buf) override; size_t getSize() const override { return Size; } @@ -389,7 +389,7 @@ public: RelocationSection(StringRef Name, bool Sort); void addReloc(const DynamicReloc &Reloc); unsigned getRelocOffset(); - void finalize() override; + void finalizeContents() override; void writeTo(uint8_t *Buf) override; bool empty() const override { return Relocs.empty(); } size_t getSize() const override { return Relocs.size() * this->Entsize; } @@ -414,7 +414,7 @@ public: typedef typename ELFT::uint uintX_t; SymbolTableSection(StringTableSection &StrTabSec); - void finalize() override; + void finalizeContents() override; void writeTo(uint8_t *Buf) override; size_t getSize() const override { return getNumSymbols() * sizeof(Elf_Sym); } void addGlobal(SymbolBody *Body); @@ -449,7 +449,7 @@ class GnuHashTableSection final : public SyntheticSection { public: GnuHashTableSection(); - void finalize() override; + void finalizeContents() override; void writeTo(uint8_t *Buf) override; size_t getSize() const override { return this->Size; } @@ -484,7 +484,7 @@ template class HashTableSection final : public SyntheticSection { public: HashTableSection(); - void finalize() override; + void finalizeContents() override; void writeTo(uint8_t *Buf) override; size_t getSize() const override { return this->Size; } @@ -525,7 +525,7 @@ template class GdbIndexSection final : public SyntheticSection { public: GdbIndexSection(); - void finalize() override; + void finalizeContents() override; void writeTo(uint8_t *Buf) override; size_t getSize() const override; bool empty() const override; @@ -600,7 +600,7 @@ class VersionDefinitionSection final : public SyntheticSection { public: VersionDefinitionSection(); - void finalize() override; + void finalizeContents() override; size_t getSize() const override; void writeTo(uint8_t *Buf) override; @@ -622,7 +622,7 @@ class VersionTableSection final : public SyntheticSection { public: VersionTableSection(); - void finalize() override; + void finalizeContents() override; size_t getSize() const override; void writeTo(uint8_t *Buf) override; bool empty() const override; @@ -647,7 +647,7 @@ template class VersionNeedSection final : public SyntheticSection { public: VersionNeedSection(); void addSymbol(SharedSymbol *SS); - void finalize() override; + void finalizeContents() override; void writeTo(uint8_t *Buf) override; size_t getSize() const override; size_t getNeedNum() const { return Needed.size(); } @@ -667,7 +667,7 @@ public: uintX_t Alignment); void addSection(MergeInputSection *MS); void writeTo(uint8_t *Buf) override; - void finalize() override; + void finalizeContents() override; bool shouldTailMerge() const; size_t getSize() const override; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 3db4f4fa74b5..127bfdc249f0 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1025,7 +1025,7 @@ template static void finalizeSynthetic(const std::vector &Sections) { for (SyntheticSection *SS : Sections) if (SS && SS->OutSec && !SS->empty()) { - SS->finalize(); + SS->finalizeContents(); SS->OutSec->Size = 0; SS->OutSec->template assignOffsets(); }