riscv: Fix incorrect jal with HIDDEN_JUMPTARGET
authorFangrui Song <maskray@google.com>
Thu, 28 Oct 2021 18:39:49 +0000 (11:39 -0700)
committerFangrui Song <maskray@google.com>
Thu, 28 Oct 2021 18:39:49 +0000 (11:39 -0700)
commit68389203832ab39dd0dbaabbc4059e7fff51c29b
treef3c62c53064fd060566f1ed33688dc9c75323fe4
parent9b7cfab1802b71763da00982f772208544cf4a95
riscv: Fix incorrect jal with HIDDEN_JUMPTARGET

A non-local STV_DEFAULT defined symbol is by default preemptible in a
shared object. j/jal cannot target a preemptible symbol. On other
architectures, such a jump instruction either causes PLT [BZ #18822], or
if short-ranged, sometimes rejected by the linker (but not by GNU ld's
riscv port [ld PR/28509]).

Use HIDDEN_JUMPTARGET to target a non-preemptible symbol instead.

With this patch, ld.so and libc.so can be linked with LLD if source
files are compiled/assembled with -mno-relax/-Wa,-mno-relax.

Acked-by: Palmer Dabbelt <palmer@dabbelt.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
sysdeps/riscv/setjmp.S
sysdeps/unix/sysv/linux/riscv/setcontext.S