SH: makecontext/.Lexitcode: Always initialize the GOT register before use

Thomas Schwinge thomas@codesourcery.com
Thu Jun 14 10:20:00 GMT 2012


Hi!

This is only relevant when returning from a context with »uc_link ==
NULL«, which is not exercised in the testsuite.

I first though about simply removing the »exit (0)« from
stdlib/tst-makecontext.c:cf (which would then test exactly this case),
but apparently it is not specified which status value to use for exit in
this case -- libc.info: »If `uc_link' was a null pointer the application
terminates in this case.« -- so it is not trivial to test for.  (Maybe
worth specifying?  EXIT_SUCCESS (0)?)

I also renamed some labels to make them more handsome.

	* sysdeps/unix/sysv/linux/sh/makecontext.S (.Lexitcode): Always
	initialize the GOT register before use.

diff --git a/sysdeps/unix/sysv/linux/sh/makecontext.S b/sysdeps/unix/sysv/linux/sh/makecontext.S
index 6132cf9..70ea9f4 100644
--- a/sysdeps/unix/sysv/linux/sh/makecontext.S
+++ b/sysdeps/unix/sysv/linux/sh/makecontext.S
@@ -97,24 +97,28 @@ ENTRY(__makecontext)
 
 	.align	5
 .Lexitcode:
-	tst	r8, r8
-	bt/s	2f
-	 mov	r8, r4
 #ifdef PIC
 	mova	.Lgot, r0
 	mov.l	.Lgot, r12
 	add	r0, r12
-	mov.l	.L3, r1
+#endif
+	tst	r8, r8
+	bt/s	2f
+	 mov	r8, r4
+	mov.l	.Lsetcontext, r1
+#ifdef PIC
 	bsrf	r1
 .LPCS0:
 	 nop
 #else
-	mov.l	.L3, r1
 	jsr	@r1
 	 nop
 #endif
+	/* If this returns (which can happen if the syscall fails) we'll exit
+	   the program with the return error value (-1).  */
+
 2:
-	mov.l	.L4, r1
+	mov.l	.Lexit, r1
 #ifdef PIC
 	add	r12, r1
 #endif
@@ -128,14 +132,14 @@ ENTRY(__makecontext)
 #ifdef PIC
 .Lgot:
 	.long	_GLOBAL_OFFSET_TABLE_
-.L3:
+.Lsetcontext:
 	.long	__setcontext@PLT-(.LPCS0+2-(.))
-.L4:
+.Lexit:
 	.long	HIDDEN_JUMPTARGET(exit)@GOTOFF
 #else
-.L3:
+.Lsetcontext:
 	.long	__setcontext
-.L4:
+.Lexit:
 	.long	HIDDEN_JUMPTARGET(exit)
 #endif
 	cfi_startproc


Grüße,
 Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120614/dc2758d8/attachment.sig>


More information about the Libc-alpha mailing list