aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/clang16-rt/lib/tsan/rtl/tsan_rtl_mips64.S
blob: d0f7a3f9af9890799d061ffb41176227ebd44c6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
.section .text
.set noreorder

.hidden __tsan_setjmp
.comm _ZN14__interception11real_setjmpE,8,8
.globl setjmp
.type setjmp, @function
setjmp:

  // save env parameters
  daddiu $sp,$sp,-40
  sd $s0,32($sp)
  sd $ra,24($sp)
  sd $fp,16($sp)
  sd $gp,8($sp)

  // calculate and save pointer to GOT
  lui $gp,%hi(%neg(%gp_rel(setjmp)))
  daddu $gp,$gp,$t9
  daddiu $gp,$gp,%lo(%neg(%gp_rel(setjmp)))
  move $s0,$gp

  // save jmp_buf
  sd $a0,0($sp)

  // obtain $sp
  dadd $a0,$zero,$sp

  // call tsan interceptor
  jal __tsan_setjmp
  daddiu $a1,$a0,40

  // restore jmp_buf
  ld $a0,0($sp)

  // restore gp
  move $gp,$s0

  // load pointer of libc setjmp to t9
  dla $t9,(_ZN14__interception11real_setjmpE) 

  // restore env parameters
  ld $gp,8($sp)
  ld $fp,16($sp)
  ld $ra,24($sp)
  ld $s0,32($sp)
  daddiu $sp,$sp,40

  // tail jump to libc setjmp
  ld $t9,0($t9)
  jr $t9
  nop

.size setjmp, .-setjmp

.hidden __tsan_setjmp
.globl _setjmp
.comm _ZN14__interception12real__setjmpE,8,8
.type _setjmp, @function
_setjmp:

  // Save env parameters
  daddiu $sp,$sp,-40
  sd $s0,32($sp)
  sd $ra,24($sp)
  sd $fp,16($sp)
  sd $gp,8($sp)

  // calculate and save pointer to GOT
  lui $gp,%hi(%neg(%gp_rel(_setjmp)))
  daddu $gp,$gp,$t9
  daddiu $gp,$gp,%lo(%neg(%gp_rel(_setjmp)))
  move $s0,$gp

  // save jmp_buf
  sd $a0,0($sp)

  // obtain $sp
  dadd $a0,$zero,$sp

  // call tsan interceptor
  jal __tsan_setjmp
  daddiu $a1,$a0,40

  // restore jmp_buf
  ld $a0,0($sp)

  // restore gp
  move $gp,$s0

  // load pointer of libc _setjmp to t9
  dla $t9,(_ZN14__interception12real__setjmpE)

  // restore env parameters
  ld $gp,8($sp)
  ld $fp,16($sp)
  ld $ra,24($sp)
  ld $s0,32($sp)
  daddiu $sp,$sp,40

  // tail jump to libc _setjmp
  ld $t9,0($t9)
  jr $t9
  nop

.size _setjmp, .-_setjmp

.hidden __tsan_setjmp
.globl sigsetjmp
.comm _ZN14__interception14real_sigsetjmpE,8,8
.type sigsetjmp, @function
sigsetjmp:

  // Save env parameters
  daddiu $sp,$sp,-48
  sd $s0,40($sp)
  sd $ra,32($sp)
  sd $fp,24($sp)
  sd $gp,16($sp)

  // calculate and save pointer to GOT
  lui $gp,%hi(%neg(%gp_rel(sigsetjmp)))
  daddu $gp,$gp,$t9
  daddiu $gp,$gp,%lo(%neg(%gp_rel(sigsetjmp)))
  move $s0,$gp

  // save jmp_buf and savesig
  sd $a0,0($sp)
  sd $a1,8($sp)

  // obtain $sp
  dadd $a0,$zero,$sp

  // call tsan interceptor
  jal __tsan_setjmp
  daddiu $a1,$a0,48

  // restore jmp_buf and savesig
  ld $a0,0($sp)
  ld $a1,8($sp)

  // restore gp
  move $gp,$s0

  // load pointer of libc sigsetjmp to t9
  dla $t9,(_ZN14__interception14real_sigsetjmpE) 

  // restore env parameters
  ld $gp,16($sp)
  ld $fp,24($sp)
  ld $ra,32($sp)
  ld $s0,40($sp)
  daddiu $sp,$sp,48

  // tail jump to libc sigsetjmp
  ld $t9,0($t9)
  jr $t9
  nop

.size sigsetjmp, .-sigsetjmp

.hidden __tsan_setjmp
.comm _ZN14__interception16real___sigsetjmpE,8,8
.globl __sigsetjmp
.type __sigsetjmp, @function
__sigsetjmp:

  // Save env parameters
  daddiu $sp,$sp,-48
  sd $s0,40($sp)
  sd $ra,32($sp)
  sd $fp,24($sp)
  sd $gp,16($sp)

  // calculate and save pointer to GOT
  lui $gp,%hi(%neg(%gp_rel(__sigsetjmp)))
  daddu $gp,$gp,$t9
  daddiu $gp,$gp,%lo(%neg(%gp_rel(__sigsetjmp)))
  move $s0,$gp

  // save jmp_buf and savesig
  sd $a0,0($sp)
  sd $a1,8($sp)

  // obtain $sp
  dadd $a0,$zero,$sp

  // call tsan interceptor
  jal __tsan_setjmp
  daddiu $a1,$a0,48

  // restore jmp_buf and savesig
  ld $a0,0($sp)
  ld $a1,8($sp)

  // restore gp
  move $gp,$s0

  // load pointer to libc __sigsetjmp in t9
  dla $t9,(_ZN14__interception16real___sigsetjmpE)

  // restore env parameters
  ld $gp,16($sp)
  ld $fp,24($sp)
  ld $ra,32($sp)
  ld $s0,40($sp)
  daddiu $sp,$sp,48

  // tail jump to libc __sigsetjmp
  ld $t9,0($t9)
  jr $t9
  nop

.size __sigsetjmp, .-__sigsetjmp