1// The content of this file is AArch64-only:
2#if defined(__aarch64__)
3
4#include "sanitizer_common/sanitizer_asm.h"
5
6#if !defined(__APPLE__)
7.section .text
8#else
9.section __TEXT,__text
10.align 3
11#endif
12
13ASM_HIDDEN(__tsan_setjmp)
14.comm _ZN14__interception11real_setjmpE,8,8
15.globl ASM_SYMBOL_INTERCEPTOR(setjmp)
16ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
17ASM_SYMBOL_INTERCEPTOR(setjmp):
18 CFI_STARTPROC
19
20 // Save frame/link register
21 stp x29, x30, [sp, -32]!
22 CFI_DEF_CFA_OFFSET (32)
23 CFI_OFFSET (29, -32)
24 CFI_OFFSET (30, -24)
25
26 // Adjust the SP for previous frame
27 add x29, sp, 0
28 CFI_DEF_CFA_REGISTER (29)
29
30 // Save env parameter
31 str x0, [sp, 16]
32 CFI_OFFSET (0, -16)
33
34 // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
35 add x0, x29, 32
36
37 // call tsan interceptor
38 bl ASM_SYMBOL(__tsan_setjmp)
39
40 // Restore env parameter
41 ldr x0, [sp, 16]
42 CFI_RESTORE (0)
43
44 // Restore frame/link register
45 ldp x29, x30, [sp], 32
46 CFI_RESTORE (29)
47 CFI_RESTORE (30)
48 CFI_DEF_CFA (31, 0)
49
50 // tail jump to libc setjmp
51#if !defined(__APPLE__)
52 adrp x1, :got:_ZN14__interception11real_setjmpE
53 ldr x1, [x1, #:got_lo12:_ZN14__interception11real_setjmpE]
54 ldr x1, [x1]
55#else
56 adrp x1, _setjmp@GOTPAGE
57 ldr x1, [x1, _setjmp@GOTPAGEOFF]
58#endif
59 br x1
60
61 CFI_ENDPROC
62ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
63
64.comm _ZN14__interception12real__setjmpE,8,8
65.globl ASM_SYMBOL_INTERCEPTOR(_setjmp)
66ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
67ASM_SYMBOL_INTERCEPTOR(_setjmp):
68 CFI_STARTPROC
69
70 // Save frame/link register
71 stp x29, x30, [sp, -32]!
72 CFI_DEF_CFA_OFFSET (32)
73 CFI_OFFSET (29, -32)
74 CFI_OFFSET (30, -24)
75
76 // Adjust the SP for previous frame
77 add x29, sp, 0
78 CFI_DEF_CFA_REGISTER (29)
79
80 // Save env parameter
81 str x0, [sp, 16]
82 CFI_OFFSET (0, -16)
83
84 // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
85 add x0, x29, 32
86
87 // call tsan interceptor
88 bl ASM_SYMBOL(__tsan_setjmp)
89
90 // Restore env parameter
91 ldr x0, [sp, 16]
92 CFI_RESTORE (0)
93
94 // Restore frame/link register
95 ldp x29, x30, [sp], 32
96 CFI_RESTORE (29)
97 CFI_RESTORE (30)
98 CFI_DEF_CFA (31, 0)
99
100 // tail jump to libc setjmp
101#if !defined(__APPLE__)
102 adrp x1, :got:_ZN14__interception12real__setjmpE
103 ldr x1, [x1, #:got_lo12:_ZN14__interception12real__setjmpE]
104 ldr x1, [x1]
105#else
106 adrp x1, __setjmp@GOTPAGE
107 ldr x1, [x1, __setjmp@GOTPAGEOFF]
108#endif
109 br x1
110
111 CFI_ENDPROC
112ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(_setjmp))
113
114.comm _ZN14__interception14real_sigsetjmpE,8,8
115.globl ASM_SYMBOL_INTERCEPTOR(sigsetjmp)
116ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
117ASM_SYMBOL_INTERCEPTOR(sigsetjmp):
118 CFI_STARTPROC
119
120 // Save frame/link register
121 stp x29, x30, [sp, -32]!
122 CFI_DEF_CFA_OFFSET (32)
123 CFI_OFFSET (29, -32)
124 CFI_OFFSET (30, -24)
125
126 // Adjust the SP for previous frame
127 add x29, sp, 0
128 CFI_DEF_CFA_REGISTER (29)
129
130 // Save env and savesigs parameter
131 stp x0, x1, [sp, 16]
132 CFI_OFFSET (0, -16)
133 CFI_OFFSET (1, -8)
134
135 // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
136 add x0, x29, 32
137
138 // call tsan interceptor
139 bl ASM_SYMBOL(__tsan_setjmp)
140
141 // Restore env and savesigs parameter
142 ldp x0, x1, [sp, 16]
143 CFI_RESTORE (0)
144 CFI_RESTORE (1)
145
146 // Restore frame/link register
147 ldp x29, x30, [sp], 32
148 CFI_RESTORE (29)
149 CFI_RESTORE (30)
150 CFI_DEF_CFA (31, 0)
151
152 // tail jump to libc sigsetjmp
153#if !defined(__APPLE__)
154 adrp x2, :got:_ZN14__interception14real_sigsetjmpE
155 ldr x2, [x2, #:got_lo12:_ZN14__interception14real_sigsetjmpE]
156 ldr x2, [x2]
157#else
158 adrp x2, _sigsetjmp@GOTPAGE
159 ldr x2, [x2, _sigsetjmp@GOTPAGEOFF]
160#endif
161 br x2
162 CFI_ENDPROC
163ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
164
165#if !defined(__APPLE__)
166.comm _ZN14__interception16real___sigsetjmpE,8,8
167.globl ASM_SYMBOL_INTERCEPTOR(__sigsetjmp)
168ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
169ASM_SYMBOL_INTERCEPTOR(__sigsetjmp):
170 CFI_STARTPROC
171
172 // Save frame/link register
173 stp x29, x30, [sp, -32]!
174 CFI_DEF_CFA_OFFSET (32)
175 CFI_OFFSET (29, -32)
176 CFI_OFFSET (30, -24)
177
178 // Adjust the SP for previous frame
179 add x29, sp, 0
180 CFI_DEF_CFA_REGISTER (29)
181
182 // Save env and savesigs parameter
183 stp x0, x1, [sp, 16]
184 CFI_OFFSET (0, -16)
185 CFI_OFFSET (1, -8)
186
187 // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
188 add x0, x29, 32
189
190 // call tsan interceptor
191 bl ASM_SYMBOL(__tsan_setjmp)
192
193 // Restore env and savesigs parameter
194 ldp x0, x1, [sp, 16]
195 CFI_RESTORE (0)
196 CFI_RESTORE (1)
197
198 // Restore frame/link register
199 ldp x29, x30, [sp], 32
200 CFI_RESTORE (29)
201 CFI_RESTORE (30)
202 CFI_DEF_CFA (31, 0)
203
204 // tail jump to libc __sigsetjmp
205#if !defined(__APPLE__)
206 adrp x2, :got:_ZN14__interception16real___sigsetjmpE
207 ldr x2, [x2, #:got_lo12:_ZN14__interception16real___sigsetjmpE]
208 ldr x2, [x2]
209#else
210 adrp x2, ASM_SYMBOL(__sigsetjmp)@page
211 add x2, x2, ASM_SYMBOL(__sigsetjmp)@pageoff
212#endif
213 br x2
214 CFI_ENDPROC
215ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
216#endif
217
218NO_EXEC_STACK_DIRECTIVE
219
220#endif
221

source code of compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S