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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #include <jmpbuf-offsets.h>
22 #define ENV(base,reg) [%base + (reg * 4)]
23 #define ST_FLUSH_WINDOWS 3
24 #define RW_FP [%fp + 0x48]
26 .section .rodata.str1.1,"aMS",@progbits,1
27 .type longjmp_msg,@object
29 .string "longjmp causes uninitialized stack frame"
30 .size longjmp_msg, .-longjmp_msg
33 ENTRY (____longjmp_chk)
36 PTR_DEMANGLE (%g5, %g5, %g4)
45 cfi_def_cfa_register(%fp)
47 cfi_register(%o7, %i7)
51 LOADSYSCALL(sigaltstack)
54 ld [%sp + 64 + 4], %o2
57 ld [%sp + 64 + 0], %o0
59 ld [%sp + 64 + 8], %o1
69 sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
70 2: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
73 sethi %hi(longjmp_msg), %o0
74 or %o0, %lo(longjmp_msg), %o0
78 call HIDDEN_JUMPTARGET(__fortify_fail)
86 ld ENV(o0,JB_FP), %g3 /* Cache target FP in register %g3. */
88 PTR_DEMANGLE2 (%g3, %g3, %g4)
91 mov %o0, %g1 /* ENV in %g1 */
92 orcc %o1, %g0, %g2 /* VAL in %g2 */
93 be,a 0f /* Branch if zero; else skip delay slot. */
94 mov 1, %g2 /* Delay slot only hit if zero: VAL = 1. */
98 * Do a "flush register windows trap". The trap handler in the
99 * kernel writes all the register windows to their stack slots, and
100 * marks them all as invalid (needing to be sucked up from the
101 * stack when used). This ensures that all information needed to
102 * unwind to these callers is in memory, not in the register
107 ld ENV(g1,JB_PC), %g1 /* Set return PC. */
108 PTR_DEMANGLE2 (%o7, %g1, %g4)
110 ld ENV(g1,JB_PC), %o7 /* Set return PC. */
113 sub %fp, 64, %sp /* Allocate a register frame. */
114 st %g3, RW_FP /* Set saved FP on restore below. */
116 restore %g2, 0, %o0 /* Restore values from above register frame. */