1 // The content of this file is x86_64-only:
2 #if defined(__x86_64__)
4 #include "sanitizer_common/sanitizer_asm.h"
6 #if !defined(__APPLE__)
12 ASM_HIDDEN(__tsan_setjmp)
13 #if defined(__NetBSD__)
14 .comm _ZN14__interception15real___setjmp14E,8,8
15 #elif !defined(__APPLE__)
16 .comm _ZN14__interception11real_setjmpE,8,8
18 #if defined(__NetBSD__)
19 .globl ASM_SYMBOL_INTERCEPTOR(__setjmp14)
20 ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__setjmp14))
21 ASM_SYMBOL_INTERCEPTOR(__setjmp14):
23 .globl ASM_SYMBOL_INTERCEPTOR(setjmp)
24 ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
25 ASM_SYMBOL_INTERCEPTOR(setjmp):
31 CFI_ADJUST_CFA_OFFSET(8)
32 CFI_REL_OFFSET(%rdi, 0)
33 // obtain SP, store in %rdi, first argument to `void __tsan_setjmp(uptr sp)`
34 #if defined(__FreeBSD__) || defined(__NetBSD__)
36 #elif defined(__linux__) || defined(__APPLE__)
39 # error "Unknown platform"
41 // call tsan interceptor
42 call ASM_SYMBOL(__tsan_setjmp)
43 // restore env parameter
45 CFI_ADJUST_CFA_OFFSET(-8)
47 // tail jump to libc setjmp
49 #if defined(__NetBSD__)
50 movq _ZN14__interception15real___setjmp14E@GOTPCREL(%rip), %rdx
52 #elif !defined(__APPLE__)
53 movq _ZN14__interception11real_setjmpE@GOTPCREL(%rip), %rdx
56 jmp ASM_SYMBOL(setjmp)
59 #if defined(__NetBSD__)
60 ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__setjmp14))
62 ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
65 .comm _ZN14__interception12real__setjmpE,8,8
66 .globl ASM_SYMBOL_INTERCEPTOR(_setjmp)
67 ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
68 ASM_SYMBOL_INTERCEPTOR(_setjmp):
73 CFI_ADJUST_CFA_OFFSET(8)
74 CFI_REL_OFFSET(%rdi, 0)
75 // obtain SP, store in %rdi, first argument to `void __tsan_setjmp(uptr sp)`
76 #if defined(__FreeBSD__) || defined(__NetBSD__)
78 #elif defined(__linux__) || defined(__APPLE__)
81 # error "Unknown platform"
83 // call tsan interceptor
84 call ASM_SYMBOL(__tsan_setjmp)
85 // restore env parameter
87 CFI_ADJUST_CFA_OFFSET(-8)
89 // tail jump to libc setjmp
91 #if !defined(__APPLE__)
92 movq _ZN14__interception12real__setjmpE@GOTPCREL(%rip), %rdx
95 jmp ASM_SYMBOL(_setjmp)
98 ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(_setjmp))
100 #if defined(__NetBSD__)
101 .comm _ZN14__interception18real___sigsetjmp14E,8,8
102 .globl ASM_SYMBOL_INTERCEPTOR(__sigsetjmp14)
103 ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp14))
104 ASM_SYMBOL_INTERCEPTOR(__sigsetjmp14):
106 .comm _ZN14__interception14real_sigsetjmpE,8,8
107 .globl ASM_SYMBOL_INTERCEPTOR(sigsetjmp)
108 ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
109 ASM_SYMBOL_INTERCEPTOR(sigsetjmp):
113 // save env parameter
115 CFI_ADJUST_CFA_OFFSET(8)
116 CFI_REL_OFFSET(%rdi, 0)
117 // save savesigs parameter
119 CFI_ADJUST_CFA_OFFSET(8)
120 CFI_REL_OFFSET(%rsi, 0)
123 CFI_ADJUST_CFA_OFFSET(8)
124 // obtain SP, store in %rdi, first argument to `void __tsan_setjmp(uptr sp)`
125 #if defined(__FreeBSD__) || defined(__NetBSD__)
127 #elif defined(__linux__) || defined(__APPLE__)
130 # error "Unknown platform"
132 // call tsan interceptor
133 call ASM_SYMBOL(__tsan_setjmp)
134 // unalign stack frame
136 CFI_ADJUST_CFA_OFFSET(-8)
137 // restore savesigs parameter
139 CFI_ADJUST_CFA_OFFSET(-8)
141 // restore env parameter
143 CFI_ADJUST_CFA_OFFSET(-8)
145 // tail jump to libc sigsetjmp
147 #if defined(__NetBSD__)
148 movq _ZN14__interception18real___sigsetjmp14E@GOTPCREL(%rip), %rdx
150 #elif !defined(__APPLE__)
151 movq _ZN14__interception14real_sigsetjmpE@GOTPCREL(%rip), %rdx
154 jmp ASM_SYMBOL(sigsetjmp)
157 #if defined(__NetBSD__)
158 ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp14))
160 ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
163 #if !defined(__APPLE__) && !defined(__NetBSD__)
164 .comm _ZN14__interception16real___sigsetjmpE,8,8
165 .globl ASM_SYMBOL_INTERCEPTOR(__sigsetjmp)
166 ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
167 ASM_SYMBOL_INTERCEPTOR(__sigsetjmp):
170 // save env parameter
172 CFI_ADJUST_CFA_OFFSET(8)
173 CFI_REL_OFFSET(%rdi, 0)
174 // save savesigs parameter
176 CFI_ADJUST_CFA_OFFSET(8)
177 CFI_REL_OFFSET(%rsi, 0)
180 CFI_ADJUST_CFA_OFFSET(8)
181 // obtain SP, store in %rdi, first argument to `void __tsan_setjmp(uptr sp)`
182 #if defined(__FreeBSD__)
187 // call tsan interceptor
188 call ASM_SYMBOL(__tsan_setjmp)
189 // unalign stack frame
191 CFI_ADJUST_CFA_OFFSET(-8)
192 // restore savesigs parameter
194 CFI_ADJUST_CFA_OFFSET(-8)
196 // restore env parameter
198 CFI_ADJUST_CFA_OFFSET(-8)
200 // tail jump to libc sigsetjmp
202 movq _ZN14__interception16real___sigsetjmpE@GOTPCREL(%rip), %rdx
205 ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
206 #endif // !defined(__APPLE__) && !defined(__NetBSD__)
208 NO_EXEC_STACK_DIRECTIVE