about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/hppa/setcontext.S
diff options
context:
space:
mode:
authorJohn David Anglin <danglin@gcc.gnu.org>2022-02-22 17:28:46 +0000
committerJohn David Anglin <danglin@gcc.gnu.org>2022-02-22 17:28:46 +0000
commit9e7e5fda38471e00d1190479ea91d7b08ae3e304 (patch)
tree7a811ee404068f85a8bc877c029daaa1f04c0793 /sysdeps/unix/sysv/linux/hppa/setcontext.S
parentfdc1ae67fef27eea1445bab4bdfe2f0fb3bc7aa1 (diff)
downloadglibc-9e7e5fda38471e00d1190479ea91d7b08ae3e304.tar.gz
glibc-9e7e5fda38471e00d1190479ea91d7b08ae3e304.tar.xz
glibc-9e7e5fda38471e00d1190479ea91d7b08ae3e304.zip
hppa: Revise gettext trampoline design
The current getcontext return trampoline is overly complex and it
unnecessarily clobbers several registers.  By saving the context
pointer (r26) in the context, __getcontext_ret can restore any
registers not restored by setcontext.  This allows getcontext to
save and restore the entire register context present when getcontext
is entered.  We use the unused oR0 context slot for the return
from __getcontext_ret.

While this is not directly useful in C, it can be exploited in
assembly code.  Registers r20, r23, r24 and r25 are not clobbered
in the call path to getcontext.  This allows a small simplification
of swapcontext.

It also allows saving and restoring the 6-bit SAR register in the
LSB of the oSAR context slot.  The getcontext flag value can be
stored in the MSB of the oSAR slot.
Diffstat (limited to 'sysdeps/unix/sysv/linux/hppa/setcontext.S')
-rw-r--r--sysdeps/unix/sysv/linux/hppa/setcontext.S6
1 files changed, 5 insertions, 1 deletions
diff --git a/sysdeps/unix/sysv/linux/hppa/setcontext.S b/sysdeps/unix/sysv/linux/hppa/setcontext.S
index 5da01c2f35..dfa794ad5c 100644
--- a/sysdeps/unix/sysv/linux/hppa/setcontext.S
+++ b/sysdeps/unix/sysv/linux/hppa/setcontext.S
@@ -75,7 +75,7 @@ ENTRY(__setcontext)
 	ldw	oR18(%r3), %r18
 	ldw	oR19(%r3), %r19
 	ldw	oR20(%r3), %r20
-	ldw	oR21(%r3), %r21
+	ldw	oR21(%r3), %r21 /* maybe clobbered by dyncall */
 	/* ldw	oR22(%r3), %r22 - dyncall arg.  */
 	ldw	oR23(%r3), %r23
 	ldw	oR24(%r3), %r24
@@ -87,6 +87,10 @@ ENTRY(__setcontext)
 	ldw	oR30(%r3), %sp
 	/* ldw	oR31(%r3), %r31 - dyncall scratch register */
 
+	/* Restore SAR register.  */
+	ldw	oSAR(%r3), %r22
+	mtsar	%r22
+
 	/* Restore floating-point registers.  */
 	ldo	 oFPREGS31(%r3), %r22
 	fldds	  0(%r22), %fr31