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;
++NumVisible;
}
- OutputSection<ELFT> *BSSSec = nullptr;
-
private:
SymbolTable &Table;
StringTableSection<ELFT::Is64Bits> &StrTabSec;
unsigned NumVisible = 0;
+ const Writer<ELFT> &W;
};
template <bool Is64Bits>
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();
SymbolTableSection<ELFT> SymTable;
DynamicSection<ELFT::Is64Bits> DynamicSec;
+
+ OutputSection<ELFT> *BSSSec = nullptr;
};
} // anonymous namespace
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())
}
}
- 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()) {