Avoid SEGFAULT if a requested symbol section is absent.

Patch by Igor Kudrin!

llvm-svn: 248194
This commit is contained in:
Rafael Espindola 2015-09-21 19:17:18 +00:00
parent 98a98cffb6
commit 8055ed0c12
2 changed files with 4 additions and 0 deletions

View File

@ -0,0 +1,2 @@
// Don't crash if required information is absent
RUN: llvm-readobj -dyn-symbols %p/Inputs/trivial-object-test.elf-x86-64

View File

@ -1152,6 +1152,8 @@ void ELFDumper<ELFT>::printRelocation(Elf_Rela Rel, const Elf_Shdr *SymTab) {
template<class ELFT>
void ELFDumper<ELFT>::printSymbolsHelper(bool IsDynamic) {
const Elf_Shdr *Symtab = (IsDynamic) ? DotDynSymSec : DotSymtabSec;
if (!Symtab)
return;
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab);
error(StrTableOrErr.getError());
StringRef StrTable = *StrTableOrErr;