mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-26 07:34:06 +00:00
When encountering an unknown file format, ObjectFile::createObjectFile should
politely report it instead of running into llvm_unreachable. Also patch llvm-dwarfdump to actually check whether the file it's attempting to dump is a valid object file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173489 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a506b00d14
commit
a965baca3c
@ -33,6 +33,8 @@ ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) {
|
||||
sys::LLVMFileType type = sys::IdentifyFileType(Object->getBufferStart(),
|
||||
static_cast<unsigned>(Object->getBufferSize()));
|
||||
switch (type) {
|
||||
case sys::Unknown_FileType:
|
||||
return 0;
|
||||
case sys::ELF_Relocatable_FileType:
|
||||
case sys::ELF_Executable_FileType:
|
||||
case sys::ELF_SharedObject_FileType:
|
||||
@ -52,7 +54,7 @@ ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) {
|
||||
case sys::COFF_FileType:
|
||||
return createCOFFObjectFile(Object);
|
||||
default:
|
||||
llvm_unreachable("Unknown Object File Type");
|
||||
llvm_unreachable("Unexpected Object File Type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,11 @@ static void DumpInput(const StringRef &Filename) {
|
||||
}
|
||||
|
||||
OwningPtr<ObjectFile> Obj(ObjectFile::createObjectFile(Buff.take()));
|
||||
if (!Obj) {
|
||||
errs() << Filename << ": Unknown object file format\n";
|
||||
return;
|
||||
}
|
||||
|
||||
OwningPtr<DIContext> DICtx(DIContext::getDWARFContext(Obj.get()));
|
||||
|
||||
if (Address == -1ULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user