From 536a2983118dc36acb18e33a3866dd36ae0dc9e4 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Tue, 31 Jan 2017 18:09:10 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20a=20bug=20in=20llvm-obdump(1)=20with=20th?= =?UTF-8?q?e=20-macho=20flag=20disassembling=20an=20object=20without=20sym?= =?UTF-8?q?bols=20that=20makes=20calls=20through=20a=20symbol=20stub=20whi?= =?UTF-8?q?ch=20were=20not=20correctly=20being=20annotated=20with=20?= =?UTF-8?q?=E2=80=9C##=20symbol=20stub=20for:=20=5Ffoo=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just adds the same parameters for getting the annotations from DisAsm->getInstruction() and passing them to IP->printInst() from the code above when boolean variable symbolTableWorked was true. rdar://29791952 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293662 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../X86/Inputs/stub-nosyms.macho-x86_64 | Bin 0 -> 528 bytes .../X86/macho-stub-nosyms-disassembly.test | 3 +++ tools/llvm-objdump/MachODump.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 test/tools/llvm-objdump/X86/Inputs/stub-nosyms.macho-x86_64 create mode 100644 test/tools/llvm-objdump/X86/macho-stub-nosyms-disassembly.test diff --git a/test/tools/llvm-objdump/X86/Inputs/stub-nosyms.macho-x86_64 b/test/tools/llvm-objdump/X86/Inputs/stub-nosyms.macho-x86_64 new file mode 100644 index 0000000000000000000000000000000000000000..a7f122b55084e84e62c79c96f286c2b3c7b233b3 GIT binary patch literal 528 zcmX^A>+L^w1_nlE1|R{%AbJ6a0R@sk+5(9W6Nk~FP{skM8W$C$ z5(pc@4{?nMLGWQLkRA|#nRf$dF4$-mh6b<%l!%WnE-6hah6}~VqnZaZhYhOYIMjU) zpyqKv&4bCu#~0*h=9Q!t!OeGZ3~_`T&%g_1azN>`Q1f0u%>&s76#}bZ0+JFy`~xb_ z0Tck~v#%0BoWo0RR91 literal 0 HcmV?d00001 diff --git a/test/tools/llvm-objdump/X86/macho-stub-nosyms-disassembly.test b/test/tools/llvm-objdump/X86/macho-stub-nosyms-disassembly.test new file mode 100644 index 000000000000..af66b0e7a63f --- /dev/null +++ b/test/tools/llvm-objdump/X86/macho-stub-nosyms-disassembly.test @@ -0,0 +1,3 @@ +// RUN: llvm-objdump -d -m -no-show-raw-insn -full-leading-addr -print-imm-hex %p/Inputs/stub-nosyms.macho-x86_64 | FileCheck %s + +CHECK: 0000000000000001 callq 0x7 ## symbol stub for: _foo diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index 80cbe4bc6575..b2e23f5032f7 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -6798,8 +6798,10 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, MCInst Inst; uint64_t PC = SectAddress + Index; + SmallVector AnnotationsBytes; + raw_svector_ostream Annotations(AnnotationsBytes); if (DisAsm->getInstruction(Inst, InstSize, Bytes.slice(Index), PC, - DebugOut, nulls())) { + DebugOut, Annotations)) { if (!NoLeadingAddr) { if (FullLeadingAddr) { if (MachOOF->is64Bit()) @@ -6814,7 +6816,8 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, outs() << "\t"; dumpBytes(makeArrayRef(Bytes.data() + Index, InstSize), outs()); } - IP->printInst(&Inst, outs(), "", *STI); + StringRef AnnotationsStr = Annotations.str(); + IP->printInst(&Inst, outs(), AnnotationsStr, *STI); outs() << "\n"; } else { unsigned int Arch = MachOOF->getArch();