Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / arm / __longjmp.S
blob1503923aaaae068d3787dcffdbab725b11ae6396
1 /* longjmp for ARM.
2    Copyright (C) 1997-2014 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library.  If not, see
17    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
20 #include <bits/setjmp.h>
21 #include <rtld-global-offsets.h>
22 #include <arm-features.h>
24 /* __longjmp(jmpbuf, val) */
26 ENTRY (__longjmp)
27         mov     ip, r0
28         movs    r0, r1          /* get the return value in place */
29         it      eq
30         moveq   r0, #1          /* can't let setjmp() return zero! */
32 #ifdef CHECK_SP
33         sfi_breg ip, \
34         ldr     r4, [\B, #32]   /* jmpbuf's sp */
35         cfi_undefined (r4)
36 #ifdef PTR_DEMANGLE
37         PTR_DEMANGLE (r4, r4, a3, a4)
38 #endif
39         CHECK_SP (r4)
40 #endif
41         sfi_sp sfi_breg ip, \
42         ldmia   \B!, JMP_BUF_REGLIST
43 #ifdef PTR_DEMANGLE
44         PTR_DEMANGLE (fp, a4, a3, a2)
45         ldr     a4, [ip], #4
46         PTR_DEMANGLE2 (a4, a4, a3)
47         mov     sp, a4
48         ldr     a4, [ip], #4
49         PTR_DEMANGLE2 (lr, a4, a3)
50 #else
51         mov     fp, a4
52         ldr     sp, [ip], #4
53         ldr     lr, [ip], #4
54 #endif
55         cfi_restore (v1)
56         cfi_restore (v2)
57         cfi_restore (v3)
58         cfi_restore (v4)
59         cfi_restore (v5)
60         cfi_restore (v6)
61         cfi_restore (sl)
62         cfi_restore (fp)
63         cfi_restore (sp)
64         cfi_restore (lr)
66 #if !defined ARM_ASSUME_NO_IWMMXT || defined __SOFTFP__
67 # define NEED_HWCAP 1
68 #endif
70 #ifdef NEED_HWCAP
71 # ifdef IS_IN_rtld
72         ldr     a2, 1f
73         ldr     a3, .Lrtld_local_ro
74 0:      add     a2, pc, a2
75         add     a2, a2, a3
76         ldr     a2, [a2, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
77 # else
78 #  ifdef PIC
79         ldr     a2, 1f
80         ldr     a3, .Lrtld_global_ro
81 0:      add     a2, pc, a2
82         ldr     a2, [a2, a3]
83         ldr     a2, [a2, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
84 #  else
85         ldr     a2, .Lhwcap
86         ldr     a2, [a2, #0]
87 #  endif
88 # endif
89 #endif
91 #ifdef __SOFTFP__
92         tst     a2, #HWCAP_ARM_VFP
93         beq     .Lno_vfp
94 #endif
96         /* Restore the VFP registers.  */
97         /* Following instruction is vldmia ip!, {d8-d15}.  */
98         sfi_breg r12, \
99         ldc     p11, cr8, [\B], #64
100 .Lno_vfp:
102 #ifndef ARM_ASSUME_NO_IWMMXT
103         tst     a2, #HWCAP_ARM_IWMMXT
104         beq     .Lno_iwmmxt
106         /* Restore the call-preserved iWMMXt registers.  */
107         /* Following instructions are wldrd wr10, [ip], #8 (etc.)  */
108         sfi_breg r12, \
109         ldcl    p1, cr10, [\B], #8
110         sfi_breg r12, \
111         ldcl    p1, cr11, [\B], #8
112         sfi_breg r12, \
113         ldcl    p1, cr12, [\B], #8
114         sfi_breg r12, \
115         ldcl    p1, cr13, [\B], #8
116         sfi_breg r12, \
117         ldcl    p1, cr14, [\B], #8
118         sfi_breg r12, \
119         ldcl    p1, cr15, [\B], #8
120 .Lno_iwmmxt:
121 #endif
123         DO_RET(lr)
125 #ifdef NEED_HWCAP
126 # ifdef IS_IN_rtld
127 1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
128 .Lrtld_local_ro:
129         .long   C_SYMBOL_NAME(_rtld_local_ro)(GOTOFF)
130 # else
131 #  ifdef PIC
132 1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
133 .Lrtld_global_ro:
134         .long   C_SYMBOL_NAME(_rtld_global_ro)(GOT)
135 #  else
136 .Lhwcap:
137         .long   C_SYMBOL_NAME(_dl_hwcap)
138 #  endif
139 # endif
140 #endif
142 END (__longjmp)