]> granicus.if.org Git - llvm/commitdiff
[Object, ELF] Don't call llvm_unreachable() from createELFObjectFile.
authorAlexey Samsonov <vonosmas@gmail.com>
Thu, 4 Jun 2015 22:58:25 +0000 (22:58 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Thu, 4 Jun 2015 22:58:25 +0000 (22:58 +0000)
Instead, return a proper error code from factory.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239113 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/ELFObjectFile.cpp
test/DebugInfo/Inputs/invalid.elf.2 [new file with mode: 0644]
test/DebugInfo/dwarfdump-invalid.test

index 8847a20d96e86b737f36da04a0111542702d336c..1ffdc01bcd34fe4d8444a0b5935104f815d7d188 100644 (file)
@@ -38,7 +38,7 @@ ObjectFile::createELFObjectFile(MemoryBufferRef Obj) {
     else if (Ident.second == ELF::ELFDATA2MSB)
       R.reset(new ELFObjectFile<ELFType<support::big, false>>(Obj, EC));
     else
-      llvm_unreachable("Buffer is not an ELF object file!");
+      return object_error::parse_failed;
   } else {
     assert(Ident.first == ELF::ELFCLASS64);
     if (Ident.second == ELF::ELFDATA2LSB)
@@ -46,7 +46,7 @@ ObjectFile::createELFObjectFile(MemoryBufferRef Obj) {
     else if (Ident.second == ELF::ELFDATA2MSB)
       R.reset(new ELFObjectFile<ELFType<support::big, true>>(Obj, EC));
     else
-      llvm_unreachable("Buffer is not an ELF object file!");
+      return object_error::parse_failed;
   }
 
   if (EC)
diff --git a/test/DebugInfo/Inputs/invalid.elf.2 b/test/DebugInfo/Inputs/invalid.elf.2
new file mode 100644 (file)
index 0000000..16528a5
--- /dev/null
@@ -0,0 +1 @@
+\7fELF\ 2'L:þB\93\7fELF\ 2\7fï\ 1\ 1\ 1
\ No newline at end of file
index dcbdd739190e5b9f3e484a093209bfafa82f1074..5b616bd5581dec43aa3f8a6a5a67a8cb3e33f4c3 100644 (file)
@@ -1,4 +1,5 @@
 ; Verify that llvm-dwarfdump doesn't crash on broken input files.
 
 RUN: llvm-dwarfdump %p/Inputs/invalid.elf 2>&1 | FileCheck %s --check-prefix=INVALID-ELF
+RUN: llvm-dwarfdump %p/Inputs/invalid.elf.2 2>&1 | FileCheck %s --check-prefix=INVALID-ELF
 INVALID-ELF: Invalid data was encountered while parsing the file