git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257561
91177308-0d34-0410-b5e6-
96231b3b80d8
// These test checks that llvm-objdump will not crash with malformed Archive
// files. So the check line is not all that important but the bug fixes to
// make sure llvm-objdump is robust is what matters.
-# RUN: llvm-objdump -macho -archive-headers \
+# RUN: not llvm-objdump -macho -archive-headers \
# RUN: %p/Inputs/libbogus1.a \
# RUN: 2>&1 | FileCheck -check-prefix=bogus1 %s
--- /dev/null
+RUN: not llvm-objdump -macho -s %p/Inputs/malformed-macho.bin 2>&1 | FileCheck %s -check-prefix=MALFORMED
+MALFORMED: '{{.*}}': The file was not recognized as a valid object file
// Attempt to open the binary.
ErrorOr<OwningBinary<Binary>> BinaryOrErr = createBinary(Filename);
- if (std::error_code EC = BinaryOrErr.getError()) {
- errs() << "llvm-objdump: '" << Filename << "': " << EC.message() << ".\n";
- return;
- }
+ if (std::error_code EC = BinaryOrErr.getError())
+ report_error(Filename, EC);
Binary &Bin = *BinaryOrErr.get().getBinary();
if (Archive *A = dyn_cast<Archive>(&Bin)) {