[llvm] r313921 - Fix a bug in llvm-objdump when disassembling using the wrong default CPU
Kevin Enderby via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 14:45:03 PDT 2017
Author: enderby
Date: Thu Sep 21 14:45:02 2017
New Revision: 313921
URL: http://llvm.org/viewvc/llvm-project?rev=313921&view=rev
Log:
Fix a bug in llvm-objdump when disassembling using the wrong default CPU
in the second slice of a Mach-O universal file.
The code in llvm-objdump in in DisassembleMachO() was getting the default
CPU then incorrectly setting into the global variable used for the -mcpu option
if that was not set. This caused a second call to DisassembleMachO() to use
the wrong default CPU when disassembling the next slice in a Mach-O universal
file. And would result in bad disassembly and an error message about an
recognized processor for the target:
% llvm-objdump -d -m -arch all fat.macho-armv7s-arm64
fat.macho-armv7s-arm64 (architecture armv7s):
(__TEXT,__text) section
armv7:
0: 60 47 bx r12
fat.macho-armv7s-arm64 (architecture arm64):
'cortex-a7' is not a recognized processor for this target (ignoring processor)
'cortex-a7' is not a recognized processor for this target (ignoring processor)
(__TEXT,__text) section
___multc3:
0: .long 0x1e620810
rdar://34439149
Added:
llvm/trunk/test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64 (with props)
llvm/trunk/test/tools/llvm-objdump/AArch64/macho-fat-arm-disasm.test
Modified:
llvm/trunk/tools/llvm-objdump/MachODump.cpp
Added: llvm/trunk/test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64?rev=313921&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: llvm/trunk/test/tools/llvm-objdump/AArch64/macho-fat-arm-disasm.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/AArch64/macho-fat-arm-disasm.test?rev=313921&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/AArch64/macho-fat-arm-disasm.test (added)
+++ llvm/trunk/test/tools/llvm-objdump/AArch64/macho-fat-arm-disasm.test Thu Sep 21 14:45:02 2017
@@ -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
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=313921&r1=313920&r2=313921&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Thu Sep 21 14:45:02 2017
@@ -6439,8 +6439,11 @@ static void DisassembleMachO(StringRef F
// GetTarget prints out stuff.
return;
}
+ std::string MachOMCPU;
if (MCPU.empty() && McpuDefault)
- MCPU = McpuDefault;
+ MachOMCPU = McpuDefault;
+ else
+ MachOMCPU = MCPU;
std::unique_ptr<const MCInstrInfo> InstrInfo(TheTarget->createMCInstrInfo());
std::unique_ptr<const MCInstrInfo> ThumbInstrInfo;
@@ -6462,7 +6465,7 @@ static void DisassembleMachO(StringRef F
std::unique_ptr<const MCAsmInfo> AsmInfo(
TheTarget->createMCAsmInfo(*MRI, TripleName));
std::unique_ptr<const MCSubtargetInfo> STI(
- TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr));
+ TheTarget->createMCSubtargetInfo(TripleName, MachOMCPU, FeaturesStr));
MCContext Ctx(AsmInfo.get(), MRI.get(), nullptr);
std::unique_ptr<MCDisassembler> DisAsm(
TheTarget->createMCDisassembler(*STI, Ctx));
@@ -6512,7 +6515,8 @@ static void DisassembleMachO(StringRef F
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();
More information about the llvm-commits
mailing list