diff --git a/lib/Object/ObjectFile.cpp b/lib/Object/ObjectFile.cpp index b14df9af64f..860c87be984 100644 --- a/lib/Object/ObjectFile.cpp +++ b/lib/Object/ObjectFile.cpp @@ -33,6 +33,8 @@ ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) { sys::LLVMFileType type = sys::IdentifyFileType(Object->getBufferStart(), static_cast(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"); } } diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 06875005837..6041510e039 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -86,6 +86,11 @@ static void DumpInput(const StringRef &Filename) { } OwningPtr Obj(ObjectFile::createObjectFile(Buff.take())); + if (!Obj) { + errs() << Filename << ": Unknown object file format\n"; + return; + } + OwningPtr DICtx(DIContext::getDWARFContext(Obj.get())); if (Address == -1ULL) {