1 | /* setjmp for ARM. |
2 | Copyright (C) 1997-2024 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
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. |
9 | |
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. |
14 | |
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 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #include <sysdep.h> |
20 | #include <pointer_guard.h> |
21 | #include <stap-probe.h> |
22 | #include <bits/setjmp.h> |
23 | #include <rtld-global-offsets.h> |
24 | #include <arm-features.h> |
25 | |
26 | ENTRY (__sigsetjmp) |
27 | #ifdef PTR_MANGLE |
28 | PTR_MANGLE_LOAD (a3, ip) |
29 | #endif |
30 | mov ip, r0 |
31 | |
32 | /* setjmp probe expects sigsetjmp first argument (4@r0), second |
33 | argument (-4@r1), and target address (4@r14), respectively. */ |
34 | LIBC_PROBE (setjmp, 3, 4@r0, -4@r1, 4@r14) |
35 | |
36 | /* Save sp and lr */ |
37 | #ifdef PTR_MANGLE |
38 | mov a4, sp |
39 | PTR_MANGLE2 (a4, a4, a3) |
40 | str a4, [ip], #4 |
41 | PTR_MANGLE2 (a4, lr, a3) |
42 | str a4, [ip], #4 |
43 | #else |
44 | str sp, [ip], #4 |
45 | str lr, [ip], #4 |
46 | #endif |
47 | /* Save registers */ |
48 | stmia ip!, JMP_BUF_REGLIST |
49 | |
50 | #if !defined ARM_ASSUME_NO_IWMMXT || defined __SOFTFP__ |
51 | # define NEED_HWCAP 1 |
52 | #endif |
53 | |
54 | #ifdef NEED_HWCAP |
55 | /* Check if we have a VFP unit. */ |
56 | # if IS_IN (rtld) |
57 | LDST_PCREL (ldr, a3, a4, \ |
58 | C_SYMBOL_NAME(_rtld_local_ro) \ |
59 | + RTLD_GLOBAL_RO_DL_HWCAP_OFFSET) |
60 | # else |
61 | # ifdef SHARED |
62 | LDR_GLOBAL (a3, a4, C_SYMBOL_NAME(_rtld_global_ro), \ |
63 | RTLD_GLOBAL_RO_DL_HWCAP_OFFSET) |
64 | # else |
65 | LDR_GLOBAL (a3, a4, C_SYMBOL_NAME(_dl_hwcap), 0) |
66 | # endif |
67 | # endif |
68 | #endif |
69 | |
70 | #ifdef __SOFTFP__ |
71 | tst a3, #HWCAP_ARM_VFP |
72 | beq .Lno_vfp |
73 | #endif |
74 | |
75 | /* Store the VFP registers. |
76 | Don't use VFP instructions directly because this code |
77 | is used in non-VFP multilibs. */ |
78 | /* Following instruction is vstmia ip!, {d8-d15}. */ |
79 | stc p11, cr8, [ip], #64 |
80 | .Lno_vfp: |
81 | |
82 | #ifndef ARM_ASSUME_NO_IWMMXT |
83 | tst a3, #HWCAP_ARM_IWMMXT |
84 | beq .Lno_iwmmxt |
85 | |
86 | /* Save the call-preserved iWMMXt registers. */ |
87 | /* Following instructions are wstrd wr10, [ip], #8 (etc.) */ |
88 | stcl p1, cr10, [r12], #8 |
89 | stcl p1, cr11, [r12], #8 |
90 | stcl p1, cr12, [r12], #8 |
91 | stcl p1, cr13, [r12], #8 |
92 | stcl p1, cr14, [r12], #8 |
93 | stcl p1, cr15, [r12], #8 |
94 | .Lno_iwmmxt: |
95 | #endif |
96 | |
97 | /* Make a tail call to __sigjmp_save; it takes the same args. */ |
98 | B PLTJMP(C_SYMBOL_NAME(__sigjmp_save)) |
99 | |
100 | END (__sigsetjmp) |
101 | |
102 | hidden_def (__sigsetjmp) |
103 | |