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 llvm#61019
  • Loading branch information
MaskRay committed Oct 27, 2024
1 parent 60d2fed commit 9408ced
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
11 changes: 11 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,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
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 9408ced

Please sign in to comment.