[PATCH] D77957: [llvm-objdump] Demangle C++ Symbols in branch and call targets

Markus Böck via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 11 17:36:37 PDT 2020


zero9178 created this revision.
zero9178 added reviewers: jhenderson, grimar, MaskRay.
Herald added subscribers: llvm-commits, rupprecht.
Herald added a project: LLVM.

Currently C++ symbols are demangled in the symbol table as well as in the disassembly and relocations. This patch adds demangling of C++ symbols in targets of calls and branches making it easier to decipher control flow in disassembly. This also matches up with objdump's behavior


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77957

Files:
  llvm/test/tools/llvm-objdump/X86/demangle.s
  llvm/tools/llvm-objdump/llvm-objdump.cpp


Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1561,7 +1561,10 @@
             if (TargetSym != TargetSectionSymbols->begin()) {
               --TargetSym;
               uint64_t TargetAddress = TargetSym->Addr;
-              StringRef TargetName = TargetSym->Name;
+              std::string TargetName = TargetSym->Name.str();
+              if (Demangle)
+                TargetName = demangle(TargetName);
+
               outs() << " <" << TargetName;
               uint64_t Disp = Target - TargetAddress;
               if (Disp)
Index: llvm/test/tools/llvm-objdump/X86/demangle.s
===================================================================
--- llvm/test/tools/llvm-objdump/X86/demangle.s
+++ llvm/test/tools/llvm-objdump/X86/demangle.s
@@ -11,7 +11,7 @@
 ## Check the case when relocations are inlined into disassembly.
 # RUN: llvm-objdump -d -r --demangle %t | FileCheck %s --check-prefix=INLINE
 # INLINE:      <foo()>:
-# INLINE-NEXT:  0: {{.*}}  callq   0x5 <_Z3foov+0x5>
+# INLINE-NEXT:  0: {{.*}}  callq   0x5 <foo()+0x5>
 # INLINE-NEXT:  0000000000000001:  R_X86_64_PLT32 foo()-0x4
 
 .text


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77957.256807.patch
Type: text/x-patch
Size: 1281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200412/fab19423/attachment.bin>


More information about the llvm-commits mailing list