From 945e587a20d28cea941094fa1670c51061608896 Mon Sep 17 00:00:00 2001 From: Sid Manning Date: Wed, 16 Jan 2019 16:17:19 +0000 Subject: [PATCH] [llvm-readobj] Set correct offset when dumping hex section output. Differential Revision: https://reviews.llvm.org/D56369 llvm-svn: 351356 --- test/tools/llvm-readobj/hexdump.test | 5 +++++ tools/llvm-readobj/ObjDumper.cpp | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/tools/llvm-readobj/hexdump.test 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++) {