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
diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 0687500..6041510 100644
--- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -86,6 +86,11 @@
}
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) {