[llvm] r239113 - [Object, ELF] Don't call llvm_unreachable() from createELFObjectFile.
Alexey Samsonov
vonosmas at gmail.com
Thu Jun 4 15:58:25 PDT 2015
Author: samsonov
Date: Thu Jun 4 17:58:25 2015
New Revision: 239113
URL: http://llvm.org/viewvc/llvm-project?rev=239113&view=rev
Log:
[Object, ELF] Don't call llvm_unreachable() from createELFObjectFile.
Instead, return a proper error code from factory.
Added:
llvm/trunk/test/DebugInfo/Inputs/invalid.elf.2
Modified:
llvm/trunk/lib/Object/ELFObjectFile.cpp
llvm/trunk/test/DebugInfo/dwarfdump-invalid.test
Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=239113&r1=239112&r2=239113&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ELFObjectFile.cpp Thu Jun 4 17:58:25 2015
@@ -38,7 +38,7 @@ ObjectFile::createELFObjectFile(MemoryBu
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(MemoryBu
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)
Added: llvm/trunk/test/DebugInfo/Inputs/invalid.elf.2
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/invalid.elf.2?rev=239113&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/Inputs/invalid.elf.2 (added)
+++ llvm/trunk/test/DebugInfo/Inputs/invalid.elf.2 Thu Jun 4 17:58:25 2015
@@ -0,0 +1 @@
+ELF'L:þBELFï
\ No newline at end of file
Modified: llvm/trunk/test/DebugInfo/dwarfdump-invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-invalid.test?rev=239113&r1=239112&r2=239113&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/dwarfdump-invalid.test (original)
+++ llvm/trunk/test/DebugInfo/dwarfdump-invalid.test Thu Jun 4 17:58:25 2015
@@ -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
More information about the llvm-commits
mailing list