Object: Handle files without a dynamic symbol table.

Differential Revision: https://reviews.llvm.org/D29482

llvm-svn: 294013
This commit is contained in:
Peter Collingbourne 2017-02-03 16:53:55 +00:00
parent 68e9d94055
commit cce2d8028f
2 changed files with 4 additions and 0 deletions

View File

@ -895,6 +895,8 @@ elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_begin() const {
template <class ELFT>
elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
const Elf_Shdr *SymTab = DotDynSymSec;
if (!SymTab)
return dynamic_symbol_begin();
DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
return basic_symbol_iterator(SymbolRef(Sym, this));
}

View File

@ -29,3 +29,5 @@ RUN: not llvm-nm -D %p/Inputs/trivial-object-test.coff-i386 2>&1 \
RUN: | FileCheck %s -check-prefix ERROR
ERROR: File format has no dynamic symbol table.
RUN: llvm-nm -D %p/Inputs/trivial-object-test.elf-i386 | count 0