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 ThumbMRI; std::unique_ptr 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 objdump::DisassemblerOptions; bool objdump::SymbolDescription; bool objdump::TracebackTable; static std::vector DisassembleSymbols; static bool DisassembleZeroes; -static std::vector 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 DisassemblerOptions; extern DIDumpType DwarfDumpType; extern std::vector FilterSections; extern bool LeadingAddr;