Avoid SEGFAULT if a requested symbol section is absent.

Patch by Igor Kudrin!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248194 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-09-21 19:17:18 +00:00
parent a2259fcf68
commit 82ede2f136
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;