[JITLink][RISCV] Only generate PLT entries for external symbols
authorJob Noorman <jnoorman@igalia.com>
Mon, 8 May 2023 08:05:46 +0000 (10:05 +0200)
committerJob Noorman <jnoorman@igalia.com>
Mon, 8 May 2023 08:31:33 +0000 (10:31 +0200)
commit26ee8947702d79ce2cab8e577f713685a5ca4a55
treebb78f040cb031fa52a3684a22a97423505d23c17
parent7c5cbe906e6b3c4da60ea898ddbb3a64b94a58cd
[JITLink][RISCV] Only generate PLT entries for external symbols

R_RISCV_CALL has been deprecated. [1] Both GCC and LLVM seem to not
generate it anymore and always use R_RISCV_CALL_PLT (even for calls that
do not need a PLT entry). Generating PLT entries based on relocation
type is not recommended and a better heuristic is to only generate them
when the target symbol is preemptable [2]. This patch implements this by
only generating PLT entries for undefined symbols.

[1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/340
[2] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/98

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D149525
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
llvm/test/ExecutionEngine/JITLink/RISCV/ELF_pc_indirect.s