[PATCH] D85618: [ELF] Move the outSecOff addend from relocAlloc/relocNonAlloc/... to InputSectionBase::relocate

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 9 12:32:59 PDT 2020


MaskRay created this revision.
MaskRay added reviewers: grimar, psmith.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
MaskRay requested review of this revision.

For an InputSection, the `buf` argument of `InputSectionBase::relocate` points
to the content of the containing OutputSection, instead of the content of the
InputSection itself, so `outSecOff` needs to be added in its callees.  This is
counter-intuitive and leads to many `- outSecOff` and `+ outSecOff`.

This patch makes `InputSection::writeTo` call `InputSectionBase::relocate` with
`outSecOff` added. relocAlloc/relocNonAlloc/relocateNonAllocForRelocatable can
thus be simplified now.

Updated tests:

- non-abs-reloc.s: A minor bug is fixed for a diagnostic in `relocateNonAlloc`
- x86-64-split-stack-prologue-adjust-success.s: Improved a bit to catch the failure if we fail to remove a `SectionBase::getOffset` call


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85618

Files:
  lld/ELF/AArch64ErrataFix.cpp
  lld/ELF/ARMErrataFix.cpp
  lld/ELF/InputSection.cpp
  lld/ELF/SyntheticSections.cpp
  lld/test/ELF/non-abs-reloc.s
  lld/test/ELF/x86-64-split-stack-prologue-adjust-success.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85618.284227.patch
Type: text/x-patch
Size: 7481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200809/4d95d0bd/attachment.bin>


More information about the llvm-commits mailing list