[lld] r244451 - Don't depend on getDotSymtabSec. It is going away.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 10 08:12:17 PDT 2015
Author: rafael
Date: Mon Aug 10 10:12:17 2015
New Revision: 244451
URL: http://llvm.org/viewvc/llvm-project?rev=244451&view=rev
Log:
Don't depend on getDotSymtabSec. It is going away.
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/InputFiles.h
lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=244451&r1=244450&r2=244451&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Mon Aug 10 10:12:17 2015
@@ -41,6 +41,10 @@ template <class ELFT> void elf2::ObjectF
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);
@@ -49,7 +53,6 @@ template <class ELFT> void elf2::ObjectF
}
template <class ELFT> void elf2::ObjectFile<ELFT>::initializeSymbols() {
- const Elf_Shdr *Symtab = ELFObj->getDotSymtabSec();
ErrorOr<StringRef> StringTableOrErr =
ELFObj->getStringTableForSymtab(*Symtab);
error(StringTableOrErr.getError());
Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=244451&r1=244450&r2=244451&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Mon Aug 10 10:12:17 2015
@@ -100,6 +100,8 @@ private:
// List of all chunks defined by this file.
std::vector<SectionChunk<ELFT> *> Chunks;
+
+ const Elf_Shdr *Symtab = nullptr;
};
} // namespace elf2
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp?rev=244451&r1=244450&r2=244451&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp Mon Aug 10 10:12:17 2015
@@ -125,6 +125,11 @@ std::error_code ELFFile<ELFT>::createAto
// 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;
@@ -208,22 +213,22 @@ template <class ELFT>
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;
@@ -309,11 +314,10 @@ template <class ELFT> std::error_code EL
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;
@@ -664,12 +668,11 @@ void ELFFile<ELFT>::updateReferenceForMe
}
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
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=244451&r1=244450&r2=244451&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Mon Aug 10 10:12:17 2015
@@ -320,6 +320,7 @@ protected:
llvm::BumpPtrAllocator _readerStorage;
std::unique_ptr<llvm::object::ELFFile<ELFT> > _objFile;
+ const Elf_Shdr *_symtab = nullptr;
/// \brief _relocationAddendReferences and _relocationReferences contain the
/// list of relocations references. In ELF, if a section named, ".text" has
More information about the llvm-commits
mailing list