forked from OSchip/llvm-project
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 llvm-svn: 313921
This commit is contained in:
parent
d51d38f6f9
commit
f310e62b77
Binary file not shown.
|
@ -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
|
|
@ -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<const MCInstrInfo> InstrInfo(TheTarget->createMCInstrInfo());
|
||||
std::unique_ptr<const MCInstrInfo> ThumbInstrInfo;
|
||||
|
@ -6462,7 +6465,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
|
|||
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 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();
|
||||
|
|
Loading…
Reference in New Issue