[llvm] cacf1b5 - [llvm-objdump] Demangle C++ Symbols in branch and call targets
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 18 08:31:13 PDT 2020
Author: Markus Böck
Date: 2020-04-18T08:30:50-07:00
New Revision: cacf1b5093279ae2aaa695d3eb5f0c116d0746ea
URL: https://github.com/llvm/llvm-project/commit/cacf1b5093279ae2aaa695d3eb5f0c116d0746ea
DIFF: https://github.com/llvm/llvm-project/commit/cacf1b5093279ae2aaa695d3eb5f0c116d0746ea.diff
LOG: [llvm-objdump] Demangle C++ Symbols in branch and call targets
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 GNUobjdump's
behavior
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D77957
Added:
Modified:
llvm/test/tools/llvm-objdump/X86/demangle.s
llvm/tools/llvm-objdump/llvm-objdump.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-objdump/X86/demangle.s b/llvm/test/tools/llvm-objdump/X86/demangle.s
index f6523f2e931b..c2caae865a5a 100644
--- a/llvm/test/tools/llvm-objdump/X86/demangle.s
+++ b/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
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index c264ea6461bc..0eeb337c1b7b 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1556,7 +1556,10 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
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)
More information about the llvm-commits
mailing list