-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-objdump] Handle -M for --macho #113795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm-objdump] Handle -M for --macho #113795
Conversation
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-llvm-binary-utilities Author: Fangrui Song (MaskRay) Changes--macho -d uses the Close #61019 Full diff: https://github.com/llvm/llvm-project/pull/113795.diff 4 Files Affected:
diff --git a/llvm/test/tools/llvm-objdump/MachO/AArch64/aliases.s b/llvm/test/tools/llvm-objdump/MachO/AArch64/aliases.s
new file mode 100644
index 00000000000000..547f621654857f
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/MachO/AArch64/aliases.s
@@ -0,0 +1,11 @@
+# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t
+# RUN: llvm-objdump --macho -d -M no-aliases %t | FileCheck %s
+# RUN: llvm-objdump --macho -d --disassembler-options=no-aliases %t | FileCheck %s
+
+# CHECK: orr w1, wzr, w2
+
+# RUN: not llvm-objdump --macho -d -M unknown %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
+
+# ERR: error: '[[FILE]]': unrecognized disassembler option: unknown
+
+mov w1, w2
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index b8afb560d2ae9c..ab6f65cd41a365 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -7330,6 +7330,10 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
// comment causing different diffs with the 'C' disassembler library API.
// IP->setCommentStream(CommentStream);
+ for (StringRef Opt : DisassemblerOptions)
+ if (!IP->applyTargetSpecificCLOption(Opt))
+ reportError(Filename, "unrecognized disassembler option: " + Opt);
+
// Set up separate thumb disassembler if needed.
std::unique_ptr<const MCRegisterInfo> ThumbMRI;
std::unique_ptr<const MCAsmInfo> ThumbAsmInfo;
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 8073c898b8a147..86ba9193dff2d1 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -305,11 +305,11 @@ bool objdump::ArchiveHeaders;
bool objdump::Demangle;
bool objdump::Disassemble;
bool objdump::DisassembleAll;
+std::vector<std::string> objdump::DisassemblerOptions;
bool objdump::SymbolDescription;
bool objdump::TracebackTable;
static std::vector<std::string> DisassembleSymbols;
static bool DisassembleZeroes;
-static std::vector<std::string> DisassemblerOptions;
static ColorOutput DisassemblyColor;
DIDumpType objdump::DwarfDumpType;
static bool DynamicRelocations;
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.h b/llvm/tools/llvm-objdump/llvm-objdump.h
index 7778cf6c2784eb..debaedd33429d0 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.h
+++ b/llvm/tools/llvm-objdump/llvm-objdump.h
@@ -50,6 +50,7 @@ extern DebugVarsFormat DbgVariables;
extern bool Demangle;
extern bool Disassemble;
extern bool DisassembleAll;
+extern std::vector<std::string> DisassemblerOptions;
extern DIDumpType DwarfDumpType;
extern std::vector<std::string> FilterSections;
extern bool LeadingAddr;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, on the assumption that the -M
option has an impact on the output displayed in the test (so we'd know if it wasn't doing anything in the future).
# RUN: llvm-objdump --macho -d -M no-aliases %t | FileCheck %s | ||
# RUN: llvm-objdump --macho -d --disassembler-options=no-aliases %t | FileCheck %s | ||
|
||
# CHECK: orr w1, wzr, w2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the output of this check without the -M
option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test without -M.
Created using spr 1.3.5-bogner
--macho -d uses the `parseInputMachO` code path, which does not handle -M. Add -M handling for --macho as well. Close llvm#61019 Pull Request: llvm#113795
--macho -d uses the
parseInputMachO
code path, which does not handle-M. Add -M handling for --macho as well.
Close #61019