aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorDave Lee <davelee.com@gmail.com>2018-08-03 00:06:38 +0000
committerDave Lee <davelee.com@gmail.com>2018-08-03 00:06:38 +0000
commit3fb120f12eb612b66208496b96b4735f43aac864 (patch)
treec83eb7491615e33b08cd9f7d1cf208e0477b86cd /llvm/tools/llvm-objdump/llvm-objdump.cpp
parent1ba5e9ac249fc425abe4f1be70d04960c0ce957a (diff)
downloadllvm-3fb120f12eb612b66208496b96b4735f43aac864.zip
llvm-3fb120f12eb612b66208496b96b4735f43aac864.tar.gz
llvm-3fb120f12eb612b66208496b96b4735f43aac864.tar.bz2
objdump: Better handling of Mach-O universal binaries
Summary: 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. Reviewers: compnerd Reviewed By: compnerd Subscribers: keith, llvm-commits Differential Revision: https://reviews.llvm.org/D48702 llvm-svn: 338792
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 8041e6f..543de22 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -42,6 +42,7 @@
#include "llvm/Object/COFFImportFile.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/MachO.h"
+#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/Wasm.h"
#include "llvm/Support/Casting.h"
@@ -2363,6 +2364,8 @@ static void DumpInput(StringRef file) {
DumpArchive(a);
else if (ObjectFile *o = dyn_cast<ObjectFile>(&Binary))
DumpObject(o);
+ else if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(&Binary))
+ ParseInputMachO(UB);
else
report_error(file, object_error::invalid_file_type);
}