forked from OSchip/llvm-project
[obj2yaml] Don't crash for input files without symbol table
Summary: Previously we would dereference Symtab without checking for null. Reviewers: davide, atanasyan, rafael Reviewed By: davide, atanasyan Differential Revision: https://reviews.llvm.org/D38080 llvm-svn: 313970
This commit is contained in:
parent
8f719bacd0
commit
c46750ef42
Binary file not shown.
|
@ -0,0 +1,5 @@
|
||||||
|
# RUN: obj2yaml %S/Inputs/crt1.o | FileCheck %s
|
||||||
|
# test that we don't crash when passed object files without a symbol table
|
||||||
|
# CHECK-LABEL: FileHeader:
|
||||||
|
# CHECK-LABEL: Sections:
|
||||||
|
# CHECK-LABEL: Symbols:
|
|
@ -188,6 +188,8 @@ template <class ELFT> ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump symbols
|
// Dump symbols
|
||||||
|
if (!Symtab)
|
||||||
|
return Y.release(); // if the symbol table is missing return early
|
||||||
auto StrTableOrErr = Obj.getStringTableForSymtab(*Symtab);
|
auto StrTableOrErr = Obj.getStringTableForSymtab(*Symtab);
|
||||||
if (!StrTableOrErr)
|
if (!StrTableOrErr)
|
||||||
return errorToErrorCode(StrTableOrErr.takeError());
|
return errorToErrorCode(StrTableOrErr.takeError());
|
||||||
|
|
Loading…
Reference in New Issue