From 4d7a2deb50d5d338e9a6529107d223f1375d7e01 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Thu, 21 Sep 2017 21:45:02 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313921 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../AArch64/Inputs/fat.macho-armv7s-arm64 | Bin 0 -> 33112 bytes .../AArch64/macho-fat-arm-disasm.test | 6 ++++++ tools/llvm-objdump/MachODump.cpp | 10 +++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64 create mode 100644 test/tools/llvm-objdump/AArch64/macho-fat-arm-disasm.test diff --git a/test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64 b/test/tools/llvm-objdump/AArch64/Inputs/fat.macho-armv7s-arm64 new file mode 100644 index 0000000000000000000000000000000000000000..5a61a78247a36e817a1f7912243757c895a80fd3 GIT binary patch literal 33112 zcmeI)y)HyS6ae5^HX$LKEfh4O@Bk8pRzb9iEp+QAI-7_rQ7AlyXHj?n1uvoX0t#`? z-g~(u5)n~-lbks-$IjgN`Z@Qnw|AwKsfhWAxl%SGbrxglb*fq{ud}w7wFrX%0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&U_+x>Gm*>~|;eUzu{$)Diss2Xpuj=*Jlnn#&K<1e`^7lE0!}0Ou zxLQ~H!S>$ZW1p+${HJPn(r92(%D-n5f^J-z_x59&jT{XM%5FrCtY_qCa<%*UyuVYO z?RE0@7zbygi;Ze&CP07y0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0{ 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(); -- 2.50.0