]> granicus.if.org Git - llvm/commitdiff
Fix a bug in llvm-obdump(1) with the -macho flag disassembling an object
authorKevin Enderby <enderby@apple.com>
Tue, 31 Jan 2017 18:09:10 +0000 (18:09 +0000)
committerKevin Enderby <enderby@apple.com>
Tue, 31 Jan 2017 18:09:10 +0000 (18:09 +0000)
without symbols that makes calls through a symbol stub which were not
correctly being annotated with “## symbol stub for: _foo”.

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

test/tools/llvm-objdump/X86/Inputs/stub-nosyms.macho-x86_64 [new file with mode: 0644]
test/tools/llvm-objdump/X86/macho-stub-nosyms-disassembly.test [new file with mode: 0644]
tools/llvm-objdump/MachODump.cpp

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 (file)
index 0000000..a7f122b
Binary files /dev/null and b/test/tools/llvm-objdump/X86/Inputs/stub-nosyms.macho-x86_64 differ
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 (file)
index 0000000..af66b0e
--- /dev/null
@@ -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
index 80cbe4bc6575b735c25ebbbd1a7bde9947922ec9..b2e23f5032f7f9c12fea5925c2ca8f8ad4960fdd 100644 (file)
@@ -6798,8 +6798,10 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
         MCInst Inst;
 
         uint64_t PC = SectAddress + Index;
+        SmallVector<char, 64> 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();