[PATCH] D56726: Include section start address when dumping hexadecimal output of a section, -x option.q

Sid Manning via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 15 08:09:58 PST 2019


sidneym created this revision.
sidneym added reviewers: jhenderson, rupprecht, LukeCheeseman.

llvm-readobj discards the starting address of a section, starting at zero instead:
Hex dump of section '.text':
0x00000000 31ed4989 d15e4889 e24883e4 f0505449 1.I..^H..H...PTI

To match gnu it should start at the section address (0x00400460), like this:
Hex dump of section '.text':
0x00400460 31ed4989 d15e4889 e24883e4 f0505449 1.I..^H..H...PTI


Repository:
  rL LLVM

https://reviews.llvm.org/D56726

Files:
  test/tools/llvm-readobj/hexdump.test
  tools/llvm-readobj/ObjDumper.cpp


Index: tools/llvm-readobj/ObjDumper.cpp
===================================================================
--- tools/llvm-readobj/ObjDumper.cpp
+++ tools/llvm-readobj/ObjDumper.cpp
@@ -117,7 +117,8 @@
     uint8_t i;
     uint8_t k;
 
-    W.startLine() << format_hex(SecPtr - SecContent, 10);
+    W.startLine() << format_hex(Section.getAddress() + (SecPtr - SecContent),
+                                10);
     W.startLine() << ' ';
     for (i = 0; TmpSecPtr < SecEnd && i < 4; ++i) {
       for (k = 0; TmpSecPtr < SecEnd && k < 4; k++, TmpSecPtr++) {
Index: test/tools/llvm-readobj/hexdump.test
===================================================================
--- /dev/null
+++ test/tools/llvm-readobj/hexdump.test
@@ -0,0 +1,6 @@
+// Check dumping of the hexadecimal bytes of a section
+RUN: llvm-readobj -x .text %p/../../Object/Inputs/hello-world.elf-x86-64 | FileCheck %s
+
+CHECK: Hex dump of section '.text':
+CHECK-NEXT: 0x00400460
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56726.181791.patch
Type: text/x-patch
Size: 953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190115/1adf2813/attachment.bin>


More information about the llvm-commits mailing list