aboutsummaryrefslogtreecommitdiff
path: root/REORG.TODO/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /REORG.TODO/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.gz
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.bz2
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.zip
Prepare for radical source tree reorganization.zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage directory, REORG.TODO, except for files that will certainly still exist in their current form at top level when we're done (COPYING, COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which are moved to the new directory OldChangeLogs, instead), and the generated file INSTALL (which is just deleted; in the new order, there will be no generated files checked into version control).
Diffstat (limited to 'REORG.TODO/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S')
-rw-r--r--REORG.TODO/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S144
1 files changed, 144 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S b/REORG.TODO/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S
new file mode 100644
index 0000000000..b3063e59ed
--- /dev/null
+++ b/REORG.TODO/sysdeps/unix/sysv/linux/alpha/____longjmp_chk.S
@@ -0,0 +1,144 @@
+/* Copyright (C) 1992-2017 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <jmpbuf-offsets.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
+
+
+/* Jump to the position specified by ENV, causing the
+ setjmp call there to return VAL, or 1 if VAL is 0.
+ void __longjmp (__jmp_buf env, int val). */
+ .text
+ .align 4
+ .globl ____longjmp_chk
+ .type ____longjmp_chk, @function
+ .usepv ____longjmp_chk, std
+
+ cfi_startproc
+____longjmp_chk:
+ ldgp gp, 0(pv)
+#ifdef PROF
+ .set noat
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .set at
+#endif
+
+ ldq s2, JB_PC*8(a0)
+ mov a0, s0
+ ldq fp, JB_FP*8(a0)
+ mov a1, s1
+ ldq s3, JB_SP*8(a0)
+ cmoveq s1, 1, s1
+
+#ifdef PTR_DEMANGLE
+ PTR_DEMANGLE(s2, t1)
+ PTR_DEMANGLE2(s3, t1)
+ PTR_DEMANGLE2(fp, t1)
+#endif
+ /* ??? While this is a proper test for detecting a longjmp to an
+ invalid frame within any given stack, the main thread stack is
+ located *below* almost everything in the address space. Which
+ means that the test at Lfail vs the signal stack will almost
+ certainly never pass. We ought bounds check top and bottom of
+ the current thread's stack. */
+ cmpule s3, sp, t1
+ bne t1, $Lfail
+
+ .align 4
+$Lok:
+ mov s0, a0
+ mov s1, v0
+ mov s3, t0
+ mov s2, ra
+ cfi_remember_state
+ cfi_def_cfa(a0, 0)
+ cfi_register(sp, t0)
+ cfi_offset(s0, JB_S0*8)
+ cfi_offset(s1, JB_S1*8)
+ cfi_offset(s2, JB_S2*8)
+ cfi_offset(s3, JB_S3*8)
+ cfi_offset(s4, JB_S4*8)
+ cfi_offset(s5, JB_S5*8)
+ cfi_offset(s3, JB_S3*8)
+ cfi_offset($f2, JB_F2*8)
+ cfi_offset($f3, JB_F3*8)
+ cfi_offset($f4, JB_F4*8)
+ cfi_offset($f5, JB_F5*8)
+ cfi_offset($f6, JB_F6*8)
+ cfi_offset($f7, JB_F7*8)
+ cfi_offset($f8, JB_F8*8)
+ cfi_offset($f9, JB_F9*8)
+ ldq s0, JB_S0*8(a0)
+ ldq s1, JB_S1*8(a0)
+ ldq s2, JB_S2*8(a0)
+ ldq s3, JB_S3*8(a0)
+ ldq s4, JB_S4*8(a0)
+ ldq s5, JB_S5*8(a0)
+ ldt $f2, JB_F2*8(a0)
+ ldt $f3, JB_F3*8(a0)
+ ldt $f4, JB_F4*8(a0)
+ ldt $f5, JB_F5*8(a0)
+ ldt $f6, JB_F6*8(a0)
+ ldt $f7, JB_F7*8(a0)
+ ldt $f8, JB_F8*8(a0)
+ ldt $f9, JB_F9*8(a0)
+ mov t0, sp
+ ret
+
+ .align 4
+$Lfail:
+ cfi_restore_state
+ lda v0, __NR_sigaltstack
+ lda a0, 0
+ lda a1, -32(sp)
+ lda sp, -32(sp)
+ cfi_adjust_cfa_offset(32)
+ callsys
+ ldq t0, 0(sp) /* ss_sp */
+ ldl t1, 8(sp) /* ss_flags */
+ ldq t2, 16(sp) /* ss_size */
+ lda sp, 32(sp)
+ cfi_adjust_cfa_offset(-32)
+
+ /* Without working sigaltstack we cannot perform the test. */
+ bne a3, $Lok
+
+ addq t0, t2, t0 /* t0 = ss_sp + ss_size */
+ subq t0, s3, t0 /* t0 = (ss_sp + ss_size) - new_sp */
+ cmpule t2, t0, t0 /* t0 = (t0 >= ss_size) */
+ and t0, t1, t0 /* t0 = (t0 >= ss_size) & (ss_flags & SS_ONSTACK) */
+ bne t0, $Lok
+
+ ldah a0, longjmp_msg(gp) !gprelhigh
+ lda a0, longjmp_msg(a0) !gprellow
+#ifdef PIC
+ jsr ra, HIDDEN_JUMPTARGET(__fortify_fail)
+#else
+ bsr ra, HIDDEN_JUMPTARGET(__fortify_fail) !samegp
+#endif
+ bugchk
+
+ cfi_endproc
+ .size ____longjmp_chk, .-____longjmp_chk