diff --git a/test/tools/llvm-readobj/hexdump.test b/test/tools/llvm-readobj/hexdump.test new file mode 100644 index 00000000000..cadb7225596 --- /dev/null +++ b/test/tools/llvm-readobj/hexdump.test @@ -0,0 +1,5 @@ +// 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 diff --git a/tools/llvm-readobj/ObjDumper.cpp b/tools/llvm-readobj/ObjDumper.cpp index a725140c9d3..81c9a2b9c4e 100644 --- a/tools/llvm-readobj/ObjDumper.cpp +++ b/tools/llvm-readobj/ObjDumper.cpp @@ -117,7 +117,8 @@ void ObjDumper::printSectionAsHex(const object::ObjectFile *Obj, 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++) {