Skip to content

Commit 92412c1

Browse files
authored
[llvm-objdump] Handle -M for --macho
--macho -d uses the `parseInputMachO` code path, which does not handle -M. Add -M handling for --macho as well. Close #61019 Pull Request: #113795
1 parent ab5d3c9 commit 92412c1

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t
2+
# RUN: llvm-objdump --macho -d -M no-aliases %t | FileCheck %s
3+
# RUN: llvm-objdump --macho -d --disassembler-options=no-aliases %t | FileCheck %s
4+
5+
# CHECK: orr w1, wzr, w2
6+
7+
# RUN: llvm-objdump --macho -d %t | FileCheck %s --check-prefix=ALIAS
8+
9+
# ALIAS: mov w1, w2
10+
11+
# RUN: not llvm-objdump --macho -d -M unknown %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=ERR
12+
13+
# ERR: error: '[[FILE]]': unrecognized disassembler option: unknown
14+
15+
mov w1, w2

llvm/tools/llvm-objdump/MachODump.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7330,6 +7330,10 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
73307330
// comment causing different diffs with the 'C' disassembler library API.
73317331
// IP->setCommentStream(CommentStream);
73327332

7333+
for (StringRef Opt : DisassemblerOptions)
7334+
if (!IP->applyTargetSpecificCLOption(Opt))
7335+
reportError(Filename, "unrecognized disassembler option: " + Opt);
7336+
73337337
// Set up separate thumb disassembler if needed.
73347338
std::unique_ptr<const MCRegisterInfo> ThumbMRI;
73357339
std::unique_ptr<const MCAsmInfo> ThumbAsmInfo;

llvm/tools/llvm-objdump/llvm-objdump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,11 @@ bool objdump::ArchiveHeaders;
305305
bool objdump::Demangle;
306306
bool objdump::Disassemble;
307307
bool objdump::DisassembleAll;
308+
std::vector<std::string> objdump::DisassemblerOptions;
308309
bool objdump::SymbolDescription;
309310
bool objdump::TracebackTable;
310311
static std::vector<std::string> DisassembleSymbols;
311312
static bool DisassembleZeroes;
312-
static std::vector<std::string> DisassemblerOptions;
313313
static ColorOutput DisassemblyColor;
314314
DIDumpType objdump::DwarfDumpType;
315315
static bool DynamicRelocations;

llvm/tools/llvm-objdump/llvm-objdump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ extern DebugVarsFormat DbgVariables;
5050
extern bool Demangle;
5151
extern bool Disassemble;
5252
extern bool DisassembleAll;
53+
extern std::vector<std::string> DisassemblerOptions;
5354
extern DIDumpType DwarfDumpType;
5455
extern std::vector<std::string> FilterSections;
5556
extern bool LeadingAddr;

0 commit comments

Comments
 (0)