uint64_t Size = ELFObj->getNumSections();
Chunks.reserve(Size);
for (const Elf_Shdr &Sec : ELFObj->sections()) {
+ if (Sec.sh_type == SHT_SYMTAB) {
+ Symtab = &Sec;
+ continue;
+ }
if (Sec.sh_flags & SHF_ALLOC) {
auto *C = new (Alloc) SectionChunk<ELFT>(this->getObj(), &Sec);
Chunks.push_back(C);
}
template <class ELFT> void elf2::ObjectFile<ELFT>::initializeSymbols() {
- const Elf_Shdr *Symtab = ELFObj->getDotSymtabSec();
ErrorOr<StringRef> StringTableOrErr =
ELFObj->getStringTableForSymtab(*Symtab);
error(StringTableOrErr.getError());
// Record the number of relocs to guess at preallocating the buffer.
uint64_t totalRelocs = 0;
for (const Elf_Shdr §ion : _objFile->sections()) {
+ if (section.sh_type == llvm::ELF::SHT_SYMTAB) {
+ _symtab = §ion;
+ continue;
+ }
+
if (isIgnoredSection(§ion))
continue;
std::error_code ELFFile<ELFT>::createSymbolsFromAtomizableSections() {
// Increment over all the symbols collecting atoms and symbol names for
// later use.
- const Elf_Shdr *symtab = _objFile->getDotSymtabSec();
- if (!symtab)
+ if (!_symtab)
return std::error_code();
- ErrorOr<StringRef> strTableOrErr = _objFile->getStringTableForSymtab(*symtab);
+ ErrorOr<StringRef> strTableOrErr =
+ _objFile->getStringTableForSymtab(*_symtab);
if (std::error_code ec = strTableOrErr.getError())
return ec;
StringRef strTable = *strTableOrErr;
- auto SymI = _objFile->symbol_begin(symtab),
- SymE = _objFile->symbol_end(symtab);
+ auto SymI = _objFile->symbol_begin(_symtab),
+ SymE = _objFile->symbol_end(_symtab);
// Skip over dummy sym.
++SymI;
for (; SymI != SymE; ++SymI) {
- ErrorOr<const Elf_Shdr *> section = _objFile->getSection(&*SymI);
+ ErrorOr<const Elf_Shdr *> section = _objFile->getSection(SymI);
if (std::error_code ec = section.getError())
return ec;
ELFDefinedAtom<ELFT> *previousAtom = nullptr;
ELFReference<ELFT> *anonFollowedBy = nullptr;
- const Elf_Shdr *symtab = _objFile->getDotSymtabSec();
- if (!symtab)
+ if (!_symtab)
continue;
ErrorOr<StringRef> strTableOrErr =
- _objFile->getStringTableForSymtab(*symtab);
+ _objFile->getStringTableForSymtab(*_symtab);
if (std::error_code ec = strTableOrErr.getError())
return ec;
StringRef strTable = *strTableOrErr;
}
template <class ELFT> void ELFFile<ELFT>::updateReferences() {
- const Elf_Shdr *symtab = _objFile->getDotSymtabSec();
for (auto &ri : _references) {
if (ri->kindNamespace() != Reference::KindNamespace::ELF)
continue;
const Elf_Sym *symbol =
- _objFile->getSymbol(symtab, ri->targetSymbolIndex());
+ _objFile->getSymbol(_symtab, ri->targetSymbolIndex());
ErrorOr<const Elf_Shdr *> shdr = _objFile->getSection(symbol);
// If the atom is not in mergeable string section, the target atom is