[Object, ELF] Don't call llvm_unreachable() from createELFObjectFile.

Instead, return a proper error code from factory.

llvm-svn: 239113
This commit is contained in:
Alexey Samsonov 2015-06-04 22:58:25 +00:00
parent 64c2f5a50f
commit 18ad2e54ab
3 changed files with 4 additions and 2 deletions

View 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)

View File

@ -0,0 +1 @@
ELF'L:þB“ELF

View 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