summaryrefslogtreecommitdiff
path: root/ports/sysdeps/unix/sysv/linux
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2009-08-09 14:33:15 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2009-08-09 14:33:15 +0000
commite3665fddce66693f98e3b6127986aac8caa55bf1 (patch)
tree06139cc7f58aa82433d0d803ca628a6da594565c /ports/sysdeps/unix/sysv/linux
parente6ab798eb7a34667bce399a7ef4349adb5d3b085 (diff)
downloadeglibc2-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/unix/sysv/linux')
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/____longjmp_chk.S75
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/____longjmp_chk.S76
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/____longjmp_chk.c42
3 files changed, 193 insertions, 0 deletions
diff --git a/ports/sysdeps/unix/sysv/linux/arm/____longjmp_chk.S b/ports/sysdeps/unix/sysv/linux/arm/____longjmp_chk.S
new file mode 100644
index 000000000..2fa727dcf
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/____longjmp_chk.S
@@ -0,0 +1,75 @@
+/* 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 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/unix/sysv/linux/mips/____longjmp_chk.c b/ports/sysdeps/unix/sysv/linux/mips/____longjmp_chk.c
new file mode 100644
index 000000000..9db339c2b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/____longjmp_chk.c
@@ -0,0 +1,42 @@
+/* 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 Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ 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(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>