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