[lld] r310931 - Remove GdbIndexSection::finalizeContents.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 10:01:39 PDT 2017
Author: ruiu
Date: Tue Aug 15 10:01:39 2017
New Revision: 310931
URL: http://llvm.org/viewvc/llvm-project?rev=310931&view=rev
Log:
Remove GdbIndexSection::finalizeContents.
GdbIndexSection doesn't need lazy finalization because when an instance
of the class is created, we already know all debug info sections.
We can initialize the instnace in the ctor.
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=310931&r1=310930&r2=310931&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Aug 15 10:01:39 2017
@@ -1708,10 +1708,6 @@ unsigned PltSection::getPltRelocOff() co
return (HeaderSize == 0) ? InX::Plt->getSize() : 0;
}
-GdbIndexSection::GdbIndexSection(std::vector<GdbIndexChunk> &&Chunks)
- : SyntheticSection(0, SHT_PROGBITS, 1, ".gdb_index"),
- StringPool(llvm::StringTableBuilder::ELF), Chunks(std::move(Chunks)) {}
-
// The hash function used for .gdb_index version 5 or above.
static uint32_t gdbHash(StringRef Str) {
uint32_t R = 0;
@@ -1793,7 +1789,7 @@ void GdbIndexSection::buildIndex() {
bool IsNew;
GdbSymbol *Sym;
- std::tie(IsNew, Sym) = SymbolTable.add(Hash, Offset);
+ std::tie(IsNew, Sym) = HashTab.add(Hash, Offset);
if (IsNew) {
Sym->CuVectorIndex = CuVectors.size();
CuVectors.resize(CuVectors.size() + 1);
@@ -1840,44 +1836,37 @@ static size_t getAddressAreaSize(ArrayRe
return Ret;
}
-void GdbIndexSection::finalizeContents() {
- if (Finalized)
- return;
- Finalized = true;
-
+GdbIndexSection::GdbIndexSection(std::vector<GdbIndexChunk> &&C)
+ : SyntheticSection(0, SHT_PROGBITS, 1, ".gdb_index"),
+ StringPool(llvm::StringTableBuilder::ELF), Chunks(std::move(C)) {
buildIndex();
-
- SymbolTable.finalizeContents();
+ HashTab.finalizeContents();
// GdbIndex header consist from version fields
// and 5 more fields with different kinds of offsets.
CuTypesOffset = CuListOffset + getCuSize(Chunks) * CompilationUnitSize;
SymTabOffset = CuTypesOffset + getAddressAreaSize(Chunks) * AddressEntrySize;
-
- ConstantPoolOffset =
- SymTabOffset + SymbolTable.getCapacity() * SymTabEntrySize;
+ ConstantPoolOffset = SymTabOffset + HashTab.getCapacity() * SymTabEntrySize;
for (std::set<uint32_t> &CuVec : CuVectors) {
CuVectorsOffset.push_back(CuVectorsSize);
CuVectorsSize += OffsetTypeSize * (CuVec.size() + 1);
}
StringPoolOffset = ConstantPoolOffset + CuVectorsSize;
-
StringPool.finalizeInOrder();
}
size_t GdbIndexSection::getSize() const {
- const_cast<GdbIndexSection *>(this)->finalizeContents();
return StringPoolOffset + StringPool.getSize();
}
void GdbIndexSection::writeTo(uint8_t *Buf) {
- write32le(Buf, 7); // Write version.
- write32le(Buf + 4, CuListOffset); // CU list offset.
- write32le(Buf + 8, CuTypesOffset); // Types CU list offset.
- write32le(Buf + 12, CuTypesOffset); // Address area offset.
- write32le(Buf + 16, SymTabOffset); // Symbol table offset.
- write32le(Buf + 20, ConstantPoolOffset); // Constant pool offset.
+ write32le(Buf, 7); // Write version
+ write32le(Buf + 4, CuListOffset); // CU list offset
+ write32le(Buf + 8, CuTypesOffset); // Types CU list offset
+ write32le(Buf + 12, CuTypesOffset); // Address area offset
+ write32le(Buf + 16, SymTabOffset); // Symbol table offset
+ write32le(Buf + 20, ConstantPoolOffset); // Constant pool offset
Buf += 24;
// Write the CU list.
@@ -1902,8 +1891,8 @@ void GdbIndexSection::writeTo(uint8_t *B
}
// Write the symbol table.
- for (size_t I = 0; I < SymbolTable.getCapacity(); ++I) {
- GdbSymbol *Sym = SymbolTable.getSymbol(I);
+ for (size_t I = 0; I < HashTab.getCapacity(); ++I) {
+ GdbSymbol *Sym = HashTab.getSymbol(I);
if (Sym) {
size_t NameOffset =
Sym->NameOffset + StringPoolOffset - ConstantPoolOffset;
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=310931&r1=310930&r2=310931&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Tue Aug 15 10:01:39 2017
@@ -504,14 +504,14 @@ class GdbIndexSection final : public Syn
public:
GdbIndexSection(std::vector<GdbIndexChunk> &&Chunks);
- void finalizeContents() override;
void writeTo(uint8_t *Buf) override;
size_t getSize() const override;
bool empty() const override;
+private:
// Symbol table is a hash table for types and names.
// It is the area of gdb index.
- GdbHashTab SymbolTable;
+ GdbHashTab HashTab;
// CU vector is a part of constant pool area of section.
std::vector<std::set<uint32_t>> CuVectors;
@@ -523,7 +523,6 @@ public:
// object and used to build different areas of gdb index.
std::vector<GdbIndexChunk> Chunks;
-private:
void buildIndex();
uint32_t CuTypesOffset;
@@ -533,8 +532,6 @@ private:
size_t CuVectorsSize = 0;
std::vector<size_t> CuVectorsOffset;
-
- bool Finalized = false;
};
template <class ELFT> GdbIndexSection *createGdbIndex();
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=310931&r1=310930&r2=310931&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Aug 15 10:01:39 2017
@@ -1293,14 +1293,18 @@ template <class ELFT> void Writer<ELFT>:
// Dynamic section must be the last one in this list and dynamic
// symbol table section (DynSymTab) must be the first one.
- applySynthetic({InX::DynSymTab, InX::Bss, InX::BssRelRo,
- InX::GnuHashTab, In<ELFT>::HashTab, InX::SymTab,
- InX::ShStrTab, InX::StrTab, In<ELFT>::VerDef,
- InX::DynStrTab, InX::GdbIndex, InX::Got,
- InX::MipsGot, InX::IgotPlt, InX::GotPlt,
- In<ELFT>::RelaDyn, In<ELFT>::RelaIplt, In<ELFT>::RelaPlt,
- InX::Plt, InX::Iplt, In<ELFT>::EhFrameHdr,
- In<ELFT>::VerSym, In<ELFT>::VerNeed, InX::Dynamic},
+ applySynthetic({InX::DynSymTab, InX::Bss,
+ InX::BssRelRo, InX::GnuHashTab,
+ In<ELFT>::HashTab, InX::SymTab,
+ InX::ShStrTab, InX::StrTab,
+ In<ELFT>::VerDef, InX::DynStrTab,
+ InX::Got, InX::MipsGot,
+ InX::IgotPlt, InX::GotPlt,
+ In<ELFT>::RelaDyn, In<ELFT>::RelaIplt,
+ In<ELFT>::RelaPlt, InX::Plt,
+ InX::Iplt, In<ELFT>::EhFrameHdr,
+ In<ELFT>::VerSym, In<ELFT>::VerNeed,
+ InX::Dynamic},
[](SyntheticSection *SS) { SS->finalizeContents(); });
// Some architectures use small displacements for jump instructions.
More information about the llvm-commits
mailing list