From 68389203832ab39dd0dbaabbc4059e7fff51c29b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 28 Oct 2021 11:39:49 -0700 Subject: 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 Reviewed-by: Adhemerval Zanella --- sysdeps/unix/sysv/linux/riscv/setcontext.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sysdeps/unix/sysv/linux/riscv') diff --git a/sysdeps/unix/sysv/linux/riscv/setcontext.S b/sysdeps/unix/sysv/linux/riscv/setcontext.S index 9510518750..e44a68aad4 100644 --- a/sysdeps/unix/sysv/linux/riscv/setcontext.S +++ b/sysdeps/unix/sysv/linux/riscv/setcontext.S @@ -95,6 +95,7 @@ LEAF (__setcontext) 99: j __syscall_error END (__setcontext) +libc_hidden_def (__setcontext) weak_alias (__setcontext, setcontext) LEAF (__start_context) @@ -108,7 +109,7 @@ LEAF (__start_context) /* Invoke subsequent context if present, else exit(0). */ mv a0, s2 beqz s2, 1f - jal __setcontext -1: j exit + jal HIDDEN_JUMPTARGET (__setcontext) +1: j HIDDEN_JUMPTARGET (exit) END (__start_context) -- cgit 1.4.1