Consolidate NPTL vs non clone.S for ARM.
[glibc.git] / sysdeps / unix / sysv / linux / arm / ____longjmp_chk.S
blob96f8b4eb2d6741658d5e85f19bb49f43e2f56ab7
1 /* Copyright (C) 2009-2014 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/>.  */
18 #include <sysdep.h>
20         .section .rodata.str1.1,"aMS",%progbits,1
21         .type   longjmp_msg,%object
22 longjmp_msg:
23         .string "longjmp causes uninitialized stack frame"
24         .size   longjmp_msg, .-longjmp_msg
25         .text
27 #define __longjmp ____longjmp_chk
29 #ifdef PIC
30 # define CALL_FAIL                                              \
31         ldr     sl, .L_GOT;                                     \
32         cfi_undefined (sl);                                     \
33 .L_GOT_OFF:                                                     \
34         add     sl, pc, sl;                                     \
35         ldr     r0, .Lstr;                                      \
36         add     r0, sl, r0;                                     \
37         B       PLTJMP(HIDDEN_JUMPTARGET(__fortify_fail));      \
38 .L_GOT:                                                         \
39         .word   _GLOBAL_OFFSET_TABLE_-(.L_GOT_OFF+8);           \
40 .Lstr:                                                          \
41         .word   longjmp_msg(GOTOFF);
42 #else
43 # define CALL_FAIL                                      \
44         ldr     r0, .Lstr;                              \
45         B       HIDDEN_JUMPTARGET(__fortify_fail);      \
46 .Lstr:                                                  \
47         .word   longjmp_msg;
48 #endif
50 #define CHECK_SP(reg)                           \
51         cfi_remember_state;                     \
52         cmp     sp, reg;                        \
53         bls     .Lok;                           \
54         push    { r7 };                         \
55         cfi_adjust_cfa_offset (4);              \
56         cfi_rel_offset (r7, 0);                 \
57         mov     r5, r0;                         \
58         cfi_undefined (r5);                     \
59         mov     r7, #SYS_ify(sigaltstack);      \
60         mov     r0, #0;                         \
61         sub     sp, sp, #12; /* == sizeof (stack_t) */ \
62         cfi_adjust_cfa_offset (12);             \
63         cfi_remember_state;                     \
64         mov     r1, sp;                         \
65         swi     #0;                             \
66         cmp     r0, #0;                         \
67         bne     .Lok2;                          \
68         ldr     r1, [sp, #4];                   \
69         tst     r1, #1;                         \
70         beq     .Lfail;                         \
71         ldr     r2, [sp, #0];                   \
72         ldr     r3, [sp, #8];                   \
73         add     r2, r2, r3;                     \
74         sub     r2, r2, reg;                    \
75         cmp     r2, r3;                         \
76         bhi     .Lok2;                          \
77 .Lfail:                                         \
78         add     sp, sp, #12;                    \
79         cfi_adjust_cfa_offset (-12);            \
80         pop     { r7 };                         \
81         cfi_adjust_cfa_offset (-4);             \
82         cfi_restore (r7);                       \
83         CALL_FAIL                               \
84         cfi_restore_state;                      \
85 .Lok2:                                          \
86         mov     r0, r5;                         \
87         cfi_restore_state;                      \
88 .Lok:
90 #include <__longjmp.S>