[PATCH] D101450: [ELF] Check the Elf_Rel addends for dynamic relocations

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 28 06:38:10 PDT 2021


arichardson created this revision.
arichardson added reviewers: MaskRay, atanasyan, grimar, peter.smith.
Herald added subscribers: jrtc27, dang, luismarques, s.egerton, PkmX, simoncook, kristof.beyls, sdardis, emaste.
arichardson requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

There used to be many cases where addends for Elf_Rel were not emitted in
the final object file (mostly when building for MIPS64 since the input .o
files use RELA but the output uses REL). These cases have been fixed since,
but this patch adds a check to ensure that the written values are correct.
It is based on a previous patch that I added to the CHERI fork of LLD since
we were using MIPS64 as a baseline. The work has now almost entirely
shifted to RISC-V and Arm Morello (which use Elf_Rela), but I thought
it would be useful to upstream our local changes anyway.

This patch adds a (hidden) command line flag --check-dynamic-relocations
that can be used to enable these checks. It is also on by default in
assertions builds for targets that handle all dynamic relocations kinds
that LLD can emit in Target::getImplicitAddend(). Currently this is
enabled for ARM, MIPS, and I386.

Depends on D100490 <https://reviews.llvm.org/D100490>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101450

Files:
  lld/ELF/Arch/ARM.cpp
  lld/ELF/Arch/Mips.cpp
  lld/ELF/Arch/X86.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/OutputSections.cpp
  lld/ELF/OutputSections.h
  lld/ELF/SyntheticSections.h
  lld/ELF/Target.cpp
  lld/ELF/Writer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101450.341175.patch
Type: text/x-patch
Size: 11781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210428/40356a56/attachment.bin>


More information about the llvm-commits mailing list