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

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