diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2009-08-09 14:33:15 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2009-08-09 14:33:15 +0000 |
commit | e3665fddce66693f98e3b6127986aac8caa55bf1 (patch) | |
tree | 06139cc7f58aa82433d0d803ca628a6da594565c /ports/sysdeps | |
parent | e6ab798eb7a34667bce399a7ef4349adb5d3b085 (diff) | |
download | eglibc2-e3665fddce66693f98e3b6127986aac8caa55bf1.tar.gz |
Merge changes between r8756 and r8789 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@8790 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'ports/sysdeps')
-rw-r--r-- | ports/sysdeps/arm/__longjmp.S | 4 | ||||
-rw-r--r-- | ports/sysdeps/arm/eabi/__longjmp.S | 4 | ||||
-rw-r--r-- | ports/sysdeps/mips/__longjmp.c | 8 | ||||
-rw-r--r-- | ports/sysdeps/mips/mips64/__longjmp.c | 8 | ||||
-rw-r--r-- | ports/sysdeps/unix/sysv/linux/arm/____longjmp_chk.S (renamed from ports/sysdeps/arm/____longjmp_chk.S) | 22 | ||||
-rw-r--r-- | ports/sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S | 76 | ||||
-rw-r--r-- | ports/sysdeps/unix/sysv/linux/mips/____longjmp_chk.c (renamed from ports/sysdeps/mips/____longjmp_chk.c) | 22 |
7 files changed, 130 insertions, 14 deletions
diff --git a/ports/sysdeps/arm/__longjmp.S b/ports/sysdeps/arm/__longjmp.S index c834e7860..09e638641 100644 --- a/ports/sysdeps/arm/__longjmp.S +++ b/ports/sysdeps/arm/__longjmp.S @@ -30,8 +30,8 @@ ENTRY (__longjmp) moveq r0, #1 /* can't let setjmp() return zero! */ #ifdef CHECK_SP - ldr r1, [ip, #32] - CHECK_SP (r1) + ldr r4, [ip, #32] + CHECK_SP (r4) #endif LOADREGS(ia, ip, {v1-v6, sl, fp, sp, pc}) END (__longjmp) diff --git a/ports/sysdeps/arm/eabi/__longjmp.S b/ports/sysdeps/arm/eabi/__longjmp.S index 1f3f79156..f28329708 100644 --- a/ports/sysdeps/arm/eabi/__longjmp.S +++ b/ports/sysdeps/arm/eabi/__longjmp.S @@ -31,8 +31,8 @@ ENTRY (__longjmp) moveq r0, #1 /* can't let setjmp() return zero! */ #ifdef CHECK_SP - ldr r1, [ip, #32] - CHECK_SP (r1) + ldr r4, [ip, #32] + CHECK_SP (r4) #endif LOADREGS(ia, ip!, {v1-v6, sl, fp, sp, lr}) diff --git a/ports/sysdeps/mips/__longjmp.c b/ports/sysdeps/mips/__longjmp.c index 340485de8..2a917719f 100644 --- a/ports/sysdeps/mips/__longjmp.c +++ b/ports/sysdeps/mips/__longjmp.c @@ -25,19 +25,19 @@ #endif void -__longjmp (env, val_arg) - __jmp_buf env; +__longjmp (env_arg, val_arg) + __jmp_buf env_arg; int val_arg; { /* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before the hack around it); force it to use $a1 for the longjmp value. Without this it saves $a1 in a register which gets clobbered along the way. */ + register struct __jmp_buf_internal_tag *env asm ("a0"); register int val asm ("a1"); #ifdef CHECK_SP register long sp asm ("$29"); - if ((long) (env[0].__sp) < sp) - __fortify_fail ("longjmp causes uninitialized stack frame"); + CHECK_SP (env[0].__sp, sp, long); #endif #ifdef __mips_hard_float diff --git a/ports/sysdeps/mips/mips64/__longjmp.c b/ports/sysdeps/mips/mips64/__longjmp.c index d7e36ff68..99aac01a9 100644 --- a/ports/sysdeps/mips/mips64/__longjmp.c +++ b/ports/sysdeps/mips/mips64/__longjmp.c @@ -27,19 +27,19 @@ #endif void -__longjmp (env, val_arg) - __jmp_buf env; +__longjmp (env_arg, val_arg) + __jmp_buf env_arg; int val_arg; { /* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before the hack around it); force it to use $a1 for the longjmp value. Without this it saves $a1 in a register which gets clobbered along the way. */ + register struct __jmp_buf_internal_tag *env asm ("a0"); register int val asm ("a1"); #ifdef CHECK_SP register long long sp asm ("$29"); - if ((long long) (env[0].__sp) < sp) - __fortify_fail ("longjmp causes uninitialized stack frame"); + CHECK_SP (env[0].__sp, sp, long long); #endif #ifdef __mips_hard_float diff --git a/ports/sysdeps/arm/____longjmp_chk.S b/ports/sysdeps/unix/sysv/linux/arm/____longjmp_chk.S index 16fc4cdeb..2fa727dcf 100644 --- a/ports/sysdeps/arm/____longjmp_chk.S +++ b/ports/sysdeps/unix/sysv/linux/arm/____longjmp_chk.S @@ -16,6 +16,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <sysdep.h> .section .rodata.str1.1,"aMS",%progbits,1 .type longjmp_msg,%object @@ -47,9 +48,28 @@ longjmp_msg: #endif #define CHECK_SP(reg) \ - cmp sp, reg; \ + cmp sp, reg; \ bls .Lok; \ + mov r5, r0; \ + mov r0, #0; \ + sub sp, sp, #16; \ + mov r1, sp; \ + swi #SYS_ify(sigaltstack); \ + cmp r0, #0; \ + bne .Lok2; \ + ldr r1, [sp, #4]; \ + tst r1, #1; \ + beq .Lfail; \ + ldr r2, [sp, #0]; \ + ldr r3, [sp, #8]; \ + add r2, r2, r3; \ + sub r2, r2, reg; \ + cmp r2, r3; \ + bhi .Lok2; \ +.Lfail: \ CALL_FAIL \ +.Lok2: \ + mov r0, r5; \ .Lok: #include <__longjmp.S> diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S b/ports/sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S new file mode 100644 index 000000000..f92a382e4 --- /dev/null +++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S @@ -0,0 +1,76 @@ +/* Copyright (C) 2009 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING. If not, write to the Free + Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include <sysdep.h> + + .section .rodata.str1.1,"aMS",%progbits,1 + .type longjmp_msg,%object +longjmp_msg: + .string "longjmp causes uninitialized stack frame" + .size longjmp_msg, .-longjmp_msg + .text + +#define __longjmp ____longjmp_chk + +#ifdef PIC +# define CALL_FAIL \ + ldr sl, .L_GOT; \ +.L_GOT_OFF: \ + add sl, pc, sl; \ + ldr r0, .Lstr; \ + add r0, sl, r0; \ + B PLTJMP(HIDDEN_JUMPTARGET(__fortify_fail)); \ +.L_GOT: \ + .word _GLOBAL_OFFSET_TABLE_-(.L_GOT_OFF+8); \ +.Lstr: \ + .word longjmp_msg(GOTOFF); +#else +# define CALL_FAIL \ + ldr r0, .Lstr; \ + B HIDDEN_JUMPTARGET(__fortify_fail); \ +.Lstr: \ + .word longjmp_msg; +#endif + +#define CHECK_SP(reg) \ + cmp sp, reg; \ + bls .Lok; \ + mov r5, r0; \ + mov r7, #SYS_ify(sigaltstack); \ + mov r0, #0; \ + sub sp, sp, #16; \ + mov r1, sp; \ + swi #0; \ + cmp r0, #0; \ + bne .Lok2; \ + ldr r1, [sp, #4]; \ + tst r1, #1; \ + beq .Lfail; \ + ldr r2, [sp, #0]; \ + ldr r3, [sp, #8]; \ + add r2, r2, r3; \ + sub r2, r2, reg; \ + cmp r2, r3; \ + bhi .Lok2; \ +.Lfail: \ + CALL_FAIL \ +.Lok2: \ + mov r0, r5; \ +.Lok: + +#include <__longjmp.S> diff --git a/ports/sysdeps/mips/____longjmp_chk.c b/ports/sysdeps/unix/sysv/linux/mips/____longjmp_chk.c index a46ed150d..9db339c2b 100644 --- a/ports/sysdeps/mips/____longjmp_chk.c +++ b/ports/sysdeps/unix/sysv/linux/mips/____longjmp_chk.c @@ -16,7 +16,27 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <signal.h> #include <stdio.h> #define __longjmp ____longjmp_chk -#define CHECK_SP +#define CHECK_SP(saved_sp, cur_sp, sp_type) \ + do { \ + sp_type sp_saved = (sp_type) (saved_sp); \ + if (sp_saved < (cur_sp)) \ + { \ + struct __jmp_buf_internal_tag *env_save = env_arg; \ + int val_save = val_arg; \ + stack_t ss; \ + int ret = __sigaltstack (NULL, &ss); \ + if (ret == 0 \ + && (!(ss.ss_flags & SS_ONSTACK) \ + || ((unsigned sp_type) ((sp_type) ss.ss_sp \ + + (sp_type) ss.ss_size \ + - sp_saved) \ + < ss.ss_size))) \ + __fortify_fail ("longjmp causes uninitialized stack frame"); \ + asm volatile ("move %0, %1" : "=r" (env) : "r" (env_save)); \ + asm volatile ("move %0, %1" : "=r" (val) : "r" (val_save)); \ + } \ + } while (0) #include <__longjmp.c> |