Index: llvm/include/llvm/Object/ELFObjectFile.h =================================================================== --- llvm/include/llvm/Object/ELFObjectFile.h +++ llvm/include/llvm/Object/ELFObjectFile.h @@ -895,6 +895,8 @@ template elf_symbol_iterator ELFObjectFile::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)); } Index: llvm/test/Object/nm-shared-object.test =================================================================== --- llvm/test/Object/nm-shared-object.test +++ llvm/test/Object/nm-shared-object.test @@ -29,3 +29,5 @@ 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