[PATCH] D63183: [ELF][RISCV] Treat R_RISCV_{ADD,SET,SUB}* as link-time constants

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 23:33:59 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: asb, jrtc27, PkmX, ruiu.
Herald added subscribers: llvm-commits, Jim, benna, psnobl, jocewei, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

R_RISCV_{ADD,SET,SUB}* are expected to be used as local label
computation. Add a new RelExpr R_RISCV_ADD to represent them.

R_RISCV_ADD is treated as a link-time constant because otherwise
R_RISCV_{ADD,SET,SUB}* are not allowed in a non-writable section in
-pie/-shared mode.

In glibc Scrt1.o, .rela.eh_frame contains such relocations. With D63076 <https://reviews.llvm.org/D63076>
and this patch, I can run -pie/-shared programs linked against glibc.

Note llvm-mc cannot currently produce R_RISCV_SET* so they are not
tested.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D63183

Files:
  ELF/Arch/RISCV.cpp
  ELF/InputSection.cpp
  ELF/Relocations.cpp
  ELF/Relocations.h
  test/ELF/riscv-reloc-add.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63183.204218.patch
Type: text/x-patch
Size: 3096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190612/fda74927/attachment.bin>


More information about the llvm-commits mailing list