[llvm] r350726 - [llvm-objdump] - Print symbol addressed when dumping disassembly output (-d)
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 9 06:43:33 PST 2019
Author: grimar
Date: Wed Jan 9 06:43:33 2019
New Revision: 350726
URL: http://llvm.org/viewvc/llvm-project?rev=350726&view=rev
Log:
[llvm-objdump] - Print symbol addressed when dumping disassembly output (-d)
When GNU objdump dumps the input with -d it prints the symbol addresses,
for example:
0000000000000031 <foo>:
31: 00 00 add %al,(%rax)
...
llvm-objdump currently does not do that.
Patch changes the behavior to match the GNU objdump.
That is useful for implementing -z/--disassemble-zeroes (D56083),
it allows omitting first zero bytes and keep the information
about the symbol address in the output.
Differential revision: https://reviews.llvm.org/D56123
Added:
llvm/trunk/test/tools/llvm-objdump/X86/print-symbol-addr.s
Modified:
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Added: llvm/trunk/test/tools/llvm-objdump/X86/print-symbol-addr.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/X86/print-symbol-addr.s?rev=350726&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/X86/print-symbol-addr.s (added)
+++ llvm/trunk/test/tools/llvm-objdump/X86/print-symbol-addr.s Wed Jan 9 06:43:33 2019
@@ -0,0 +1,29 @@
+// RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t.o
+
+// Check we print the address of `foo` and `bar`.
+// RUN: llvm-objdump -d %t.o | FileCheck %s
+// CHECK: Disassembly of section .text:
+// CHECK-NEXT: 0000000000000000 foo:
+// CHECK-NEXT: 0: {{.*}} nop
+// CHECK-NEXT: 1: {{.*}} nop
+// CHECK: 0000000000000002 bar:
+// CHECK-NEXT: 2: {{.*}} nop
+
+// Check we do not print the addresses with -no-leading-addr.
+// RUN: llvm-objdump -d -no-leading-addr %t.o | FileCheck %s --check-prefix=NOADDR
+// NOADDR: Disassembly of section .text:
+// NOADDR-NEXT: {{^}}foo:
+// NOADDR-NEXT: {{.*}} nop
+// NOADDR-NEXT: {{.*}} nop
+// NOADDR: {{^}}bar:
+// NOADDR-NEXT: {{.*}} nop
+
+.text
+.globl foo
+.type foo, @function
+foo:
+ nop
+ nop
+
+bar:
+ nop
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=350726&r1=350725&r2=350726&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Wed Jan 9 06:43:33 2019
@@ -1592,6 +1592,9 @@ static void DisassembleObject(const Obje
}
outs() << '\n';
+ if (!NoLeadingAddr)
+ outs() << format("%016" PRIx64 " ", SectionAddr + Start);
+
StringRef SymbolName = std::get<1>(Symbols[si]);
if (Demangle)
outs() << demangle(SymbolName) << ":\n";
More information about the llvm-commits
mailing list