This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Hi!

On Thu, 14 Jun 2012 12:19:29 +0200, I wrote:
> 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)?)

Will revisit this topic after the release.


For now, I pushed the following as commit
a9def8c49d22815801408e62bedca26810cfceb7:

	* 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 4a0207a..a847bb6 100644
--- a/sysdeps/unix/sysv/linux/sh/makecontext.S
+++ b/sysdeps/unix/sysv/linux/sh/makecontext.S
@@ -97,22 +97,26 @@ ENTRY(__makecontext)
 
 	.align	5
 .Lexitcode:
-	tst	r8, r8		/* ucb->uc_link == NULL? */
-	bt/s	2f
-	 mov	r8, r4		/* r4 <- ucb->uc_link */
 #ifdef PIC
 	mova	.Lgot, r0
 	mov.l	.Lgot, r12
 	add	r0, r12
+#endif
+	tst	r8, r8		/* ucb->uc_link == NULL? */
+	bt/s	2f
+	 mov	r8, r4		/* r4 <- ucb->uc_link */
 	mov.l	.Lsetcontext, r1
+#ifdef PIC
 	bsrf	r1
 .LPCS0:
 	 nop
 #else
-	mov.l	.Lsetcontext, 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	.Lexit, r1
 #ifdef PIC


GrÃÃe,
 Thomas

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]