[PATCH] D48702: objdump: Better handling of Mach-O universal binaries

Dave Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 27 21:14:06 PDT 2018


kastiglione created this revision.
kastiglione added a reviewer: compnerd.

With Mach-O, there is a flag requirement discrepancy between working with
universal binaries and thin binaries. Many flags that don't require the `-macho`
flag (for example `-private-headers` and `-disassemble`) fail to work on
universal binaries unless `-macho` is given. When this happens, the error
message is unhelpful, stating:

  The file was not recognized as a valid object file.

Which can lead to confusion.

This change allows generic flags to be used on universal binaries with and
without the `-macho` flag. This means flags that can be used for thin files can
be used consistently with fat files too.

To do this, the universal binary support within `ParseInputMachO()` is extracted
into a new function. This new function is called directly from `DumpInput()`
when the input binary is universal. Additionally the `-arch` flag validation in
`ParseInputMachO()` was extracted to be reused.


Repository:
  rL LLVM

https://reviews.llvm.org/D48702

Files:
  test/tools/llvm-objdump/X86/macho-private-headers.test
  test/tools/llvm-objdump/X86/macho-universal-x86_64.i386.test
  tools/llvm-objdump/MachODump.cpp
  tools/llvm-objdump/llvm-objdump.cpp
  tools/llvm-objdump/llvm-objdump.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48702.153253.patch
Type: text/x-patch
Size: 20582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180628/439a42f0/attachment.bin>


More information about the llvm-commits mailing list