[PATCH] D58020: [exposition-only] Refactor RelocVisitor and fix computation of SHT_RELA-typed relocation entries

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 10 17:27:19 PST 2019


MaskRay created this revision.
Herald added subscribers: llvm-commits, fedor.sergeev, aheejin, aprantl.
Herald added a project: LLVM.
MaskRay edited the summary of this revision.

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/D58020

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58020.186172.patch
Type: text/x-patch
Size: 19625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190211/1f8dc52e/attachment.bin>


More information about the llvm-commits mailing list