1 #include "sanitizer_common/sanitizer_asm.h"
2 .hidden __tsan_trace_switch
3 .globl __tsan_trace_switch_thunk
4 __tsan_trace_switch_thunk:
6 # Save scratch registers.
8 CFI_ADJUST_CFA_OFFSET(8)
9 CFI_REL_OFFSET(%rax, 0)
11 CFI_ADJUST_CFA_OFFSET(8)
12 CFI_REL_OFFSET(%rcx, 0)
14 CFI_ADJUST_CFA_OFFSET(8)
15 CFI_REL_OFFSET(%rdx, 0)
17 CFI_ADJUST_CFA_OFFSET(8)
18 CFI_REL_OFFSET(%rsi, 0)
20 CFI_ADJUST_CFA_OFFSET(8)
21 CFI_REL_OFFSET(%rdi, 0)
23 CFI_ADJUST_CFA_OFFSET(8)
24 CFI_REL_OFFSET(%r8, 0)
26 CFI_ADJUST_CFA_OFFSET(8)
27 CFI_REL_OFFSET(%r9, 0)
29 CFI_ADJUST_CFA_OFFSET(8)
30 CFI_REL_OFFSET(%r10, 0)
32 CFI_ADJUST_CFA_OFFSET(8)
33 CFI_REL_OFFSET(%r11, 0)
35 push %rbx # non-scratch
36 CFI_ADJUST_CFA_OFFSET(8)
37 CFI_REL_OFFSET(%rbx, 0)
38 mov %rsp, %rbx # save current rsp
39 CFI_DEF_CFA_REGISTER(%rbx)
40 shr $4, %rsp # clear 4 lsb, align to 16
43 call __tsan_trace_switch
45 # Unalign stack frame back.
46 mov %rbx, %rsp # restore the original rsp
47 CFI_DEF_CFA_REGISTER(%rsp)
49 CFI_ADJUST_CFA_OFFSET(-8)
50 # Restore scratch registers.
52 CFI_ADJUST_CFA_OFFSET(-8)
54 CFI_ADJUST_CFA_OFFSET(-8)
56 CFI_ADJUST_CFA_OFFSET(-8)
58 CFI_ADJUST_CFA_OFFSET(-8)
60 CFI_ADJUST_CFA_OFFSET(-8)
62 CFI_ADJUST_CFA_OFFSET(-8)
64 CFI_ADJUST_CFA_OFFSET(-8)
66 CFI_ADJUST_CFA_OFFSET(-8)
68 CFI_ADJUST_CFA_OFFSET(-8)
82 .hidden __tsan_report_race
83 .globl __tsan_report_race_thunk
84 __tsan_report_race_thunk:
86 # Save scratch registers.
88 CFI_ADJUST_CFA_OFFSET(8)
89 CFI_REL_OFFSET(%rax, 0)
91 CFI_ADJUST_CFA_OFFSET(8)
92 CFI_REL_OFFSET(%rcx, 0)
94 CFI_ADJUST_CFA_OFFSET(8)
95 CFI_REL_OFFSET(%rdx, 0)
97 CFI_ADJUST_CFA_OFFSET(8)
98 CFI_REL_OFFSET(%rsi, 0)
100 CFI_ADJUST_CFA_OFFSET(8)
101 CFI_REL_OFFSET(%rdi, 0)
103 CFI_ADJUST_CFA_OFFSET(8)
104 CFI_REL_OFFSET(%r8, 0)
106 CFI_ADJUST_CFA_OFFSET(8)
107 CFI_REL_OFFSET(%r9, 0)
109 CFI_ADJUST_CFA_OFFSET(8)
110 CFI_REL_OFFSET(%r10, 0)
112 CFI_ADJUST_CFA_OFFSET(8)
113 CFI_REL_OFFSET(%r11, 0)
115 push %rbx # non-scratch
116 CFI_ADJUST_CFA_OFFSET(8)
117 CFI_REL_OFFSET(%rbx, 0)
118 mov %rsp, %rbx # save current rsp
119 CFI_DEF_CFA_REGISTER(%rbx)
120 shr $4, %rsp # clear 4 lsb, align to 16
123 call __tsan_report_race
125 # Unalign stack frame back.
126 mov %rbx, %rsp # restore the original rsp
127 CFI_DEF_CFA_REGISTER(%rsp)
129 CFI_ADJUST_CFA_OFFSET(-8)
130 # Restore scratch registers.
132 CFI_ADJUST_CFA_OFFSET(-8)
134 CFI_ADJUST_CFA_OFFSET(-8)
136 CFI_ADJUST_CFA_OFFSET(-8)
138 CFI_ADJUST_CFA_OFFSET(-8)
140 CFI_ADJUST_CFA_OFFSET(-8)
142 CFI_ADJUST_CFA_OFFSET(-8)
144 CFI_ADJUST_CFA_OFFSET(-8)
146 CFI_ADJUST_CFA_OFFSET(-8)
148 CFI_ADJUST_CFA_OFFSET(-8)
162 .hidden __tsan_setjmp
163 .comm _ZN14__interception11real_setjmpE,8,8
165 .type setjmp, @function
168 // save env parameter
170 CFI_ADJUST_CFA_OFFSET(8)
171 CFI_REL_OFFSET(%rdi, 0)
175 xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
177 // call tsan interceptor
179 // restore env parameter
181 CFI_ADJUST_CFA_OFFSET(-8)
183 // tail jump to libc setjmp
185 movq _ZN14__interception11real_setjmpE@GOTPCREL(%rip), %rdx
188 .size setjmp, .-setjmp
190 .comm _ZN14__interception12real__setjmpE,8,8
192 .type _setjmp, @function
195 // save env parameter
197 CFI_ADJUST_CFA_OFFSET(8)
198 CFI_REL_OFFSET(%rdi, 0)
202 xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
204 // call tsan interceptor
206 // restore env parameter
208 CFI_ADJUST_CFA_OFFSET(-8)
210 // tail jump to libc setjmp
212 movq _ZN14__interception12real__setjmpE@GOTPCREL(%rip), %rdx
215 .size _setjmp, .-_setjmp
217 .comm _ZN14__interception14real_sigsetjmpE,8,8
219 .type sigsetjmp, @function
222 // save env parameter
224 CFI_ADJUST_CFA_OFFSET(8)
225 CFI_REL_OFFSET(%rdi, 0)
226 // save savesigs parameter
228 CFI_ADJUST_CFA_OFFSET(8)
229 CFI_REL_OFFSET(%rsi, 0)
232 CFI_ADJUST_CFA_OFFSET(8)
236 xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
238 // call tsan interceptor
240 // unalign stack frame
242 CFI_ADJUST_CFA_OFFSET(-8)
243 // restore savesigs parameter
245 CFI_ADJUST_CFA_OFFSET(-8)
247 // restore env parameter
249 CFI_ADJUST_CFA_OFFSET(-8)
251 // tail jump to libc sigsetjmp
253 movq _ZN14__interception14real_sigsetjmpE@GOTPCREL(%rip), %rdx
256 .size sigsetjmp, .-sigsetjmp
258 .comm _ZN14__interception16real___sigsetjmpE,8,8
260 .type __sigsetjmp, @function
263 // save env parameter
265 CFI_ADJUST_CFA_OFFSET(8)
266 CFI_REL_OFFSET(%rdi, 0)
267 // save savesigs parameter
269 CFI_ADJUST_CFA_OFFSET(8)
270 CFI_REL_OFFSET(%rsi, 0)
273 CFI_ADJUST_CFA_OFFSET(8)
277 xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
279 // call tsan interceptor
281 // unalign stack frame
283 CFI_ADJUST_CFA_OFFSET(-8)
284 // restore savesigs parameter
286 CFI_ADJUST_CFA_OFFSET(-8)
288 // restore env parameter
290 CFI_ADJUST_CFA_OFFSET(-8)
292 // tail jump to libc sigsetjmp
294 movq _ZN14__interception16real___sigsetjmpE@GOTPCREL(%rip), %rdx
297 .size __sigsetjmp, .-__sigsetjmp
300 /* We do not need executable stack. */
301 .section .note.GNU-stack,"",@progbits