diff options
author | Fangrui Song <i@maskray.me> | 2023-12-18 09:53:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-18 09:53:44 -0800 |
commit | 644e6d7d8be29b170d3fabe8e388ae5478b4adcf (patch) | |
tree | 09288a9780d19fe98c55be73419b794fed2f8e49 /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | 96aca7c51701f9b3c5dd8567fcddf29492008e6d (diff) | |
download | llvm-644e6d7d8be29b170d3fabe8e388ae5478b4adcf.zip llvm-644e6d7d8be29b170d3fabe8e388ae5478b4adcf.tar.gz llvm-644e6d7d8be29b170d3fabe8e388ae5478b4adcf.tar.bz2 |
[llvm-objdump] --disassemble-symbols: skip inline relocs from symbols that are not dumped (#75724)
When a section contains two functions x1 and x2, we incorrectly display
x1's relocations when dumping x2 for `--disassemble-symbols=x2 -r`.
Fix #75539 by ignoring these relocations.
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 12bb70d..1cdd84b 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1948,6 +1948,13 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj, continue; } + // Skip relocations from symbols that are not dumped. + for (; RelCur != RelEnd; ++RelCur) { + uint64_t Offset = RelCur->getOffset() - RelAdjustment; + if (Index <= Offset) + break; + } + bool DumpARMELFData = false; bool DumpTracebackTableForXCOFFFunction = Obj.isXCOFF() && Section.isText() && TracebackTable && @@ -2214,7 +2221,7 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj, while (RelCur != RelEnd) { uint64_t Offset = RelCur->getOffset() - RelAdjustment; // If this relocation is hidden, skip it. - if (getHidden(*RelCur) || SectionAddr + Offset < StartAddress) { + if (getHidden(*RelCur)) { ++RelCur; continue; } |