[lld] r296314 - Rename SyntheticSection::finalize -> finalizeContents.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 26 19:07:42 PST 2017
Author: ruiu
Date: Sun Feb 26 21:07:41 2017
New Revision: 296314
URL: http://llvm.org/viewvc/llvm-project?rev=296314&view=rev
Log:
Rename SyntheticSection::finalize -> finalizeContents.
In LLD source code, too many functions are called "finalize", although
what they do are different. This patch gives it a better name.
Modified:
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=296314&r1=296313&r2=296314&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Sun Feb 26 21:07:41 2017
@@ -526,7 +526,7 @@ static void writeCieFde(uint8_t *Buf, Ar
write32<E>(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4);
}
-template <class ELFT> void EhFrameSection<ELFT>::finalize() {
+template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() {
if (this->Size)
return; // Already finalized.
@@ -651,7 +651,7 @@ GotSection<ELFT>::getGlobalDynOffset(con
return B.GlobalDynIndex * sizeof(uintX_t);
}
-template <class ELFT> void GotSection<ELFT>::finalize() {
+template <class ELFT> void GotSection<ELFT>::finalizeContents() {
Size = NumEntries * sizeof(uintX_t);
}
@@ -831,7 +831,7 @@ unsigned MipsGotSection<ELFT>::getLocalE
LocalEntries32.size();
}
-template <class ELFT> void MipsGotSection<ELFT>::finalize() {
+template <class ELFT> void MipsGotSection<ELFT>::finalizeContents() {
PageEntriesNum = 0;
for (std::pair<const OutputSection *, size_t> &P : PageIndexMap) {
// For each output section referenced by GOT page relocations calculate
@@ -1068,7 +1068,7 @@ template <class ELFT> void DynamicSectio
}
// Add remaining entries to complete .dynamic contents.
-template <class ELFT> void DynamicSection<ELFT>::finalize() {
+template <class ELFT> void DynamicSection<ELFT>::finalizeContents() {
if (this->Size)
return; // Already finalized.
@@ -1258,7 +1258,7 @@ template <class ELFT> unsigned Relocatio
return this->Entsize * Relocs.size();
}
-template <class ELFT> void RelocationSection<ELFT>::finalize() {
+template <class ELFT> void RelocationSection<ELFT>::finalizeContents() {
this->Link = In<ELFT>::DynSymTab ? In<ELFT>::DynSymTab->OutSec->SectionIndex
: In<ELFT>::SymTab->OutSec->SectionIndex;
@@ -1293,7 +1293,7 @@ static bool sortMipsSymbols(const Symbol
return L->GotIndex < R->GotIndex;
}
-template <class ELFT> void SymbolTableSection<ELFT>::finalize() {
+template <class ELFT> void SymbolTableSection<ELFT>::finalizeContents() {
this->OutSec->Link = this->Link = StrTabSec.OutSec->SectionIndex;
this->OutSec->Entsize = this->Entsize;
@@ -1512,7 +1512,7 @@ unsigned GnuHashTableSection<ELFT>::calc
return NextPowerOf2((NumHashed - 1) / sizeof(Elf_Off));
}
-template <class ELFT> void GnuHashTableSection<ELFT>::finalize() {
+template <class ELFT> void GnuHashTableSection<ELFT>::finalizeContents() {
unsigned NumHashed = Symbols.size();
NBuckets = calcNBuckets(NumHashed);
MaskWords = calcMaskWords(NumHashed);
@@ -1625,7 +1625,7 @@ HashTableSection<ELFT>::HashTableSection
this->Entsize = sizeof(Elf_Word);
}
-template <class ELFT> void HashTableSection<ELFT>::finalize() {
+template <class ELFT> void HashTableSection<ELFT>::finalizeContents() {
this->OutSec->Link = this->Link = In<ELFT>::DynSymTab->OutSec->SectionIndex;
this->OutSec->Entsize = this->Entsize;
@@ -1770,7 +1770,7 @@ template <class ELFT> void GdbIndexSecti
}
}
-template <class ELFT> void GdbIndexSection<ELFT>::finalize() {
+template <class ELFT> void GdbIndexSection<ELFT>::finalizeContents() {
if (Finalized)
return;
Finalized = true;
@@ -1795,7 +1795,7 @@ template <class ELFT> void GdbIndexSecti
}
template <class ELFT> size_t GdbIndexSection<ELFT>::getSize() const {
- const_cast<GdbIndexSection<ELFT> *>(this)->finalize();
+ const_cast<GdbIndexSection<ELFT> *>(this)->finalizeContents();
return StringPoolOffset + StringPool.getSize();
}
@@ -1918,7 +1918,7 @@ static StringRef getFileDefName() {
return Config->OutputFile;
}
-template <class ELFT> void VersionDefinitionSection<ELFT>::finalize() {
+template <class ELFT> void VersionDefinitionSection<ELFT>::finalizeContents() {
FileDefNameOff = In<ELFT>::DynStrTab->addString(getFileDefName());
for (VersionDefinition &V : Config->VersionDefinitions)
V.NameOff = In<ELFT>::DynStrTab->addString(V.Name);
@@ -1971,7 +1971,7 @@ VersionTableSection<ELFT>::VersionTableS
: SyntheticSection(SHF_ALLOC, SHT_GNU_versym, sizeof(uint16_t),
".gnu.version") {}
-template <class ELFT> void VersionTableSection<ELFT>::finalize() {
+template <class ELFT> void VersionTableSection<ELFT>::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 <class ELFT> void VersionNeedSe
Verneed[-1].vn_next = 0;
}
-template <class ELFT> void VersionNeedSection<ELFT>::finalize() {
+template <class ELFT> void VersionNeedSection<ELFT>::finalizeContents() {
this->OutSec->Link = this->Link = In<ELFT>::DynStrTab->OutSec->SectionIndex;
this->OutSec->Info = this->Info = Needed.size();
}
@@ -2138,7 +2138,7 @@ template <class ELFT> void MergeSyntheti
Builder.finalizeInOrder();
}
-template <class ELFT> void MergeSyntheticSection<ELFT>::finalize() {
+template <class ELFT> void MergeSyntheticSection<ELFT>::finalizeContents() {
if (Finalized)
return;
Finalized = true;
@@ -2150,7 +2150,7 @@ template <class ELFT> void MergeSyntheti
template <class ELFT> size_t MergeSyntheticSection<ELFT>::getSize() const {
// We should finalize string builder to know the size.
- const_cast<MergeSyntheticSection<ELFT> *>(this)->finalize();
+ const_cast<MergeSyntheticSection<ELFT> *>(this)->finalizeContents();
return Builder.getSize();
}
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=296314&r1=296313&r2=296314&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Sun Feb 26 21:07:41 2017
@@ -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 ELFT> class EhFrameSecti
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 ELFT> class DynamicSecti
: 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<Entry> 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<ELFT> &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<ELFT> &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
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 ELFT> class HashTableSec
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 ELFT> class GdbIndexSect
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 : p
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
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 ELFT> class VersionNeedS
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<ELFT> *MS);
void writeTo(uint8_t *Buf) override;
- void finalize() override;
+ void finalizeContents() override;
bool shouldTailMerge() const;
size_t getSize() const override;
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=296314&r1=296313&r2=296314&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sun Feb 26 21:07:41 2017
@@ -1025,7 +1025,7 @@ template <class ELFT>
static void finalizeSynthetic(const std::vector<SyntheticSection *> &Sections) {
for (SyntheticSection *SS : Sections)
if (SS && SS->OutSec && !SS->empty()) {
- SS->finalize();
+ SS->finalizeContents();
SS->OutSec->Size = 0;
SS->OutSec->template assignOffsets<ELFT>();
}
More information about the llvm-commits
mailing list