Use "far" calls and branches so that lld uses valid relocations.

Conditional branch and jump instructions do not always call via PLT
stubs and thus will not honor LD_PRELOAD, etc.  lld warns about using
non-preemptible relocations for preemptible or unknown symbols whereas
bfd does not (at least for RISC-V).

Reviewed by:	br, James Clarke
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D22658
This commit is contained in:
John Baldwin 2019-12-04 21:01:13 +00:00
parent c0acb84da7
commit 18cf0a022e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=355403
2 changed files with 10 additions and 6 deletions

View File

@ -46,7 +46,7 @@ ENTRY(setjmp)
addi a2, a0, (_JB_SIGMASK * 8) /* oset */
li a1, 0 /* set */
li a0, 1 /* SIG_BLOCK */
jal sigprocmask
call _C_LABEL(sigprocmask)
ld a0, 0(sp)
ld ra, 8(sp)
@ -109,7 +109,7 @@ ENTRY(longjmp)
li a2, 0 /* oset */
addi a1, a0, (_JB_SIGMASK * 8) /* set */
li a0, 3 /* SIG_BLOCK */
jal sigprocmask
call _C_LABEL(sigprocmask)
ld a1, (2 * 8)(sp)
ld ra, (1 * 8)(sp)

View File

@ -38,8 +38,10 @@ __FBSDID("$FreeBSD$");
#include <machine/setjmp.h>
ENTRY(sigsetjmp)
beqz a1, _C_LABEL(_setjmp)
j _C_LABEL(setjmp)
beqz a1, 1f
tail _C_LABEL(setjmp)
1:
tail _C_LABEL(_setjmp)
END(sigsetjmp)
ENTRY(siglongjmp)
@ -48,8 +50,10 @@ ENTRY(siglongjmp)
ld a3, 0(a0)
/* Check the magic */
beq a2, a3, _C_LABEL(_longjmp)
j _C_LABEL(longjmp)
beq a2, a3, 1f
tail _C_LABEL(longjmp)
1:
tail _C_LABEL(_longjmp)
.align 3
.Lmagic: