Skip to content

Commit

Permalink
[llvm-objdump] Handle -M for --macho
Browse files Browse the repository at this point in the history
--macho -d uses the `parseInputMachO` code path, which does not handle
-M. Add -M handling for --macho as well.

Close #61019

Pull Request: #113795
  • Loading branch information
MaskRay authored Oct 28, 2024
1 parent ab5d3c9 commit 92412c1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions llvm/test/tools/llvm-objdump/MachO/AArch64/aliases.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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: llvm-objdump --macho -d %t | FileCheck %s --check-prefix=ALIAS

# ALIAS: mov w1, 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
4 changes: 4 additions & 0 deletions llvm/tools/llvm-objdump/MachODump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions llvm/tools/llvm-objdump/llvm-objdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 92412c1

Please sign in to comment.