aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorPierre van Houtryve <pierre.vanhoutryve@amd.com>2022-10-07 08:12:36 +0000
committerPierre van Houtryve <pierre.vanhoutryve@amd.com>2022-10-12 10:44:03 +0000
commit02b5d3bc3bb9108e8d18308395120f7e3161dbe8 (patch)
treebf71b707499604c55b448ee0f22b3033c95426fa /llvm/tools/llvm-objdump/llvm-objdump.cpp
parent1e723b7ab30360fcf70c3a66dadcc4d5bbb2ace9 (diff)
downloadllvm-02b5d3bc3bb9108e8d18308395120f7e3161dbe8.zip
llvm-02b5d3bc3bb9108e8d18308395120f7e3161dbe8.tar.gz
llvm-02b5d3bc3bb9108e8d18308395120f7e3161dbe8.tar.bz2
[llvm-objdump] Support nonzero section addresses in addSymbolizer
The previous calculations seem to have assumed that the section address would be zero. This is true for relocatable object files, but certainly not for linked files like shared libraries. Fixed the calculations to make them identical to the "real" `getInstruction` call below & added a regression test. Reviewed By: scott.linder, simon_tatham Differential Revision: https://reviews.llvm.org/D135430
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index f7d6666d..aa3c053 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1190,8 +1190,9 @@ static void addSymbolizer(
for (size_t Index = 0; Index != Bytes.size();) {
MCInst Inst;
uint64_t Size;
- ArrayRef<uint8_t> ThisBytes = Bytes.slice(Index - SectionAddr);
- DisAsm->getInstruction(Inst, Size, ThisBytes, Index, nulls());
+ ArrayRef<uint8_t> ThisBytes = Bytes.slice(Index);
+ const uint64_t ThisAddr = SectionAddr + Index;
+ DisAsm->getInstruction(Inst, Size, ThisBytes, ThisAddr, nulls());
if (Size == 0)
Size = std::min<uint64_t>(ThisBytes.size(),
DisAsm->suggestBytesToSkip(ThisBytes, Index));