[lld] r270533 - Do not pass the symbol table. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon May 23 21:25:47 PDT 2016
Author: ruiu
Date: Mon May 23 23:25:47 2016
New Revision: 270533
URL: http://llvm.org/viewvc/llvm-project?rev=270533&view=rev
Log:
Do not pass the symbol table. NFC.
Since the symbol table is a singleton class and globally accessible,
we don't need to pass it around.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=270533&r1=270532&r2=270533&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon May 23 23:25:47 2016
@@ -566,9 +566,8 @@ void GnuHashTableSection<ELFT>::addSymbo
}
template <class ELFT>
-DynamicSection<ELFT>::DynamicSection(SymbolTable<ELFT> &SymTab)
- : OutputSectionBase<ELFT>(".dynamic", SHT_DYNAMIC, SHF_ALLOC | SHF_WRITE),
- SymTab(SymTab) {
+DynamicSection<ELFT>::DynamicSection()
+ : OutputSectionBase<ELFT>(".dynamic", SHT_DYNAMIC, SHF_ALLOC | SHF_WRITE) {
Elf_Shdr &Header = this->Header;
Header.sh_addralign = sizeof(uintX_t);
Header.sh_entsize = ELFT::Is64Bits ? 16 : 8;
@@ -594,7 +593,8 @@ template <class ELFT> void DynamicSectio
if (!Config->RPath.empty())
Add({Config->EnableNewDtags ? DT_RUNPATH : DT_RPATH,
Out<ELFT>::DynStrTab->addString(Config->RPath)});
- for (const std::unique_ptr<SharedFile<ELFT>> &F : SymTab.getSharedFiles())
+ for (const std::unique_ptr<SharedFile<ELFT>> &F :
+ Symtab<ELFT>::X->getSharedFiles())
if (F->isNeeded())
Add({DT_NEEDED, Out<ELFT>::DynStrTab->addString(F->getSoName())});
if (!Config->SoName.empty())
@@ -639,9 +639,9 @@ template <class ELFT> void DynamicSectio
Add({DT_FINI_ARRAYSZ, (uintX_t)FiniArraySec->getSize()});
}
- if (SymbolBody *B = SymTab.find(Config->Init))
+ if (SymbolBody *B = Symtab<ELFT>::X->find(Config->Init))
Add({DT_INIT, B});
- if (SymbolBody *B = SymTab.find(Config->Fini))
+ if (SymbolBody *B = Symtab<ELFT>::X->find(Config->Fini))
Add({DT_FINI, B});
uint32_t DtFlags = 0;
@@ -1214,11 +1214,11 @@ template <class ELFT> void StringTableSe
template <class ELFT>
SymbolTableSection<ELFT>::SymbolTableSection(
- SymbolTable<ELFT> &Table, StringTableSection<ELFT> &StrTabSec)
+ StringTableSection<ELFT> &StrTabSec)
: OutputSectionBase<ELFT>(StrTabSec.isDynamic() ? ".dynsym" : ".symtab",
StrTabSec.isDynamic() ? SHT_DYNSYM : SHT_SYMTAB,
StrTabSec.isDynamic() ? (uintX_t)SHF_ALLOC : 0),
- StrTabSec(StrTabSec), Table(Table) {
+ StrTabSec(StrTabSec) {
this->Header.sh_entsize = sizeof(Elf_Sym);
this->Header.sh_addralign = sizeof(uintX_t);
}
@@ -1303,7 +1303,8 @@ template <class ELFT>
void SymbolTableSection<ELFT>::writeLocalSymbols(uint8_t *&Buf) {
// Iterate over all input object files to copy their local symbols
// to the output symbol table pointed by Buf.
- for (const std::unique_ptr<ObjectFile<ELFT>> &File : Table.getObjectFiles()) {
+ for (const std::unique_ptr<ObjectFile<ELFT>> &File :
+ Symtab<ELFT>::X->getObjectFiles()) {
for (const std::pair<const DefinedRegular<ELFT> *, size_t> &P :
File->KeptLocalSyms) {
const DefinedRegular<ELFT> &Body = *P.first;
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=270533&r1=270532&r2=270533&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Mon May 23 23:25:47 2016
@@ -201,8 +201,7 @@ public:
typedef typename ELFT::Sym Elf_Sym;
typedef typename ELFT::SymRange Elf_Sym_Range;
typedef typename ELFT::uint uintX_t;
- SymbolTableSection(SymbolTable<ELFT> &Table,
- StringTableSection<ELFT> &StrTabSec);
+ SymbolTableSection(StringTableSection<ELFT> &StrTabSec);
void finalize() override;
void writeTo(uint8_t *Buf) override;
@@ -223,8 +222,6 @@ private:
const OutputSectionBase<ELFT> *getOutputSection(SymbolBody *Sym);
- SymbolTable<ELFT> &Table;
-
// A vector of symbols and their string table offsets.
std::vector<std::pair<SymbolBody *, size_t>> Symbols;
};
@@ -485,16 +482,13 @@ class DynamicSection final : public Outp
std::vector<Entry> Entries;
public:
- explicit DynamicSection(SymbolTable<ELFT> &SymTab);
+ explicit DynamicSection();
void finalize() override;
void writeTo(uint8_t *Buf) override;
OutputSectionBase<ELFT> *PreInitArraySec = nullptr;
OutputSectionBase<ELFT> *InitArraySec = nullptr;
OutputSectionBase<ELFT> *FiniArraySec = nullptr;
-
-private:
- SymbolTable<ELFT> &SymTab;
};
template <class ELFT>
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=270533&r1=270532&r2=270533&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon May 23 23:25:47 2016
@@ -110,7 +110,7 @@ template <class ELFT> void elf::writeRes
// Create singleton output sections.
OutputSection<ELFT> Bss(".bss", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);
- DynamicSection<ELFT> Dynamic(*Symtab);
+ DynamicSection<ELFT> Dynamic;
EhOutputSection<ELFT> EhFrame;
GotSection<ELFT> Got;
InterpSection<ELFT> Interp;
@@ -119,7 +119,7 @@ template <class ELFT> void elf::writeRes
Config->ZCombreloc);
StringTableSection<ELFT> DynStrTab(".dynstr", true);
StringTableSection<ELFT> ShStrTab(".shstrtab", false);
- SymbolTableSection<ELFT> DynSymTab(*Symtab, DynStrTab);
+ SymbolTableSection<ELFT> DynSymTab(DynStrTab);
VersionTableSection<ELFT> VerSym;
VersionNeedSection<ELFT> VerNeed;
@@ -160,7 +160,7 @@ template <class ELFT> void elf::writeRes
RelaPlt.reset(new RelocationSection<ELFT>(S, false /*Sort*/));
if (!Config->StripAll) {
StrTab.reset(new StringTableSection<ELFT>(".strtab", false));
- SymTabSec.reset(new SymbolTableSection<ELFT>(*Symtab, *StrTab));
+ SymTabSec.reset(new SymbolTableSection<ELFT>(*StrTab));
}
if (Config->EMachine == EM_MIPS && !Config->Shared) {
// This is a MIPS specific section to hold a space within the data segment
More information about the llvm-commits
mailing list