[llvm] r239116 - [Object, ELF] Don't assert on invalid magic in createELFObjectFile.
Alexey Samsonov
vonosmas at gmail.com
Thu Jun 4 16:14:43 PDT 2015
Author: samsonov
Date: Thu Jun 4 18:14:43 2015
New Revision: 239116
URL: http://llvm.org/viewvc/llvm-project?rev=239116&view=rev
Log:
[Object, ELF] Don't assert on invalid magic in createELFObjectFile.
Instead, return a proper error code from factory.
Added:
llvm/trunk/test/DebugInfo/Inputs/invalid.elf.3
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=239116&r1=239115&r2=239116&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ELFObjectFile.cpp Thu Jun 4 18:14:43 2015
@@ -39,14 +39,15 @@ ObjectFile::createELFObjectFile(MemoryBu
R.reset(new ELFObjectFile<ELFType<support::big, false>>(Obj, EC));
else
return object_error::parse_failed;
- } else {
- assert(Ident.first == ELF::ELFCLASS64);
+ } else if (Ident.first == ELF::ELFCLASS64) {
if (Ident.second == ELF::ELFDATA2LSB)
R.reset(new ELFObjectFile<ELFType<support::little, true>>(Obj, EC));
else if (Ident.second == ELF::ELFDATA2MSB)
R.reset(new ELFObjectFile<ELFType<support::big, true>>(Obj, EC));
else
return object_error::parse_failed;
+ } else {
+ return object_error::parse_failed;
}
if (EC)
Added: llvm/trunk/test/DebugInfo/Inputs/invalid.elf.3
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/invalid.elf.3?rev=239116&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/Inputs/invalid.elf.3 (added)
+++ llvm/trunk/test/DebugInfo/Inputs/invalid.elf.3 Thu Jun 4 18:14:43 2015
@@ -0,0 +1 @@
+ELFLþ'ELFB
\ 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=239116&r1=239115&r2=239116&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/dwarfdump-invalid.test (original)
+++ llvm/trunk/test/DebugInfo/dwarfdump-invalid.test Thu Jun 4 18:14:43 2015
@@ -2,4 +2,5 @@
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
+RUN: llvm-dwarfdump %p/Inputs/invalid.elf.3 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