1 /* Copyright (C) 1992-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
19 #include <jmpbuf-offsets.h>
22 .section .rodata.str1.1,"aMS",@progbits,1
23 .type longjmp_msg,@object
25 .string "longjmp causes uninitialized stack frame"
26 .size longjmp_msg, .-longjmp_msg
29 /* Jump to the position specified by ENV, causing the
30 setjmp call there to return VAL, or 1 if VAL is 0.
31 void __longjmp (__jmp_buf env, int val). */
34 .globl ____longjmp_chk
35 .type ____longjmp_chk, @function
36 .usepv ____longjmp_chk, std
60 /* ??? While this is a proper test for detecting a longjmp to an
61 invalid frame within any given stack, the main thread stack is
62 located *below* almost everything in the address space. Which
63 means that the test at Lfail vs the signal stack will almost
64 certainly never pass. We ought bounds check top and bottom of
65 the current thread's stack. */
78 cfi_offset(s0, JB_S0*8)
79 cfi_offset(s1, JB_S1*8)
80 cfi_offset(s2, JB_S2*8)
81 cfi_offset(s3, JB_S3*8)
82 cfi_offset(s4, JB_S4*8)
83 cfi_offset(s5, JB_S5*8)
84 cfi_offset(s3, JB_S3*8)
85 cfi_offset($f2, JB_F2*8)
86 cfi_offset($f3, JB_F3*8)
87 cfi_offset($f4, JB_F4*8)
88 cfi_offset($f5, JB_F5*8)
89 cfi_offset($f6, JB_F6*8)
90 cfi_offset($f7, JB_F7*8)
91 cfi_offset($f8, JB_F8*8)
92 cfi_offset($f9, JB_F9*8)
113 lda v0, __NR_sigaltstack
117 cfi_adjust_cfa_offset(32)
119 ldq t0, 0(sp) /* ss_sp */
120 ldl t1, 8(sp) /* ss_flags */
121 ldq t2, 16(sp) /* ss_size */
123 cfi_adjust_cfa_offset(-32)
125 /* Without working sigaltstack we cannot perform the test. */
128 addq t0, t2, t0 /* t0 = ss_sp + ss_size */
129 subq t0, s3, t0 /* t0 = (ss_sp + ss_size) - new_sp */
130 cmpule t2, t0, t0 /* t0 = (t0 >= ss_size) */
131 and t0, t1, t0 /* t0 = (t0 >= ss_size) & (ss_flags & SS_ONSTACK) */
134 ldah a0, longjmp_msg(gp) !gprelhigh
135 lda a0, longjmp_msg(a0) !gprellow
137 jsr ra, HIDDEN_JUMPTARGET(__fortify_fail)
139 bsr ra, HIDDEN_JUMPTARGET(__fortify_fail) !samegp
144 .size ____longjmp_chk, .-____longjmp_chk