summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-09-11 00:10:11 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-09-11 00:10:11 +0000
commit24d07fdd27dd316c923ec633f41678322aef7401 (patch)
tree53b3a504359d24674d84fabb87e5774624cffbcc
parent7531f7dd8d012f8820ca367353788dd1938398b2 (diff)
downloadbcm5719-llvm-24d07fdd27dd316c923ec633f41678322aef7401.tar.gz
bcm5719-llvm-24d07fdd27dd316c923ec633f41678322aef7401.zip
Cache the bss output section in the writer, not in the symbol table.
There is soon going to be two symbol tables, but there will still be only one output bss. llvm-svn: 247363
-rw-r--r--lld/ELF/Writer.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 294c44d727b..b81e20813d5 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -132,15 +132,17 @@ private:
llvm::StringTableBuilder StrTabBuilder;
};
+template <class ELFT> class Writer;
+
template <class ELFT>
class SymbolTableSection final : public OutputSectionBase<ELFT::Is64Bits> {
public:
typedef typename ELFFile<ELFT>::Elf_Sym Elf_Sym;
typedef typename OutputSectionBase<ELFT::Is64Bits>::uintX_t uintX_t;
- SymbolTableSection(SymbolTable &Table,
+ SymbolTableSection(Writer<ELFT> &W, SymbolTable &Table,
StringTableSection<ELFT::Is64Bits> &StrTabSec)
: OutputSectionBase<ELFT::Is64Bits>(".symtab", SHT_SYMTAB, 0),
- Table(Table), StrTabSec(StrTabSec) {
+ Table(Table), StrTabSec(StrTabSec), W(W) {
typedef OutputSectionBase<ELFT::Is64Bits> Base;
typename Base::HeaderT &Header = this->Header;
@@ -165,12 +167,11 @@ public:
++NumVisible;
}
- OutputSection<ELFT> *BSSSec = nullptr;
-
private:
SymbolTable &Table;
StringTableSection<ELFT::Is64Bits> &StrTabSec;
unsigned NumVisible = 0;
+ const Writer<ELFT> &W;
};
template <bool Is64Bits>
@@ -246,10 +247,15 @@ public:
typedef typename ELFFile<ELFT>::Elf_Phdr Elf_Phdr;
typedef typename ELFFile<ELFT>::Elf_Sym Elf_Sym;
Writer(SymbolTable *T)
- : StrTabSec(false), DynStrSec(true), SymTable(*T, StrTabSec),
+ : StrTabSec(false), DynStrSec(true), SymTable(*this, *T, StrTabSec),
DynamicSec(*T, DynStrSec) {}
void run();
+ const OutputSection<ELFT> &getBSS() const {
+ assert(BSSSec);
+ return *BSSSec;
+ }
+
private:
void createSections();
void assignAddresses();
@@ -273,6 +279,8 @@ private:
SymbolTableSection<ELFT> SymTable;
DynamicSection<ELFT::Is64Bits> DynamicSec;
+
+ OutputSection<ELFT> *BSSSec = nullptr;
};
} // anonymous namespace
@@ -406,14 +414,14 @@ template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) {
ESym->st_name = StrTabSec.getFileOff(Name);
const SectionChunk<ELFT> *Section = nullptr;
- OutputSection<ELFT> *Out = nullptr;
+ const OutputSection<ELFT> *Out = nullptr;
switch (Body->kind()) {
case SymbolBody::DefinedRegularKind:
Section = &cast<DefinedRegular<ELFT>>(Body)->Section;
break;
case SymbolBody::DefinedCommonKind:
- Out = BSSSec;
+ Out = &W.getBSS();
break;
case SymbolBody::UndefinedKind:
if (!Body->isWeak())
@@ -546,8 +554,7 @@ template <class ELFT> void Writer<ELFT>::createSections() {
}
}
- SymTable.BSSSec = getSection(".bss", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);
- OutputSection<ELFT> *BSSSec = SymTable.BSSSec;
+ BSSSec = getSection(".bss", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);
// FIXME: Try to avoid the extra walk over all global symbols.
std::vector<DefinedCommon<ELFT> *> CommonSymbols;
for (auto &P : Symtab.getSymbols()) {
OpenPOWER on IntegriCloud