[PATCH] D57939: Refactor RelocVisitor and fix computation of SHT_RELA-typed relocation entries

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 8 00:02:34 PST 2019


MaskRay created this revision.
MaskRay added reviewers: echristo, dblaikie.
Herald added subscribers: llvm-commits, fedor.sergeev, aheejin, aprantl, mgorny.
Herald added a project: LLVM.

getRelocatedValue may compute incorrect value for SHT_RELA-typed relocation entries.

// DWARFDataExtractor.cpp
uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint32_t *Off,
...

  // This formula is correct for SHT_REL-typed relocation entries.
  // But for SHT_RELA-typed, if the implicit r_addend (getUnsigned(Off, Size)) is not zero, it will be incorrect.
  return getUnsigned(Off, Size) + Rel->Value;

In this patch, we refactor these visit* functions to include a new
parameter `int64_t A` (implicit r_addend). They should use either the
explicit r_addend (SHT_RELA: getELFAddend(R)) or the implicit r_addend

  (SHT_REL: A) according to processor supplement requirements.

Since these visit* functions are no longer used as a prescan manner but
will be called on-demand in getRelocatedValue, rename them to resolve*.


Repository:
  rL LLVM

https://reviews.llvm.org/D57939

Files:
  include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
  include/llvm/Object/RelocVisitor.h
  include/llvm/Object/RelocationResolver.h
  lib/DebugInfo/DWARF/DWARFContext.cpp
  lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
  lib/Object/CMakeLists.txt
  lib/Object/RelocationResolver.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57939.185915.patch
Type: text/x-patch
Size: 24973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190208/528066d8/attachment.bin>


More information about the llvm-commits mailing list