summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xllvm/test/tools/obj2yaml/Inputs/crt1.obin0 -> 2712 bytes
-rw-r--r--llvm/test/tools/obj2yaml/missing_symtab.test5
-rw-r--r--llvm/tools/obj2yaml/elf2yaml.cpp2
3 files changed, 7 insertions, 0 deletions
diff --git a/llvm/test/tools/obj2yaml/Inputs/crt1.o b/llvm/test/tools/obj2yaml/Inputs/crt1.o
new file mode 100755
index 00000000000..2b000ab9ae8
--- /dev/null
+++ b/llvm/test/tools/obj2yaml/Inputs/crt1.o
Binary files differ
diff --git a/llvm/test/tools/obj2yaml/missing_symtab.test b/llvm/test/tools/obj2yaml/missing_symtab.test
new file mode 100644
index 00000000000..b992931a0db
--- /dev/null
+++ b/llvm/test/tools/obj2yaml/missing_symtab.test
@@ -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:
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp
index 8997a5c4211..8c94843788f 100644
--- a/llvm/tools/obj2yaml/elf2yaml.cpp
+++ b/llvm/tools/obj2yaml/elf2yaml.cpp
@@ -188,6 +188,8 @@ template <class ELFT> ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
}
// Dump symbols
+ if (!Symtab)
+ return Y.release(); // if the symbol table is missing return early
auto StrTableOrErr = Obj.getStringTableForSymtab(*Symtab);
if (!StrTableOrErr)
return errorToErrorCode(StrTableOrErr.takeError());
OpenPOWER on IntegriCloud