[PATCH] D74507: [llvm-objdump] Print method name from debug info in disassembly output.
Jordan Rupprecht via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 10:44:30 PST 2020
rupprecht added a comment.
Sure, here's an example you can play around with:
$ echo 'extern "C" int foo() { return 5; }; namespace xyz { int bar() { return 10; } }' > /tmp/src.cc; clang++ -g -c /tmp/src.cc -o /tmp/obj.o
$ objdump -ldC /tmp/obj.o # GNU objdump
...
Disassembly of section .text:
0000000000000000 <foo>:
foo():
/tmp/src.cc:1
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: b8 05 00 00 00 mov $0x5,%eax
9: 5d pop %rbp
a: c3 retq
b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
0000000000000010 <xyz::bar()>:
_ZN3xyz3barEv(): # <-- Note, see https://sourceware.org/ml/binutils/2020-02/msg00369.html to demangle this too
/tmp/src.cc:1
10: 55 push %rbp
11: 48 89 e5 mov %rsp,%rbp
14: b8 0a 00 00 00 mov $0xa,%eax
19: 5d pop %rbp
1a: c3 retq
$ llvm-objdump -ldC /tmp/obj.o # llvm-objdump, w/o this patch
...
0000000000000000 foo:
; /tmp/src.cc:1
0: 55 pushq %rbp
1: 48 89 e5 movq %rsp, %rbp
4: b8 05 00 00 00 movl $5, %eax
9: 5d popq %rbp
a: c3 retq
b: 0f 1f 44 00 00 nopl (%rax,%rax)
0000000000000010 xyz::bar():
10: 55 pushq %rbp
11: 48 89 e5 movq %rsp, %rbp
14: b8 0a 00 00 00 movl $10, %eax
19: 5d popq %rbp
1a: c3 retq
$ llvm-objdump -ldC /tmp/obj.o # llvm-objdump, w/ this patch
...
0000000000000000 foo:
; foo(): # <-- this is new
; /tmp/src.cc:1
0: 55 pushq %rbp
1: 48 89 e5 movq %rsp, %rbp
4: b8 05 00 00 00 movl $5, %eax
9: 5d popq %rbp
a: c3 retq
; /tmp/src.cc:1 # <-- just noticed this unexpected diff, I'll see what's going on here....
b: 0f 1f 44 00 00 nopl (%rax,%rax)
0000000000000010 xyz::bar():
; _ZN3xyz3barEv(): # <-- this is new
; /tmp/src.cc:1 # <-- this is new and correct (although wasn't the intention of this patch to fix)
10: 55 pushq %rbp
11: 48 89 e5 movq %rsp, %rbp
14: b8 0a 00 00 00 movl $10, %eax
19: 5d popq %rbp
1a: c3 retq
http://llvm.org/PR41341 also has some examples. It seems superfluous with the trivial examples, but helps in situations where the object file has debugging information but no (or limited) symbols.
Note this patch doesn't address the syntactic difference of the leading `;` delimiter, which is still a difference between llvm-objdump and GNU objdump.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74507/new/
https://reviews.llvm.org/D74507
More information about the llvm-commits
mailing list