[llvm] r293547 - Change the llvm-obdump(1) behavior with the -macho flag and inappropriate file types.
Kevin Enderby via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 12:53:18 PST 2017
Author: enderby
Date: Mon Jan 30 14:53:17 2017
New Revision: 293547
URL: http://llvm.org/viewvc/llvm-project?rev=293547&view=rev
Log:
Change the llvm-obdump(1) behavior with the -macho flag and inappropriate file types.
To better match the old darwin otool(1) behavior, when llvm-obdump(1) is used
with the -macho option and the input file is not an object file simply print
the file name and this message:
foo: is not an object file
and continue on to process other input files. Also in this case don’t exit
non-zero. This should help in some OSS projects' with autoconf scripts
that are expecting the old darwin otool(1) behavior.
rdar://26828015
Modified:
llvm/trunk/test/Object/macho-invalid.test
llvm/trunk/test/tools/llvm-objdump/malformed-macho.test
llvm/trunk/tools/llvm-objdump/MachODump.cpp
Modified: llvm/trunk/test/Object/macho-invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/macho-invalid.test?rev=293547&r1=293546&r2=293547&view=diff
==============================================================================
--- llvm/trunk/test/Object/macho-invalid.test (original)
+++ llvm/trunk/test/Object/macho-invalid.test Mon Jan 30 14:53:17 2017
@@ -83,8 +83,8 @@ RUN: not llvm-objdump -t %p/Inputs/macho
RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-objdump %s
INVALID-SECTION-IDX-SYMBOL-SEC-objdump: truncated or malformed object (bad section index: 66 for symbol at index 8)
-RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s
-INVALID-HEADER: The file was not recognized as a valid object file
+RUN: llvm-objdump -macho -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s
+INVALID-HEADER: is not an object file
RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s
INCOMPLETE-SEGMENT-LOADC: truncated or malformed object (load commands extend past the end of the file)
Modified: llvm/trunk/test/tools/llvm-objdump/malformed-macho.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/malformed-macho.test?rev=293547&r1=293546&r2=293547&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/malformed-macho.test (original)
+++ llvm/trunk/test/tools/llvm-objdump/malformed-macho.test Mon Jan 30 14:53:17 2017
@@ -1,2 +1,3 @@
-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
+RUN: llvm-objdump -macho -private-header %p/Inputs/malformed-macho.bin %p/Inputs/empty.macho-armv7 2>&1 | FileCheck %s -check-prefix=MALFORMED
+MALFORMED: is not an object file
+MALFORMED-NEXT: Mach header
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=293547&r1=293546&r2=293547&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Mon Jan 30 14:53:17 2017
@@ -1566,8 +1566,13 @@ void llvm::ParseInputMachO(StringRef Fil
// Attempt to open the binary.
Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(Filename);
- if (!BinaryOrErr)
- report_error(Filename, BinaryOrErr.takeError());
+ if (!BinaryOrErr) {
+ if (auto E = isNotObjectErrorInvalidFileType(BinaryOrErr.takeError()))
+ report_error(Filename, std::move(E));
+ else
+ outs() << Filename << ": is not an object file\n";
+ return;
+ }
Binary &Bin = *BinaryOrErr.get().getBinary();
if (Archive *A = dyn_cast<Archive>(&Bin)) {
More information about the llvm-commits
mailing list