mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
[Object, ELF] Don't assert on invalid magic in createELFObjectFile.
Instead, return a proper error code from factory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239116 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b0b8cde9d4
commit
196340cc6c
@ -39,14 +39,15 @@ ObjectFile::createELFObjectFile(MemoryBufferRef Obj) {
|
|||||||
R.reset(new ELFObjectFile<ELFType<support::big, false>>(Obj, EC));
|
R.reset(new ELFObjectFile<ELFType<support::big, false>>(Obj, EC));
|
||||||
else
|
else
|
||||||
return object_error::parse_failed;
|
return object_error::parse_failed;
|
||||||
} else {
|
} else if (Ident.first == ELF::ELFCLASS64) {
|
||||||
assert(Ident.first == ELF::ELFCLASS64);
|
|
||||||
if (Ident.second == ELF::ELFDATA2LSB)
|
if (Ident.second == ELF::ELFDATA2LSB)
|
||||||
R.reset(new ELFObjectFile<ELFType<support::little, true>>(Obj, EC));
|
R.reset(new ELFObjectFile<ELFType<support::little, true>>(Obj, EC));
|
||||||
else if (Ident.second == ELF::ELFDATA2MSB)
|
else if (Ident.second == ELF::ELFDATA2MSB)
|
||||||
R.reset(new ELFObjectFile<ELFType<support::big, true>>(Obj, EC));
|
R.reset(new ELFObjectFile<ELFType<support::big, true>>(Obj, EC));
|
||||||
else
|
else
|
||||||
return object_error::parse_failed;
|
return object_error::parse_failed;
|
||||||
|
} else {
|
||||||
|
return object_error::parse_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EC)
|
if (EC)
|
||||||
|
1
test/DebugInfo/Inputs/invalid.elf.3
Normal file
1
test/DebugInfo/Inputs/invalid.elf.3
Normal file
@ -0,0 +1 @@
|
|||||||
|
ELF‚Lþ'ELFB
|
@ -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>&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.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
|
INVALID-ELF: Invalid data was encountered while parsing the file
|
||||||
|
Loading…
Reference in New Issue
Block a user