public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: GNU libc hacker <libc-hacker@sources.redhat.com>
Subject: Re: things to do for arch maintainers
Date: Mon, 19 Dec 2005 22:12:00 -0000	[thread overview]
Message-ID: <20051219221204.GK4625@sunsite.mff.cuni.cz> (raw)
In-Reply-To: <43A5B402.10007@redhat.com>

On Sun, Dec 18, 2005 at 11:09:54AM -0800, Ulrich Drepper wrote:
> 1. on the setjmp code, make sure that for the code ending up inside 
> ld.so we don't call __sigjmp_save (see the x86, x86-64, ppc code)
> 
> 2. add pointer_guard to tcbhead_t in <tls.h>
> 
> 3. define THREAD_SET_POINTER_GUARD and THREAD_COPY_POINTER_GUARD in <tls.h>
> 
> 4. in <sysdep.h>, define PTR_MANGLE and PTR_DEMANGLE.  The ld.so code 
> must use the global variable __pointer_chk_guard_local.  The libc code 
> must use the tcbhead_t value.  C and asm versions are needed.  See the 
> x86-64 version
> 
> 
> All needs to be done for archs other than x86 and x86-64 (although 1 is 
> done for ppc).

Here it is for ppc, ppc64, s390, s390x and ia64.  Arch maintainers are
surely welcome to improve the asm sequences, but this patch seems to at
least work correctly.

2005-12-19  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/powerpc/powerpc32/__longjmp-common.S (__longjmp): Use
	PTR_DEMANGLE for PC if defined.
	* sysdeps/powerpc/powerpc64/__longjmp-common.S (__longjmp):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/__longjmp.S (__longjmp): Likewise.
	* sysdeps/s390/s390-32/__longjmp.c (__longjmp): Xor %r14 with
	THREAD_GET_POINTER_GUARD () if PTR_DEMANGLE is defined.
	* sysdeps/s390/s390-64/__longjmp.c (__longjmp): Likewise.
	* sysdeps/powerpc/powerpc32/setjmp-common.S (__sigsetjmp): Use
	PTR_MANGLE for PC if defined.
	* sysdeps/powerpc/powerpc64/setjmp-common.S (__sigsetjmp): Likewise.
	* sysdeps/s390/s390-32/setjmp.S (__sigsetjmp): Likewise.
	Avoid call to __sigjmp_save if IS_IN_rtld.
	* sysdeps/s390/s390-32/elf/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/s390/s390-64/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/s390/s390-64/elf/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/unix/sysv/linux/ia64/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/unix/sysv/linux/ia64/sysdep.h (PTR_MANGLE, PTR_DEMANGLE):
	Define.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h: Include tls.h.
	(PTR_MANGLE, PTR_DEMANGLE): Define.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Include tls.h
	(PTR_MANGLE, PTR_DEMANGLE): Define.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Include tls.h.
	(PTR_MANGLE, PTR_DEMANGLE): Define.
	(SYSCALL_ERROR_HANDLER): Add missing semicolons.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h: Include tls.h.
	(PTR_MANGLE, PTR_DEMANGLE): Define.
	* sysdeps/unix/sysv/linux/s390/s390-64/socket.S (__socket): Add
	SYSCALL_ERROR_HANDLER.
nptl/
	* sysdeps/ia64/tls.h (TLS_PRE_TCB_SIZE): Make room for 2 uintptr_t's
	rather than one.
	(THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
	THREAD_COPY_POINTER_GUARD): Define.
	* sysdeps/powerpc/tcb-offsets.sym (POINTER_GUARD): Add.
	* sysdeps/powerpc/tls.h (tcbhead_t): Add pointer_guard field.
	(THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
	THREAD_COPY_POINTER_GUARD): Define.
	* sysdeps/s390/tcb-offsets.sym (STACK_GUARD): Add.
	* sysdeps/s390/tls.h (THREAD_GET_POINTER_GUARD,
	THREAD_SET_POINTER_GUARD, THREAD_COPY_POINTER_GUARD): Define.
	* sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S (__ia64_longjmp):
	Use PTR_DEMANGLE for B0 if defined.

--- libc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h.jj	2005-09-12 09:29:49.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h	2005-12-19 15:09:37.000000000 +0100
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000,01,02,03,04 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
+   Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -23,6 +24,7 @@
 #include <sysdeps/s390/s390-32/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
+#include <tls.h>
 
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
@@ -111,8 +113,8 @@
 0:  lcr   %r0,%r2;							      \
     basr  %r1,0;							      \
 1:  al    %r1,2f-1b(%r1);						      \
-    l     %r1,SYSCALL_ERROR_ERRNO@gotntpoff(%r1)			      \
-    ear   %r2,%a0							      \
+    l     %r1,SYSCALL_ERROR_ERRNO@gotntpoff(%r1);			      \
+    ear   %r2,%a0;							      \
     st    %r0,0(%r1,%r2);						      \
     lhi   %r2,-1;							      \
     br    %r14;								      \
@@ -261,4 +263,24 @@
 #define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
 #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
 
+
+/* Pointer mangling support.  */
+#if defined NOT_IN_libc && defined IS_IN_rtld
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+   earlier than the descriptor is initialized.  */
+#else
+/* For the time being just use stack_guard rather than a separate
+   pointer_guard.  */
+# ifdef __ASSEMBLER__
+#  define PTR_MANGLE(reg, tmpreg) \
+  ear     tmpreg,%a0;			\
+  x       reg,STACK_GUARD(tmpreg)
+#  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
+# else
+#  define PTR_MANGLE(var) \
+  (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+#  define PTR_DEMANGLE(var)	PTR_MANGLE (var)
+# endif
+#endif
+
 #endif /* _LINUX_S390_SYSDEP_H */
--- libc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h.jj	2005-09-12 09:29:50.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h	2005-12-19 15:09:48.000000000 +0100
@@ -1,5 +1,5 @@
 /* Assembler macros for 64 bit S/390.
-   Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -24,6 +24,7 @@
 #include <sysdeps/s390/s390-64/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
+#include <tls.h>
 
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
@@ -263,4 +264,25 @@
 #define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
 #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
 
+/* Pointer mangling support.  */
+#if defined NOT_IN_libc && defined IS_IN_rtld
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+   earlier than the descriptor is initialized.  */
+#else
+/* For the time being just use stack_guard rather than a separate
+   pointer_guard.  */
+# ifdef __ASSEMBLER__
+#  define PTR_MANGLE(reg, tmpreg) \
+  ear     tmpreg,%a0;			\
+  sllg    tmpreg,tmpreg,32;		\
+  ear     tmpreg,%a1;			\
+  xg      reg,STACK_GUARD(tmpreg)
+#  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
+# else
+#  define PTR_MANGLE(var) \
+  (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+#  define PTR_DEMANGLE(var)	PTR_MANGLE (var)
+# endif
+#endif
+
 #endif /* _LINUX_S390_SYSDEP_H */
--- libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h.jj	2005-09-12 09:29:49.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h	2005-12-19 15:08:42.000000000 +0100
@@ -23,6 +23,7 @@
 #define _LINUX_POWERPC_SYSDEP_H 1
 
 #include <sysdeps/unix/powerpc/sysdep.h>
+#include <tls.h>
 
 /* Define __set_errno() for INLINE_SYSCALL macro below.  */
 #ifndef __ASSEMBLER__
@@ -180,4 +181,22 @@
 #define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
 #define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
 
+
+/* Pointer mangling support.  */
+#if defined NOT_IN_libc && defined IS_IN_rtld
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+   earlier than the descriptor is initialized.  */
+#else
+# ifdef __ASSEMBLER__
+#  define PTR_MANGLE(reg, tmpreg) \
+	ld	tmpreg,POINTER_GUARD(r13); \
+	xor	reg,tmpreg,reg
+#  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
+# else
+#  define PTR_MANGLE(var) \
+  (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+#  define PTR_DEMANGLE(var)	PTR_MANGLE (var)
+# endif
+#endif
+
 #endif /* linux/powerpc/powerpc64/sysdep.h */
--- libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h.jj	2005-09-12 09:29:49.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h	2005-12-19 15:09:06.000000000 +0100
@@ -20,6 +20,7 @@
 #define _LINUX_POWERPC_SYSDEP_H 1
 
 #include <sysdeps/unix/powerpc/sysdep.h>
+#include <tls.h>
 
 /* Some systen calls got renamed over time, but retained the same semantics.
    Handle them here so they can be catched by both C and assembler stubs in
@@ -170,4 +171,21 @@
 #endif /* __ASSEMBLER__ */
 
 
+/* Pointer mangling support.  */
+#if defined NOT_IN_libc && defined IS_IN_rtld
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+   earlier than the descriptor is initialized.  */
+#else
+# ifdef __ASSEMBLER__
+#  define PTR_MANGLE(reg, tmpreg) \
+	lwz	tmpreg,POINTER_GUARD(r2); \
+	xor	reg,tmpreg,reg
+#  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
+# else
+#  define PTR_MANGLE(var) \
+  (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+#  define PTR_DEMANGLE(var)	PTR_MANGLE (var)
+# endif
+#endif
+
 #endif /* linux/powerpc/powerpc32/sysdep.h */
--- libc/sysdeps/unix/sysv/linux/ia64/__longjmp.S.jj	2001-07-06 08:24:16.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/ia64/__longjmp.S	2005-12-19 13:54:19.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc.
    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -101,6 +101,9 @@ LEAF(__longjmp)
 	ld8.nta r18=[r2],16		// b2
 	ld8.nta r19=[r3],16		// b3
 	;;
+#ifdef PTR_DEMANGLE
+	PTR_DEMANGLE (r16, r24)
+#endif
 	ld8.nta r20=[r2],16		// b4
 	ld8.nta r21=[r3],16		// b5
 	;;
--- libc/sysdeps/unix/sysv/linux/ia64/sysdep.h.jj	2005-09-12 09:29:44.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/ia64/sysdep.h	2005-12-19 13:54:48.000000000 +0100
@@ -1,4 +1,5 @@
-/* Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
    Based on code originally written by David Mosberger-Tang
@@ -360,4 +361,24 @@
 
 #endif /* not __ASSEMBLER__ */
 
+/* Pointer mangling support.  */
+#if defined NOT_IN_libc && defined IS_IN_rtld
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+   earlier than the descriptor is initialized.  */
+#else
+# ifdef __ASSEMBLER__
+#  define PTR_MANGLE(reg, tmpreg) \
+        add	tmpreg=-16,r13		\
+        ;;				\
+        ld8	tmpreg=[tmpreg]		\
+        ;;				\
+        xor	reg=reg, tmpreg
+#  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
+# else
+#  define PTR_MANGLE(var) \
+  (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+#  define PTR_DEMANGLE(var)	PTR_MANGLE (var)
+# endif
+#endif
+
 #endif /* linux/ia64/sysdep.h */
--- libc/sysdeps/unix/sysv/linux/ia64/setjmp.S.jj	2004-04-28 20:39:49.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/ia64/setjmp.S	2005-12-19 13:55:01.000000000 +0100
@@ -1,4 +1,5 @@
-/* Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005
+   Free Software Foundation, Inc.
    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -86,7 +87,7 @@ libc_hidden_def (_setjmp)
 
 ENTRY(__sigsetjmp)
 	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
-	alloc loc1=ar.pfs,2,3,2,0
+	alloc loc1=ar.pfs,2,5,2,0
 	.save ar.unat, loc2
 	mov loc2=ar.unat
 	;;
@@ -140,7 +141,13 @@ ENTRY(__sigsetjmp)
 	;;
 	stf.spill.nta [r8]=f28,32
 	stf.spill.nta [r9]=f29,32
+#ifdef PTR_MANGLE
+	mov loc3=loc0
 	;;
+	PTR_MANGLE (loc3, loc4)
+#else
+	;;
+#endif
 	stf.spill.nta [r8]=f30
 	stf.spill.nta [r9]=f31
 
@@ -151,7 +158,11 @@ ENTRY(__sigsetjmp)
 	mov r25=ar.unat
 	mov out0=in0
 
+#ifdef PTR_MANGLE
+	st8.nta [r2]=loc3,16		// b0
+#else
 	st8.nta [r2]=loc0,16		// b0
+#endif
 	st8.nta [r3]=r17,16		// b1
 	mov out1=in1
 	;;
@@ -169,7 +180,12 @@ ENTRY(__sigsetjmp)
 	;;
 	st8.nta [r2]=r25		// ar.unat
 	st8.nta [r3]=in0		// &__jmp_buf
+#if defined NOT_IN_libc && defined IS_IN_rtld
+	/* In ld.so we never save the signal mask.  */
+	;;
+#else
 	br.call.dpnt.few rp=__sigjmp_save
+#endif
 .ret0:					// force a new bundle ::q
 	mov.m ar.unat=loc2		// restore caller's unat
 	mov rp=loc0
--- libc/sysdeps/s390/s390-32/setjmp.S.jj	2001-07-06 06:56:03.000000000 +0200
+++ libc/sysdeps/s390/s390-32/setjmp.S	2005-12-19 16:39:36.000000000 +0100
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -29,10 +29,22 @@
 /* R2 = pointer to jmp_buf, R3 = savemask */
 
 ENTRY(__sigsetjmp)
+#ifdef PTR_MANGLE
+	stm    %r6,%r13,0(%r2)      /* store registers in jmp_buf */
+	lr     %r4,%r14
+	PTR_MANGLE (%r4, %r5)
+	st     %r4,32(%r2)
+	st     %r15,36(%r2)
+#else
 	stm    %r6,%r15,0(%r2)      /* store registers in jmp_buf */
+#endif
 	std    %f4,40(%r2)
 	std    %f6,48(%r2)
-#ifdef PIC
+#if defined NOT_IN_libc && defined IS_IN_rtld
+	/* In ld.so we never save the signal mask.  */
+	lhi    %r2,0
+	br     %r14
+#elif defined PIC
 	/* We cannot use the PLT, because it requires that %r12 be set, but
 	   we can't save and restore our caller's value.  Instead, we do an
 	   indirect jump through the GOT. */
--- libc/sysdeps/s390/s390-32/elf/setjmp.S.jj	2005-09-12 09:29:34.000000000 +0200
+++ libc/sysdeps/s390/s390-32/elf/setjmp.S	2005-12-19 16:43:16.000000000 +0100
@@ -1,5 +1,5 @@
 /* setjmp for s390, ELF version.
-   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -46,10 +46,22 @@ END (__setjmp)
 
 ENTRY(__sigsetjmp)
 .Linternal_sigsetjmp:
+#ifdef PTR_MANGLE
+	stm    %r6,%r13,0(%r2)      /* store registers in jmp_buf */
+	lr     %r4,%r14
+	PTR_MANGLE (%r4, %r5)
+	st     %r4,32(%r2)
+	st     %r15,36(%r2)
+#else
 	stm    %r6,%r15,0(%r2)      /* store registers in jmp_buf */
+#endif
 	std    %f4,40(%r2)
 	std    %f6,48(%r2)
-#ifdef PIC
+#if defined NOT_IN_libc && defined IS_IN_rtld
+	/* In ld.so we never save the signal mask.  */
+	lhi    %r2,0
+	br     %r14
+#elif defined PIC
 	/* We cannot use the PLT, because it requires that %r12 be set, but
 	   we can't save and restore our caller's value.  Instead, we do an
 	   indirect jump through the GOT. */
--- libc/sysdeps/s390/s390-32/__longjmp.c.jj	2001-07-06 06:56:03.000000000 +0200
+++ libc/sysdeps/s390/s390-32/__longjmp.c	2005-12-19 13:45:41.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
 
@@ -29,14 +29,24 @@
 void
 __longjmp (__jmp_buf env, int val)
 {
-   /* Restore registers and jump back.  */
-   asm volatile ("lr   %%r2,%0\n\t"	  /* PUT val in grp 2.  */
-		 "ld   %%f6,48(%1)\n\t"
-		 "ld   %%f4,40(%1)\n\t"
-		 "lm   %%r6,%%r15,0(%1)\n\t"
-		 "br   %%r14"
-		 : : "r" (val == 0 ? 1 : val),
-		 "a" (env) : "2" );
+#ifdef PTR_DEMANGLE
+  register uintptr_t r5 __asm ("%r5") = THREAD_GET_POINTER_GUARD ();
+#endif
+  /* Restore registers and jump back.  */
+  asm volatile ("lr   %%r2,%0\n\t"	  /* PUT val in grp 2.  */
+		"ld   %%f6,48(%1)\n\t"
+		"ld   %%f4,40(%1)\n\t"
+		"lm   %%r6,%%r15,0(%1)\n\t"
+#ifdef PTR_DEMANGLE
+		"xr   %%r14,%2\n\t"
+#endif
+		"br   %%r14"
+		: : "r" (val == 0 ? 1 : val),
+		    "a" (env)
+#ifdef PTR_DEMANGLE
+		    , "r" (r5)
+#endif
+		: "2" );
 
   /* Avoid `volatile function does return' warnings.  */
   for (;;);
--- libc/sysdeps/s390/s390-64/setjmp.S.jj	2001-07-06 06:56:03.000000000 +0200
+++ libc/sysdeps/s390/s390-64/setjmp.S	2005-12-19 16:41:22.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2005 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -28,16 +28,26 @@
 /* R2 = pointer to jmp_buf, R3 = savemask.  */
 
 ENTRY(__sigsetjmp)
+#ifdef PTR_MANGLE
+	stmg   %r6,%r13,0(%r2)      /* Store registers in jmp_buf.  */
+	lgr    %r4,%r14
+	PTR_MANGLE (%r4, %r5)
+	stg    %r4,64(%r2)
+	stg    %r15,72(%r2)
+#else
         stmg   %r6,%r15,0(%r2)      /* Store registers in jmp_buf.  */
+#endif
 	std    %f1,80(%r2)
 	std    %f3,88(%r2)
 	std    %f5,96(%r2)
 	std    %f7,104(%r2)
-#ifdef PIC
+#if defined NOT_IN_libc && defined IS_IN_rtld
+	/* In ld.so we never save the signal mask.  */
+	lghi   %r2,0
+	br     %r14
+#elif defined PIC
         jg     __sigjmp_save@PLT    /* Tail-call __sigjmp_save.  */
 #else
         jg     __sigjmp_save        /* Tail-call __sigjmp_save.  */
 #endif
 END (__sigsetjmp)
-
-
--- libc/sysdeps/s390/s390-64/elf/setjmp.S.jj	2005-09-12 09:29:34.000000000 +0200
+++ libc/sysdeps/s390/s390-64/elf/setjmp.S	2005-12-19 16:43:25.000000000 +0100
@@ -1,5 +1,5 @@
 /* setjmp for 64 bit S/390, ELF version.
-   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -46,12 +46,24 @@ END (setjmp)
 
 ENTRY(__sigsetjmp)
 .Linternal_sigsetjmp:
+#ifdef PTR_MANGLE
+	stmg   %r6,%r13,0(%r2)      /* Store registers in jmp_buf.  */
+	lgr    %r4,%r14
+	PTR_MANGLE (%r4, %r5)
+	stg    %r4,64(%r2)
+	stg    %r15,72(%r2)
+#else
         stmg   %r6,%r15,0(%r2)      /* Store registers in jmp_buf.  */
+#endif
 	std    %f1,80(%r2)
 	std    %f3,88(%r2)
 	std    %f5,96(%r2)
 	std    %f7,104(%r2)
-#ifdef PIC
+#if defined NOT_IN_libc && defined IS_IN_rtld
+	/* In ld.so we never save the signal mask.  */
+	lghi   %r2,0
+	br     %r14
+#elif defined PIC
         jg     __sigjmp_save@PLT    /* Branch to PLT of __sigsetjmp.  */
 #else
 	jg     __sigjmp_save
--- libc/sysdeps/s390/s390-64/__longjmp.c.jj	2001-07-06 06:56:03.000000000 +0200
+++ libc/sysdeps/s390/s390-64/__longjmp.c	2005-12-19 13:46:12.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
 
@@ -29,18 +29,27 @@
 void
 __longjmp (__jmp_buf env, int val)
 {
-   /* Restore registers and jump back.  */
-   asm volatile ("lgr  %%r2,%0\n\t"        /* Put val in grp 2.  */
-		 "ld   %%f7,104(%1)\n\t"
-		 "ld   %%f5,96(%1)\n\t"
-		 "ld   %%f3,88(%1)\n\t"
-		 "ld   %%f1,80(%1)\n\t"
-                 "lmg  %%r6,%%r15,0(%1)\n\t"
-                 "br   %%r14"
-                 : : "r" (val == 0 ? 1 : val),
-                 "a" (env) : "2" );
+#ifdef PTR_DEMANGLE
+  register uintptr_t r5 __asm ("%r5") = THREAD_GET_POINTER_GUARD ();
+#endif
+  /* Restore registers and jump back.  */
+  asm volatile ("lgr  %%r2,%0\n\t"        /* Put val in grp 2.  */
+		"ld   %%f7,104(%1)\n\t"
+		"ld   %%f5,96(%1)\n\t"
+		"ld   %%f3,88(%1)\n\t"
+		"ld   %%f1,80(%1)\n\t"
+		"lmg  %%r6,%%r15,0(%1)\n\t"
+#ifdef PTR_DEMANGLE
+		"xgr  %%r14,%2\n\t"
+#endif
+		"br   %%r14"
+		: : "r" (val == 0 ? 1 : val),
+		    "a" (env)
+#ifdef PTR_DEMANGLE
+		    , "r" (r5)
+#endif
+		: "2" );
 
   /* Avoid `volatile function does return' warnings.  */
   for (;;);
 }
-
--- libc/sysdeps/powerpc/powerpc64/__longjmp-common.S.jj	2004-12-21 14:33:39.000000000 +0100
+++ libc/sysdeps/powerpc/powerpc64/__longjmp-common.S	2005-12-19 10:41:04.000000000 +0100
@@ -1,5 +1,5 @@
 /* longjmp for PowerPC64.
-   Copyright (C) 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -128,6 +128,9 @@ L(no_vmx):
 	lfd fp19,((JB_FPRS+5)*8)(r3)
 	ld r20,((JB_GPRS+6)*8)(r3)
 	lfd fp20,((JB_FPRS+6)*8)(r3)
+#ifdef PTR_DEMANGLE
+	PTR_DEMANGLE (r0, r25)
+#endif
 	mtlr r0
 /* 	std r2,40(r1)	Restore the TOC save area.  */
 	ld r21,((JB_GPRS+7)*8)(r3)
--- libc/sysdeps/powerpc/powerpc64/setjmp-common.S.jj	2005-12-19 08:43:50.000000000 +0100
+++ libc/sysdeps/powerpc/powerpc64/setjmp-common.S	2005-12-19 10:47:55.000000000 +0100
@@ -56,6 +56,9 @@ JUMPTARGET(GLUE(__sigsetjmp,_ent)):
 #endif
 	std  r14,((JB_GPRS+0)*8)(3)
 	stfd fp14,((JB_FPRS+0)*8)(3)
+#ifdef PTR_MANGLE
+	PTR_MANGLE (r0, r10)
+#endif
 	std  r0,(JB_LR*8)(3)
 	std  r15,((JB_GPRS+1)*8)(3)
 	stfd fp15,((JB_FPRS+1)*8)(3)
--- libc/sysdeps/powerpc/powerpc32/__longjmp-common.S.jj	2004-02-14 05:04:04.000000000 +0100
+++ libc/sysdeps/powerpc/powerpc32/__longjmp-common.S	2005-12-19 10:38:07.000000000 +0100
@@ -1,5 +1,6 @@
 /* longjmp for PowerPC.
-   Copyright (C) 1995-1997,1999-2001,2003,2004 Free Software Foundation, Inc.
+   Copyright (C) 1995-1997, 1999-2001, 2003, 2004, 2005
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -40,6 +41,9 @@ ENTRY (BP_SYM (__longjmp))
 	lwz r18,((JB_GPRS+4)*4)(r3)
 	lwz r19,((JB_GPRS+5)*4)(r3)
 	lwz r20,((JB_GPRS+6)*4)(r3)
+#ifdef PTR_DEMANGLE
+	PTR_DEMANGLE (r0, r25)
+#endif
 	mtlr r0
 	lwz r21,((JB_GPRS+7)*4)(r3)
 	lwz r22,((JB_GPRS+8)*4)(r3)
--- libc/sysdeps/powerpc/powerpc32/setjmp-common.S.jj	2005-12-19 08:43:50.000000000 +0100
+++ libc/sysdeps/powerpc/powerpc32/setjmp-common.S	2005-12-19 10:47:36.000000000 +0100
@@ -36,6 +36,9 @@ ENTRY (BP_SYM (__sigsetjmp))
 	stw  r1,(JB_GPR1*4)(3)
 	mflr r0
 	stw  r14,((JB_GPRS+0)*4)(3)
+#ifdef PTR_MANGLE
+	PTR_MANGLE (r0, r10)
+#endif
 	stw  r0,(JB_LR*4)(3)
 	stw  r15,((JB_GPRS+1)*4)(3)
 	mfcr r0
--- libc/nptl/sysdeps/s390/tcb-offsets.sym.jj	2004-12-21 14:33:30.000000000 +0100
+++ libc/nptl/sysdeps/s390/tcb-offsets.sym	2005-12-19 09:32:17.000000000 +0100
@@ -2,5 +2,6 @@
 #include <tls.h>
 
 MULTIPLE_THREADS_OFFSET		offsetof (tcbhead_t, multiple_threads)
+STACK_GUARD			offsetof (tcbhead_t, stack_guard)
 PID				offsetof (struct pthread, pid)
 TID				offsetof (struct pthread, tid)
--- libc/nptl/sysdeps/s390/tls.h.jj	2005-07-04 10:16:56.000000000 +0200
+++ libc/nptl/sysdeps/s390/tls.h	2005-12-19 13:42:40.000000000 +0100
@@ -164,6 +164,13 @@ typedef struct
   ((descr)->header.stack_guard						      \
    = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
 
+/* s390 doesn't have HP_TIMING_*, so for the time being
+   use stack_guard as pointer_guard.  */
+#define THREAD_GET_POINTER_GUARD() \
+  THREAD_GETMEM (THREAD_SELF, header.stack_guard)
+#define THREAD_SET_POINTER_GUARD(value)
+#define THREAD_COPY_POINTER_GUARD(descr)
+
 #endif /* __ASSEMBLER__ */
 
 #endif	/* tls.h */
--- libc/nptl/sysdeps/powerpc/tcb-offsets.sym.jj	2005-02-21 17:20:00.000000000 +0100
+++ libc/nptl/sysdeps/powerpc/tcb-offsets.sym	2005-12-19 10:19:53.000000000 +0100
@@ -14,3 +14,4 @@ MULTIPLE_THREADS_OFFSET		thread_offsetof
 #endif
 PID				thread_offsetof (pid)
 TID				thread_offsetof (tid)
+POINTER_GUARD			(offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
--- libc/nptl/sysdeps/powerpc/tls.h.jj	2005-07-04 10:16:56.000000000 +0200
+++ libc/nptl/sysdeps/powerpc/tls.h	2005-12-19 10:17:09.000000000 +0100
@@ -66,9 +66,11 @@ typedef union dtv
 # include <nptl/descr.h>
 
 /* The stack_guard is accessed directly by GCC -fstack-protector code,
-   so it is a part of public ABI.  The dtv field is private.  */
+   so it is a part of public ABI.  The dtv and pointer_guard fields
+   are private.  */
 typedef struct
 {
+  uintptr_t pointer_guard;
   uintptr_t stack_guard;
   dtv_t *dtv;
 } tcbhead_t;
@@ -166,6 +168,17 @@ register void *__thread_register __asm__
      = ((tcbhead_t *) ((char *) __thread_register			      \
 		       - TLS_TCB_OFFSET))[-1].stack_guard)
 
+/* Set the stack guard field in TCB head.  */
+# define THREAD_GET_POINTER_GUARD() \
+    (((tcbhead_t *) ((char *) __thread_register				      \
+		     - TLS_TCB_OFFSET))[-1].pointer_guard)
+# define THREAD_SET_POINTER_GUARD(value) \
+    (THREAD_GET_POINTER_GUARD () = (value))
+# define THREAD_COPY_POINTER_GUARD(descr) \
+    (((tcbhead_t *) ((char *) (descr)					      \
+		     + TLS_PRE_TCB_SIZE))[-1].pointer_guard		      \
+     = THREAD_GET_POINTER_GUARD())
+
 /* l_tls_offset == 0 is perfectly valid on PPC, so we have to use some
    different value to mean unset l_tls_offset.  */
 # define NO_TLS_OFFSET		-1
--- libc/nptl/sysdeps/ia64/tls.h.jj	2005-07-11 09:14:32.000000000 +0200
+++ libc/nptl/sysdeps/ia64/tls.h	2005-12-19 13:41:05.000000000 +0100
@@ -81,13 +81,14 @@ register struct pthread *__thread_self _
 # define TLS_TCB_SIZE sizeof (tcbhead_t)
 
 /* This is the size we need before TCB.
-   If there is not any room for uintptr_t stack_guard in struct pthread's
-   final padding, we need to put struct pthread 16 byte slower.  */
+   If there is not any room for uintptr_t stack_guard and
+   uintptr_t pointer_guard in struct pthread's final padding,
+   we need to put struct pthread 16 byte slower.  */
 # define TLS_PRE_TCB_SIZE \
-  (sizeof (struct pthread)					\
-   + (PTHREAD_STRUCT_END_PADDING < sizeof (uintptr_t)		\
-      ? ((sizeof (uintptr_t) + __alignof__ (struct pthread) - 1)\
-	 & ~(__alignof__ (struct pthread) - 1))			\
+  (sizeof (struct pthread)						\
+   + (PTHREAD_STRUCT_END_PADDING < 2 * sizeof (uintptr_t)		\
+      ? ((2 * sizeof (uintptr_t) + __alignof__ (struct pthread) - 1)	\
+	 & ~(__alignof__ (struct pthread) - 1))				\
       : 0))
 
 /* Alignment requirements for the TCB.  */
@@ -156,6 +157,15 @@ register struct pthread *__thread_self _
   (((uintptr_t *) ((char *) (descr) + TLS_PRE_TCB_SIZE))[-1] \
    = ((uintptr_t *) __thread_self)[-1])
 
+/* Set the pointer guard field in TCB head.  */
+#define THREAD_GET_POINTER_GUARD() \
+  (((uintptr_t *) __thread_self)[-2])
+#define THREAD_SET_POINTER_GUARD(value) \
+  (((uintptr_t *) __thread_self)[-2] = (value))
+#define THREAD_COPY_POINTER_GUARD(descr) \
+  (((uintptr_t *) ((char *) (descr) + TLS_PRE_TCB_SIZE))[-2] \
+   = THREAD_GET_POINTER_GUARD ())
+
 #endif /* __ASSEMBLER__ */
 
 #endif	/* tls.h */
--- libc/sysdeps/unix/sysv/linux/s390/s390-64/socket.S.jj	2005-09-12 09:29:50.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/s390/s390-64/socket.S	2005-12-19 16:23:44.000000000 +0100
@@ -128,6 +128,7 @@ L(socket_cancel):
 	j	4b
 #endif
 
+	SYSCALL_ERROR_HANDLER
 END (__socket)
 
 #ifndef NO_WEAK_ALIAS
--- libc/nptl/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S.jj	2004-09-13 20:34:47.000000000 +0200
+++ libc/nptl/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S	2005-12-19 19:00:44.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -102,6 +102,9 @@ LEAF(__ia64_longjmp)
 	;;
 	ld8.nta r20=[r2],16		// b4
 	ld8.nta r21=[r3],16		// b5
+#ifdef PTR_DEMANGLE
+	PTR_DEMANGLE (r16, r24)
+#endif
 	;;
 	ld8.nta r11=[r2],16		// ar.pfs
 	ld8.nta r22=[r3],56		// ar.lc


	Jakub

  reply	other threads:[~2005-12-19 22:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-18 19:11 Ulrich Drepper
2005-12-19 22:12 ` Jakub Jelinek [this message]
2005-12-20  6:55   ` Ulrich Drepper
2005-12-20  9:09 ` Kaz Kojima
2005-12-20 15:32   ` Ulrich Drepper
2005-12-21  0:57     ` Kaz Kojima
2005-12-20 21:08 ` Steven Munroe
2005-12-20 21:13   ` Jakub Jelinek
2005-12-20 23:34     ` Steven Munroe
2005-12-20 23:58       ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051219221204.GK4625@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).