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]

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


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

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]