1 /* Copyright (C) 2009 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>
21 #define ENV(base,reg) [%base + (reg * 4)]
22 #define ST_FLUSH_WINDOWS 3
23 #define RW_FP [%fp + 0x48]
25 .section .rodata.str1.1,"aMS",@progbits,1
26 .type longjmp_msg,@object
28 .string "longjmp causes uninitialized stack frame"
29 .size longjmp_msg, .-longjmp_msg
32 ENTRY (____longjmp_chk)
35 PTR_DEMANGLE (%g5, %g5, %g4)
44 cfi_def_cfa_register(%fp)
46 cfi_register(%o7, %i7)
50 LOADSYSCALL(sigaltstack)
53 ld [%sp + 64 + 4], %o2
56 ld [%sp + 64 + 0], %o0
58 ld [%sp + 64 + 8], %o1
68 sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
69 2: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
72 sethi %hi(longjmp_msg), %o0
73 or %o0, %lo(longjmp_msg), %o0
77 call HIDDEN_JUMPTARGET(__fortify_fail)
85 ld ENV(o0,JB_FP), %g3 /* Cache target FP in register %g3. */
87 PTR_DEMANGLE2 (%g3, %g3, %g4)
90 mov %o0, %g1 /* ENV in %g1 */
91 orcc %o1, %g0, %g2 /* VAL in %g2 */
92 be,a 0f /* Branch if zero; else skip delay slot. */
93 mov 1, %g2 /* Delay slot only hit if zero: VAL = 1. */
97 * Do a "flush register windows trap". The trap handler in the
98 * kernel writes all the register windows to their stack slots, and
99 * marks them all as invalid (needing to be sucked up from the
100 * stack when used). This ensures that all information needed to
101 * unwind to these callers is in memory, not in the register
106 ld ENV(g1,JB_PC), %g1 /* Set return PC. */
107 PTR_DEMANGLE2 (%o7, %g1, %g4)
109 ld ENV(g1,JB_PC), %o7 /* Set return PC. */
112 sub %fp, 64, %sp /* Allocate a register frame. */
113 st %g3, RW_FP /* Set saved FP on restore below. */
115 restore %g2, 0, %o0 /* Restore values from above register frame. */