This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
> 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). The appended patch is for SH. It also fixes a typo in sysdeps/unix/sysv/linux/sh/sysdep.h. Regards, kaz -- [nptl/ChangeLog] 2005-12-19 Kaz Kojima <kkojima@rr.iij4u.or.jp> * sysdeps/sh/tcb-offsets.sym: Add POINTER_GUARD. * sysdeps/sh/tls.h (tcbhead_t): Remove private and add pointer_guard. (THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD, THREAD_COPY_POINTER_GUARD): Define. [ChangeLog] 2005-12-19 Kaz Kojima <kkojima@rr.iij4u.or.jp> * sysdeps/unix/sysv/linux/sh/sysdep.h: Include tls.h. (PTR_MANGLE, PTR_DEMANGLE): Difine. (SYSCALL_ERROR_HANDLER): Fix typo. * sysdeps/sh/sh4/__longjmp.S: Use PTR_DEMANGLE if defined. * sysdeps/sh/sh3/__longjmp.S: Likewise. * sysdeps/sh/sh4/setjmp.S: Use PTR_MANGLE if defined. * sysdeps/sh/sh3/setjmp.S: Likewise. diff -uprN ORIG/libc/nptl/sysdeps/sh/tcb-offsets.sym LOCAL/libc/nptl/sysdeps/sh/tcb-offsets.sym --- ORIG/libc/nptl/sysdeps/sh/tcb-offsets.sym 2004-03-12 01:03:46.000000000 +0900 +++ LOCAL/libc/nptl/sysdeps/sh/tcb-offsets.sym 2005-12-19 07:11:28.000000000 +0900 @@ -9,3 +9,4 @@ CLEANUP_JMP_BUF offsetof (struct pthrea MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads) TLS_PRE_TCB_SIZE sizeof (struct pthread) MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock) +POINTER_GUARD offsetof (tcbhead_t, pointer_guard) diff -uprN ORIG/libc/nptl/sysdeps/sh/tls.h LOCAL/libc/nptl/sysdeps/sh/tls.h --- ORIG/libc/nptl/sysdeps/sh/tls.h 2005-01-07 07:40:21.000000000 +0900 +++ LOCAL/libc/nptl/sysdeps/sh/tls.h 2005-12-20 16:26:27.000000000 +0900 @@ -41,7 +41,7 @@ typedef union dtv typedef struct { dtv_t *dtv; - void *private; + uintptr_t pointer_guard; } tcbhead_t; # define TLS_MULTIPLE_THREADS_IN_TCB 1 @@ -140,6 +140,19 @@ typedef struct # define THREAD_SETMEM_NC(descr, member, idx, value) \ descr->member[idx] = (value) +#define THREAD_GET_POINTER_GUARD() \ + ({ tcbhead_t *__tcbp; \ + __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \ + __tcbp->pointer_guard;}) + #define THREAD_SET_POINTER_GUARD(value) \ + ({ tcbhead_t *__tcbp; \ + __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \ + __tcbp->pointer_guard = (value);}) +#define THREAD_COPY_POINTER_GUARD(descr) \ + ({ tcbhead_t *__tcbp; \ + __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \ + ((tcbhead_t *) (descr + 1))->pointer_guard = __tcbp->pointer_guard;}) + #endif /* __ASSEMBLER__ */ #endif /* tls.h */ diff -uprN ORIG/libc/sysdeps/sh/sh3/__longjmp.S LOCAL/libc/sysdeps/sh/sh3/__longjmp.S --- ORIG/libc/sysdeps/sh/sh3/__longjmp.S 2001-07-06 13:56:03.000000000 +0900 +++ LOCAL/libc/sysdeps/sh/sh3/__longjmp.S 2005-12-19 08:44:11.000000000 +0900 @@ -1,5 +1,5 @@ /* longjmp for SH. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 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 @@ -32,13 +32,19 @@ ENTRY (__longjmp) mov.l @r4+, r12 mov.l @r4+, r13 mov.l @r4+, r14 - mov.l @r4+, r15 mov r5, r0 /* get the return value in place */ tst r0, r0 bf.s 1f - lds.l @r4+, pr + mov.l @r4+, r15 mov #1,r0 /* can't let setjmp() return zero! */ 1: +#ifdef PTR_DEMANGLE + mov.l @r4+, r2 + PTR_DEMANGLE (r2) + lds r2, pr +#else + lds.l @r4+, pr +#endif rts ldc.l @r4+, gbr END (__longjmp) diff -uprN ORIG/libc/sysdeps/sh/sh3/setjmp.S LOCAL/libc/sysdeps/sh/sh3/setjmp.S --- ORIG/libc/sysdeps/sh/sh3/setjmp.S 2001-07-06 13:56:03.000000000 +0900 +++ LOCAL/libc/sysdeps/sh/sh3/setjmp.S 2005-12-19 08:43:47.000000000 +0900 @@ -1,5 +1,5 @@ /* setjmp for SH3. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 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 @@ -26,7 +26,13 @@ ENTRY (__sigsetjmp) /* Save registers */ add #(JB_SIZE - 4 * 5), r4 stc.l gbr, @-r4 +#ifdef PTR_MANGLE + sts pr, r2 + PTR_MANGLE (r2) + mov.l r2, @-r4 +#else sts.l pr, @-r4 +#endif mov.l r15, @-r4 mov.l r14, @-r4 mov.l r13, @-r4 @@ -36,8 +42,13 @@ ENTRY (__sigsetjmp) mov.l r9, @-r4 mov.l r8, @-r4 +#if defined NOT_IN_libc && defined IS_IN_rtld + /* In ld.so we never save the signal mask. */ + rts + mov #0, r0 +#else /* Make a tail call to __sigjmp_save; it takes the same args. */ -#ifdef SHARED +# ifdef SHARED mov.l 1f, r1 mova 1f, r0 bra 2f @@ -53,12 +64,13 @@ ENTRY (__sigsetjmp) .align 2 .L1: .long C_SYMBOL_NAME(__sigjmp_save@GOT) -#else +# else mov.l .L1, r1 jmp @r1 nop .align 2 .L1: .long C_SYMBOL_NAME(__sigjmp_save) +# endif #endif END (__sigsetjmp) diff -uprN ORIG/libc/sysdeps/sh/sh4/__longjmp.S LOCAL/libc/sysdeps/sh/sh4/__longjmp.S --- ORIG/libc/sysdeps/sh/sh4/__longjmp.S 2001-07-06 13:56:03.000000000 +0900 +++ LOCAL/libc/sysdeps/sh/sh4/__longjmp.S 2005-12-19 08:44:47.000000000 +0900 @@ -1,5 +1,5 @@ /* longjmp for SH. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 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 @@ -32,13 +32,19 @@ ENTRY (__longjmp) mov.l @r4+, r12 mov.l @r4+, r13 mov.l @r4+, r14 - mov.l @r4+, r15 mov r5, r0 /* get the return value in place */ tst r0, r0 bf.s 1f - lds.l @r4+, pr + mov.l @r4+, r15 mov #1,r0 /* can't let setjmp() return zero! */ 1: +#ifdef PTR_DEMANGLE + mov.l @r4+, r2 + PTR_DEMANGLE (r2) + lds r2, pr +#else + lds.l @r4+, pr +#endif ldc.l @r4+, gbr lds.l @r4+, fpscr fmov.s @r4+, fr12 diff -uprN ORIG/libc/sysdeps/sh/sh4/setjmp.S LOCAL/libc/sysdeps/sh/sh4/setjmp.S --- ORIG/libc/sysdeps/sh/sh4/setjmp.S 2001-07-06 13:56:03.000000000 +0900 +++ LOCAL/libc/sysdeps/sh/sh4/setjmp.S 2005-12-19 08:44:31.000000000 +0900 @@ -1,5 +1,5 @@ /* setjmp for SH4. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 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 @@ -31,7 +31,13 @@ ENTRY (__sigsetjmp) fmov.s fr12, @-r4 sts.l fpscr, @-r4 stc.l gbr, @-r4 +#ifdef PTR_MANGLE + sts pr, r2 + PTR_MANGLE (r2) + mov.l r2, @-r4 +#else sts.l pr, @-r4 +#endif mov.l r15, @-r4 mov.l r14, @-r4 mov.l r13, @-r4 @@ -41,8 +47,13 @@ ENTRY (__sigsetjmp) mov.l r9, @-r4 mov.l r8, @-r4 +#if defined NOT_IN_libc && defined IS_IN_rtld + /* In ld.so we never save the signal mask. */ + rts + mov #0, r0 +#else /* Make a tail call to __sigjmp_save; it takes the same args. */ -#ifdef SHARED +# ifdef SHARED mov.l 1f, r1 mova 1f, r0 bra 2f @@ -58,12 +69,13 @@ ENTRY (__sigsetjmp) .align 2 .L1: .long C_SYMBOL_NAME(__sigjmp_save@GOT) -#else +# else mov.l .L1, r1 jmp @r1 nop .align 2 .L1: .long C_SYMBOL_NAME(__sigjmp_save) +# endif #endif END (__sigsetjmp) diff -uprN ORIG/libc/sysdeps/unix/sysv/linux/sh/sysdep.h LOCAL/libc/sysdeps/unix/sysv/linux/sh/sysdep.h --- ORIG/libc/sysdeps/unix/sysv/linux/sh/sysdep.h 2004-10-05 05:59:37.000000000 +0900 +++ LOCAL/libc/sysdeps/unix/sysv/linux/sh/sysdep.h 2005-12-20 17:31:03.000000000 +0900 @@ -1,5 +1,5 @@ -/* Copyright (C) 1992,1993,1995,1996,1997,1998,1999,2000,2002,2003,2004 - Free Software Foundation, Inc. +/* Copyright (C) 1992,1993,1995,1996,1997,1998,1999,2000,2002,2003,2004, + 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995. Changed by Kaz Kojima, <kkojima@rr.iij4u.or.jp>. @@ -24,6 +24,7 @@ /* There is some commonality. */ #include <sysdeps/unix/sh/sysdep.h> +#include <tls.h> /* For Linux we can use the system call table in the header file /usr/include/asm/unistd.h @@ -104,7 +105,7 @@ mova 0f,r0; \ add r0,r12; \ mov.l 1f,r0; \ - mov.l r1,@(r0,r12) + mov.l r1,@(r0,r12); \ bra .Lpseudo_end; \ mov _IMM1,r0; \ .align 2; \ @@ -359,4 +360,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. Using a global variable + is too complicated here since we have no PC-relative addressing mode. */ +#else +# ifdef __ASSEMBLER__ +# define PTR_MANGLE(reg) \ + stc gbr,r1; mov.l @(POINTER_GUARD,r1),r1; xor r1,reg +# define PTR_DEMANGLE(reg) PTR_MANGLE (reg) +# 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/sh/sysdep.h */
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |