1#include "sanitizer_common/sanitizer_asm.h"
2
3.section .text
4
5.comm _ZN14__interception11real_setjmpE,8,8
6.globl ASM_SYMBOL_INTERCEPTOR(setjmp)
7ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
8ASM_SYMBOL_INTERCEPTOR(setjmp):
9 CFI_STARTPROC
10
11 // Save frame pointer and return address register
12 addi sp, sp, -32
13 sd ra, 24(sp)
14 sd s0, 16(sp)
15 CFI_DEF_CFA_OFFSET (32)
16 CFI_OFFSET (1, -8)
17 CFI_OFFSET (8, -16)
18
19 // Adjust the SP for previous frame
20 addi s0, sp, 32
21 CFI_DEF_CFA_REGISTER (8)
22
23 // Save env parameter
24 sd a0, 8(sp)
25 CFI_OFFSET (10, -24)
26
27 // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
28 addi a0, s0, 0
29
30 // call tsan interceptor
31 call ASM_SYMBOL(__tsan_setjmp)
32
33 // Restore env parameter
34 ld a0, 8(sp)
35 CFI_RESTORE (10)
36
37 // Restore frame/link register
38 ld s0, 16(sp)
39 ld ra, 24(sp)
40 addi sp, sp, 32
41 CFI_RESTORE (8)
42 CFI_RESTORE (1)
43 CFI_DEF_CFA (2, 0)
44
45 // tail jump to libc setjmp
46 la t1, _ZN14__interception11real_setjmpE
47 ld t1, 0(t1)
48 jr t1
49
50 CFI_ENDPROC
51ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
52
53.comm _ZN14__interception12real__setjmpE,8,8
54.globl ASM_SYMBOL_INTERCEPTOR(_setjmp)
55ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
56ASM_SYMBOL_INTERCEPTOR(_setjmp):
57 CFI_STARTPROC
58
59 // Save frame pointer and return address register
60 addi sp, sp, -32
61 sd ra, 24(sp)
62 sd s0, 16(sp)
63 CFI_DEF_CFA_OFFSET (32)
64 CFI_OFFSET (1, -8)
65 CFI_OFFSET (8, -16)
66
67 // Adjust the SP for previous frame
68 addi s0, sp, 32
69 CFI_DEF_CFA_REGISTER (8)
70
71 // Save env parameter
72 sd a0, 8(sp)
73 CFI_OFFSET (10, -24)
74
75 // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
76 addi a0, s0, 0
77
78 // call tsan interceptor
79 call ASM_SYMBOL(__tsan_setjmp)
80
81 // Restore env parameter
82 ld a0, 8(sp)
83 CFI_RESTORE (10)
84
85 // Restore frame/link register
86 ld s0, 16(sp)
87 ld ra, 24(sp)
88 addi sp, sp, 32
89 CFI_RESTORE (8)
90 CFI_RESTORE (1)
91 CFI_DEF_CFA (2, 0)
92
93 // tail jump to libc setjmp
94 la t1, _ZN14__interception12real__setjmpE
95 ld t1, 0(t1)
96 jr t1
97
98 CFI_ENDPROC
99ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(_setjmp))
100
101.comm _ZN14__interception14real_sigsetjmpE,8,8
102.globl ASM_SYMBOL_INTERCEPTOR(sigsetjmp)
103ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
104ASM_SYMBOL_INTERCEPTOR(sigsetjmp):
105 CFI_STARTPROC
106
107 // Save frame pointer and return address register
108 addi sp, sp, -32
109 sd ra, 24(sp)
110 sd s0, 16(sp)
111 CFI_DEF_CFA_OFFSET (32)
112 CFI_OFFSET (1, -8)
113 CFI_OFFSET (8, -16)
114
115 // Adjust the SP for previous frame
116 addi s0, sp, 32
117 CFI_DEF_CFA_REGISTER (8)
118
119 // Save env parameter
120 sd a0, 8(sp)
121 sd a1, 0(sp)
122 CFI_OFFSET (10, -24)
123 CFI_OFFSET (11, -32)
124
125 // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
126 addi a0, s0, 0
127
128 // call tsan interceptor
129 call ASM_SYMBOL(__tsan_setjmp)
130
131 // Restore env parameter
132 ld a0, 8(sp)
133 ld a1, 0(sp)
134 CFI_RESTORE (10)
135 CFI_RESTORE (11)
136
137 // Restore frame/link register
138 ld s0, 16(sp)
139 ld ra, 24(sp)
140 addi sp, sp, 32
141 CFI_RESTORE (8)
142 CFI_RESTORE (1)
143 CFI_DEF_CFA (2, 0)
144
145 // tail jump to libc setjmp
146 la t1, _ZN14__interception14real_sigsetjmpE
147 ld t1, 0(t1)
148 jr t1
149
150 CFI_ENDPROC
151ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
152
153.comm _ZN14__interception16real___sigsetjmpE,8,8
154.globl ASM_SYMBOL_INTERCEPTOR(__sigsetjmp)
155ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
156ASM_SYMBOL_INTERCEPTOR(__sigsetjmp):
157 CFI_STARTPROC
158
159 // Save frame pointer and return address register
160 addi sp, sp, -32
161 sd ra, 24(sp)
162 sd s0, 16(sp)
163 CFI_DEF_CFA_OFFSET (32)
164 CFI_OFFSET (1, -8)
165 CFI_OFFSET (8, -16)
166
167 // Adjust the SP for previous frame
168 addi s0, sp, 32
169 CFI_DEF_CFA_REGISTER (8)
170
171 // Save env parameter
172 sd a0, 8(sp)
173 sd a1, 0(sp)
174 CFI_OFFSET (10, -24)
175 CFI_OFFSET (11, -32)
176
177 // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
178 addi a0, s0, 0
179
180 // call tsan interceptor
181 call ASM_SYMBOL(__tsan_setjmp)
182
183 // Restore env parameter
184 ld a0, 8(sp)
185 ld a1, 0(sp)
186 CFI_RESTORE (10)
187 CFI_RESTORE (11)
188
189 // Restore frame/link register
190 ld s0, 16(sp)
191 ld ra, 24(sp)
192 addi sp, sp, 32
193 CFI_RESTORE (8)
194 CFI_RESTORE (1)
195 CFI_DEF_CFA (2, 0)
196
197 // tail jump to libc setjmp
198 la t1, _ZN14__interception16real___sigsetjmpE
199 ld t1, 0(t1)
200 jr t1
201
202 CFI_ENDPROC
203ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
204

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