Object: Handle files without a dynamic symbol table.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294013 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne 2017-02-03 16:53:55 +00:00
parent 4692382fbf
commit 055ebfae9a
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