HomePhabricator

[ELF][RISCV] Support PLT, GOT, copy and relative relocations

Authored by MaskRay on Jul 1 2019, 10:12 AM.

Description

[ELF][RISCV] Support PLT, GOT, copy and relative relocations

  • Handle initial relocation types: R_RISCV_CALL_PLT and R_RISCV_GOT_HI20.
  • Produce dynamic relocation types: R_RISCV_COPY, R_RISCV_RELATIVE, R_RISCV_JUMP_SLOT.
  • Define SymbolRel as R_RISCV_{32,64}
  • Generate PLT header: it is used by lazy binding PLT in glibc.
  • R_RISCV_CALL is changed from R_PC to R_PC_PLT. If the target symbol is preemptable, this will suppress an unnecessary "canonical PLT". This behavior is different from ld.bfd but it is agreed the current lld behavior is favored. I have received positive responses from the binutils maintainer that the ABI/binutils implementation can be improved, see: https://github.com/riscv/riscv-elf-psabi-doc/issues/98 https://sourceware.org/bugzilla/show_bug.cgi?id=24685

Many -no-pie/-pie/-shared programs linked against musl or glibc should work with this patch.

Reviewed By: jrtc27

Differential Revision: https://reviews.llvm.org/D63076

llvm-svn: 364812

Details

Committed
MaskRayJul 1 2019, 10:12 AM
Reviewer
jrtc27
Differential Revision
D63076: [ELF][RISCV] Support PLT, GOT, copy and relative relocations
Parents
rG1094e6a81430: AMDGPU/GlobalISel: RegBankSelect for DS ordered add/swap
Branches
Unknown
Tags
Unknown