<div dir="ltr">Nice!<div><br></div><div>But I thought that an MCSymbolizer would automatically get us this too? (along with symbolizing e.g. addresses of constants which the current commit won't do)</div><div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 7, 2015 at 3:06 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Tue Jul  7 17:06:59 2015<br>
New Revision: 241631<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D241631-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=SBvPi-8VNHHTbMVxOe8Hoj6zmdFyVbv3PxDb7XdiWOY&s=xxH_kVrEsOKA0HUmk0gq6OfLnlgYTvXwImPDBuig7yc&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=241631&view=rev</a><br>
Log:<br>
[llvm-objdump] Print the call target next to the instruction<br>
<br>
GNU binutils provides this behavior.  objdump -r doesn't really help<br>
when you aren't dealing with relocation object files.<br>
<br>
Modified:<br>
    llvm/trunk/test/MC/X86/AlignedBundling/nesting.s<br>
    llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp<br>
<br>
Modified: llvm/trunk/test/MC/X86/AlignedBundling/nesting.s<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_MC_X86_AlignedBundling_nesting.s-3Frev-3D241631-26r1-3D241630-26r2-3D241631-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=SBvPi-8VNHHTbMVxOe8Hoj6zmdFyVbv3PxDb7XdiWOY&s=FD64EX6xvLkIK15Mib2SjVJNmH_GhqMrGB6jZy2WBJs&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/AlignedBundling/nesting.s?rev=241631&r1=241630&r2=241631&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/MC/X86/AlignedBundling/nesting.s (original)<br>
+++ llvm/trunk/test/MC/X86/AlignedBundling/nesting.s Tue Jul  7 17:06:59 2015<br>
@@ -6,7 +6,7 @@<br>
 # Will be bundle-aligning to 16 byte boundaries<br>
   .bundle_align_mode 4<br>
   .text<br>
-# CHECK-LABEL: foo<br>
+# CHECK-LABEL: foo:<br>
 foo:<br>
 # Test that bundle alignment mode can be set more than once.<br>
   .bundle_align_mode 4<br>
@@ -19,11 +19,11 @@ foo:<br>
   callq bar<br>
   .bundle_unlock<br>
   .bundle_unlock<br>
-# CHECK:      10: callq<br>
-# CHECK-NEXT: 15: callq<br>
+# CHECK:      10: callq {{.*}} <bar><br>
+# CHECK-NEXT: 15: callq {{.*}} <bar><br>
<br>
   .p2align 4<br>
-# CHECK-LABEL: bar<br>
+# CHECK-LABEL: bar:<br>
 bar:<br>
   callq foo<br>
   callq foo<br>
@@ -35,10 +35,10 @@ bar:<br>
   callq bar<br>
   .bundle_unlock<br>
   .bundle_unlock<br>
-# CHECK:      36: callq<br>
-# CHECK-NEXT: 3b: callq<br>
+# CHECK:      36: callq {{.*}} <bar><br>
+# CHECK-NEXT: 3b: callq {{.*}} <bar><br>
<br>
-# CHECK-LABEL: baz<br>
+# CHECK-LABEL: baz:<br>
 baz:<br>
   callq foo<br>
   callq foo<br>
@@ -50,8 +50,8 @@ baz:<br>
   callq bar<br>
   .bundle_unlock<br>
   .bundle_unlock<br>
-# CHECK:      56: callq<br>
-# CHECK-NEXT: 5b: callq<br>
+# CHECK:      56: callq {{.*}} <bar><br>
+# CHECK-NEXT: 5b: callq {{.*}} <bar><br>
<br>
 # CHECK-LABEL: quux<br>
 quux:<br>
@@ -65,5 +65,5 @@ quux:<br>
   .bundle_unlock<br>
 # Check that the calls are bundled together when the second one is after the<br>
 # inner nest is closed.<br>
-# CHECK:      70: callq<br>
-# CHECK-NEXT: 75: callq<br>
+# CHECK:      70: callq {{.*}} <bar><br>
+# CHECK-NEXT: 75: callq {{.*}} <bar><br>
<br>
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_tools_llvm-2Dobjdump_llvm-2Dobjdump.cpp-3Frev-3D241631-26r1-3D241630-26r2-3D241631-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=SBvPi-8VNHHTbMVxOe8Hoj6zmdFyVbv3PxDb7XdiWOY&s=uHnthcengEXNtT5QkBJ9dhPCp2X3qXHtK-VYNSv-rTA&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=241631&r1=241630&r2=241631&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)<br>
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Tue Jul  7 17:06:59 2015<br>
@@ -808,6 +808,27 @@ static void DisassembleObject(const Obje<br>
       SectionRelocMap[*Sec2].push_back(Section);<br>
   }<br>
<br>
+  // Create a mapping from virtual address to symbol name.  This is used to<br>
+  // pretty print the target of a call.<br>
+  std::vector<std::pair<uint64_t, StringRef>> AllSymbols;<br>
+  if (MIA) {<br>
+    for (const SymbolRef &Symbol : Obj->symbols()) {<br>
+      ErrorOr<uint64_t> AddressOrErr = Symbol.getAddress();<br>
+      if (error(AddressOrErr.getError()))<br>
+        break;<br>
+      uint64_t Address = *AddressOrErr;<br>
+<br>
+      ErrorOr<StringRef> Name = Symbol.getName();<br>
+      if (error(Name.getError()))<br>
+        break;<br>
+      if (Name->empty())<br>
+        continue;<br>
+      AllSymbols.push_back(std::make_pair(Address, *Name));<br>
+    }<br>
+<br>
+    array_pod_sort(AllSymbols.begin(), AllSymbols.end());<br>
+  }<br>
+<br>
   for (const SectionRef &Section : Obj->sections()) {<br>
     if (!Section.isText() || Section.isVirtual())<br>
       continue;<br>
@@ -912,6 +933,21 @@ static void DisassembleObject(const Obje<br>
                         SectionAddr + Index, outs(), "", *STI);<br>
           outs() << CommentStream.str();<br>
           Comments.clear();<br>
+          if (MIA && (MIA->isCall(Inst) || MIA->isUnconditionalBranch(Inst))) {<br>
+            uint64_t Target;<br>
+            if (MIA->evaluateBranch(Inst, SectionAddr + Index, Size, Target)) {<br>
+              const auto &TargetSym =<br>
+                  std::lower_bound(AllSymbols.begin(), AllSymbols.end(),<br>
+                                   std::make_pair(Target, StringRef()));<br>
+              if (TargetSym != AllSymbols.end()) {<br>
+                outs() << " <" << TargetSym->second;<br>
+                uint64_t Disp = TargetSym->first - Target;<br>
+                if (Disp)<br>
+                  outs() << '-' << Disp;<br>
+                outs() << '>';<br>
+              }<br>
+            }<br>
+          }<br>
           outs() << "\n";<br>
         } else {<br>
           errs() << ToolName << ": warning: invalid instruction encoding\n";<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>