forked from OSchip/llvm-project
[Object] object::ELFObjectFile::symbol_begin(): skip symbol index 0
For clients iterating the symbol table, none expects to handle index 0 (STN_UNDEF). Skip it to improve consistency with other binary formats. Clients that need STN_UNDEF (e.g. lld) can use getSectionContentsAsArray(). A test will be added in D62148. Reviewed By: mtrent Differential Revision: https://reviews.llvm.org/D62296 llvm-svn: 361506
This commit is contained in:
parent
8cffa84850
commit
6aebd8394a
|
@ -982,7 +982,9 @@ ELFObjectFile<ELFT>::ELFObjectFile(ELFObjectFile<ELFT> &&Other)
|
|||
|
||||
template <class ELFT>
|
||||
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
|
||||
DataRefImpl Sym = toDRI(DotSymtabSec, 0);
|
||||
DataRefImpl Sym =
|
||||
toDRI(DotSymtabSec,
|
||||
DotSymtabSec && DotSymtabSec->sh_size >= sizeof(Elf_Sym) ? 1 : 0);
|
||||
return basic_symbol_iterator(SymbolRef(Sym, this));
|
||||
}
|
||||
|
||||
|
|
|
@ -1643,11 +1643,6 @@ void printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
|
|||
|
||||
const StringRef FileName = O->getFileName();
|
||||
for (auto I = O->symbol_begin(), E = O->symbol_end(); I != E; ++I) {
|
||||
// Skip printing the special zero symbol when dumping an ELF file.
|
||||
// This makes the output consistent with the GNU objdump.
|
||||
if (I == O->symbol_begin() && isa<ELFObjectFileBase>(O))
|
||||
continue;
|
||||
|
||||
const SymbolRef &Symbol = *I;
|
||||
uint64_t Address = unwrapOrError(Symbol.getAddress(), ArchiveName, FileName,
|
||||
ArchitectureName);
|
||||
|
|
Loading…
Reference in New Issue