Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Dec 2019 21:01:13 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r355403 - head/lib/libc/riscv/gen
Message-ID:  <201912042101.xB4L1DaV094906@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Dec  4 21:01:13 2019
New Revision: 355403
URL: https://svnweb.freebsd.org/changeset/base/355403

Log:
  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

Modified:
  head/lib/libc/riscv/gen/setjmp.S
  head/lib/libc/riscv/gen/sigsetjmp.S

Modified: head/lib/libc/riscv/gen/setjmp.S
==============================================================================
--- head/lib/libc/riscv/gen/setjmp.S	Wed Dec  4 20:50:49 2019	(r355402)
+++ head/lib/libc/riscv/gen/setjmp.S	Wed Dec  4 21:01:13 2019	(r355403)
@@ -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)

Modified: head/lib/libc/riscv/gen/sigsetjmp.S
==============================================================================
--- head/lib/libc/riscv/gen/sigsetjmp.S	Wed Dec  4 20:50:49 2019	(r355402)
+++ head/lib/libc/riscv/gen/sigsetjmp.S	Wed Dec  4 21:01:13 2019	(r355403)
@@ -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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912042101.xB4L1DaV094906>