diff --git a/llvm/test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64 b/llvm/test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64 new file mode 100644 index 000000000000..5a61a78247a3 Binary files /dev/null and b/llvm/test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64 differ diff --git a/llvm/test/tools/llvm-objdump/AArch64/macho-fat-arm-disasm.test b/llvm/test/tools/llvm-objdump/AArch64/macho-fat-arm-disasm.test new file mode 100644 index 000000000000..69ff25436b6b --- /dev/null +++ b/llvm/test/tools/llvm-objdump/AArch64/macho-fat-arm-disasm.test @@ -0,0 +1,6 @@ +RUN: llvm-objdump -d -m -no-show-raw-insn -arch all %p/Inputs/fat.macho-armv7s-arm64 | FileCheck %s + +CHECK: (architecture armv7s): +CHECK: bx r12 +CHECK: (architecture arm64): +CHECK: fmul d16, d0, d2 diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index e1e42c2e218b..006ba5765e79 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -6439,8 +6439,11 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, // GetTarget prints out stuff. return; } + std::string MachOMCPU; if (MCPU.empty() && McpuDefault) - MCPU = McpuDefault; + MachOMCPU = McpuDefault; + else + MachOMCPU = MCPU; std::unique_ptr InstrInfo(TheTarget->createMCInstrInfo()); std::unique_ptr ThumbInstrInfo; @@ -6462,7 +6465,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, std::unique_ptr AsmInfo( TheTarget->createMCAsmInfo(*MRI, TripleName)); std::unique_ptr STI( - TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr)); + TheTarget->createMCSubtargetInfo(TripleName, MachOMCPU, FeaturesStr)); MCContext Ctx(AsmInfo.get(), MRI.get(), nullptr); std::unique_ptr DisAsm( TheTarget->createMCDisassembler(*STI, Ctx)); @@ -6512,7 +6515,8 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, ThumbAsmInfo.reset( ThumbTarget->createMCAsmInfo(*ThumbMRI, ThumbTripleName)); ThumbSTI.reset( - ThumbTarget->createMCSubtargetInfo(ThumbTripleName, MCPU, FeaturesStr)); + ThumbTarget->createMCSubtargetInfo(ThumbTripleName, MachOMCPU, + FeaturesStr)); ThumbCtx.reset(new MCContext(ThumbAsmInfo.get(), ThumbMRI.get(), nullptr)); ThumbDisAsm.reset(ThumbTarget->createMCDisassembler(*ThumbSTI, *ThumbCtx)); MCContext *PtrThumbCtx = ThumbCtx.get();