Add vbit-test-sec.vgtest and vbit-test-sec.stderr.exp to EXTRA_DIST.
[valgrind.git] / coregrind / m_libcsetjmp.c
blobc731806402f2e515f89845421385e8621b9dd991
2 /*--------------------------------------------------------------------*/
3 /*--- A minimal setjmp/longjmp implementation. m_libcsetjmp.c ---*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2010-2017 Mozilla Inc
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of the
15 License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 02111-1307, USA.
27 The GNU General Public License is contained in the file COPYING.
30 /* Contributed by Julian Seward <jseward@acm.org> */
32 /* This file must be compiled without link time optimisation, as otherwise
33 the asm functions below become undefined references at link time for
34 unclear reasons. */
36 #include "pub_core_basics.h"
37 #include "pub_core_libcsetjmp.h" /* self */
39 /* See include/pub_tool_libcsetjmp.h for background and rationale. */
41 /* The alternative implementations are for ppc{32,64}-linux and
42 {amd64,x86}-{linux,darwin,solaris}. See #259977. That leaves only
43 {arm,s390x}-linux using the gcc builtins now.
46 /* ------------ ppc32-linux ------------ */
48 #if defined(VGP_ppc32_linux)
50 __asm__(
51 ".text" "\n"
52 "" "\n"
53 ".global VG_MINIMAL_SETJMP" "\n" // r3 = jmp_buf
54 "VG_MINIMAL_SETJMP:" "\n"
55 " stw 0, 0(3)" "\n"
56 " stw 1, 4(3)" "\n"
57 " stw 2, 8(3)" "\n"
58 " stw 3, 12(3)" "\n"
59 " stw 4, 16(3)" "\n"
60 " stw 5, 20(3)" "\n"
61 " stw 6, 24(3)" "\n"
62 " stw 7, 28(3)" "\n"
63 " stw 8, 32(3)" "\n"
64 " stw 9, 36(3)" "\n"
65 " stw 10, 40(3)" "\n"
66 " stw 11, 44(3)" "\n"
67 " stw 12, 48(3)" "\n"
68 " stw 13, 52(3)" "\n"
69 " stw 14, 56(3)" "\n"
70 " stw 15, 60(3)" "\n"
71 " stw 16, 64(3)" "\n"
72 " stw 17, 68(3)" "\n"
73 " stw 18, 72(3)" "\n"
74 " stw 19, 76(3)" "\n"
75 " stw 20, 80(3)" "\n"
76 " stw 21, 84(3)" "\n"
77 " stw 22, 88(3)" "\n"
78 " stw 23, 92(3)" "\n"
79 " stw 24, 96(3)" "\n"
80 " stw 25, 100(3)" "\n"
81 " stw 26, 104(3)" "\n"
82 " stw 27, 108(3)" "\n"
83 " stw 28, 112(3)" "\n"
84 " stw 29, 116(3)" "\n"
85 " stw 30, 120(3)" "\n"
86 " stw 31, 124(3)" "\n"
87 // must use a caller-save register here as scratch, hence r4
88 " mflr 4" "\n"
89 " stw 4, 128(3)" "\n"
90 " mfcr 4" "\n"
91 " stw 4, 132(3)" "\n"
92 " li 3, 0" "\n"
93 " blr" "\n"
94 "" "\n"
97 ".global VG_MINIMAL_LONGJMP" "\n"
98 "VG_MINIMAL_LONGJMP:" "\n" // r3 = jmp_buf
99 // do r4 = 1
100 // and park it in the restore slot for r3 (the ret reg)
101 " li 4, 1" "\n"
102 " stw 4, 12(3)" "\n"
103 // restore everything except r3
104 // then r3 last of all
105 // then blr
106 " lwz 0, 128(3)" "\n"
107 " mtlr 0" "\n"
108 " lwz 0, 132(3)" "\n"
109 " mtcr 0" "\n"
110 " lwz 0, 0(3)" "\n"
111 " lwz 1, 4(3)" "\n"
112 " lwz 2, 8(3)" "\n"
113 // r3 is done at the end
114 " lwz 4, 16(3)" "\n"
115 " lwz 5, 20(3)" "\n"
116 " lwz 6, 24(3)" "\n"
117 " lwz 7, 28(3)" "\n"
118 " lwz 8, 32(3)" "\n"
119 " lwz 9, 36(3)" "\n"
120 " lwz 10, 40(3)" "\n"
121 " lwz 11, 44(3)" "\n"
122 " lwz 12, 48(3)" "\n"
123 " lwz 13, 52(3)" "\n"
124 " lwz 14, 56(3)" "\n"
125 " lwz 15, 60(3)" "\n"
126 " lwz 16, 64(3)" "\n"
127 " lwz 17, 68(3)" "\n"
128 " lwz 18, 72(3)" "\n"
129 " lwz 19, 76(3)" "\n"
130 " lwz 20, 80(3)" "\n"
131 " lwz 21, 84(3)" "\n"
132 " lwz 22, 88(3)" "\n"
133 " lwz 23, 92(3)" "\n"
134 " lwz 24, 96(3)" "\n"
135 " lwz 25, 100(3)" "\n"
136 " lwz 26, 104(3)" "\n"
137 " lwz 27, 108(3)" "\n"
138 " lwz 28, 112(3)" "\n"
139 " lwz 29, 116(3)" "\n"
140 " lwz 30, 120(3)" "\n"
141 " lwz 31, 124(3)" "\n"
142 " lwz 3, 12(3)" "\n"
143 " blr" "\n"
144 "" "\n"
146 ".previous" "\n"
149 #endif /* VGP_ppc32_linux */
152 /* ------------ ppc64-linux ------------ */
154 #if defined(VGP_ppc64be_linux)
156 __asm__(
157 ".section \".toc\",\"aw\"" "\n"
159 ".section \".text\"" "\n"
160 ".align 2" "\n"
161 ".p2align 4,,15" "\n"
162 ".globl VG_MINIMAL_SETJMP" "\n"
163 ".section \".opd\",\"aw\"" "\n"
164 ".align 3" "\n"
165 "VG_MINIMAL_SETJMP:" "\n"
166 ".quad .L.VG_MINIMAL_SETJMP,.TOC.@tocbase,0" "\n"
167 ".previous" "\n"
169 ".type VG_MINIMAL_SETJMP, @function" "\n"
170 ".L.VG_MINIMAL_SETJMP:" "\n"
171 " std 0, 0(3)" "\n"
172 " std 1, 8(3)" "\n"
173 " std 2, 16(3)" "\n"
174 " std 3, 24(3)" "\n"
175 " std 4, 32(3)" "\n"
176 " std 5, 40(3)" "\n"
177 " std 6, 48(3)" "\n"
178 " std 7, 56(3)" "\n"
179 " std 8, 64(3)" "\n"
180 " std 9, 72(3)" "\n"
181 " std 10, 80(3)" "\n"
182 " std 11, 88(3)" "\n"
183 " std 12, 96(3)" "\n"
184 " std 13, 104(3)" "\n"
185 " std 14, 112(3)" "\n"
186 " std 15, 120(3)" "\n"
187 " std 16, 128(3)" "\n"
188 " std 17, 136(3)" "\n"
189 " std 18, 144(3)" "\n"
190 " std 19, 152(3)" "\n"
191 " std 20, 160(3)" "\n"
192 " std 21, 168(3)" "\n"
193 " std 22, 176(3)" "\n"
194 " std 23, 184(3)" "\n"
195 " std 24, 192(3)" "\n"
196 " std 25, 200(3)" "\n"
197 " std 26, 208(3)" "\n"
198 " std 27, 216(3)" "\n"
199 " std 28, 224(3)" "\n"
200 " std 29, 232(3)" "\n"
201 " std 30, 240(3)" "\n"
202 " std 31, 248(3)" "\n"
203 // must use a caller-save register here as scratch, hence r4
204 " mflr 4" "\n"
205 " std 4, 256(3)" "\n"
206 " mfcr 4" "\n"
207 " std 4, 264(3)" "\n"
208 " li 3, 0" "\n"
209 " blr" "\n"
210 "" "\n"
213 ".globl VG_MINIMAL_LONGJMP" "\n"
215 ".section \".opd\",\"aw\"" "\n"
216 ".align 3" "\n"
217 "VG_MINIMAL_LONGJMP:" "\n"
218 ".quad .L.VG_MINIMAL_LONGJMP,.TOC.@tocbase,0" "\n"
219 ".previous" "\n"
221 ".type VG_MINIMAL_LONGJMP, @function" "\n"
222 ".L.VG_MINIMAL_LONGJMP:" "\n"
223 // do r4 = 1
224 // and park it in the restore slot for r3 (the ret reg)
225 " li 4, 1" "\n"
226 " std 4, 24(3)" "\n"
227 // restore everything except r3
228 // then r3 last of all
229 // then blr
230 " ld 0, 256(3)" "\n"
231 " mtlr 0" "\n"
232 " ld 0, 264(3)" "\n"
233 " mtcr 0" "\n"
234 " ld 0, 0(3)" "\n"
235 " ld 1, 8(3)" "\n"
236 " ld 2, 16(3)" "\n"
237 // r3 is done at the end
238 " ld 4, 32(3)" "\n"
239 " ld 5, 40(3)" "\n"
240 " ld 6, 48(3)" "\n"
241 " ld 7, 56(3)" "\n"
242 " ld 8, 64(3)" "\n"
243 " ld 9, 72(3)" "\n"
244 " ld 10, 80(3)" "\n"
245 " ld 11, 88(3)" "\n"
246 " ld 12, 96(3)" "\n"
247 " ld 13, 104(3)" "\n"
248 " ld 14, 112(3)" "\n"
249 " ld 15, 120(3)" "\n"
250 " ld 16, 128(3)" "\n"
251 " ld 17, 136(3)" "\n"
252 " ld 18, 144(3)" "\n"
253 " ld 19, 152(3)" "\n"
254 " ld 20, 160(3)" "\n"
255 " ld 21, 168(3)" "\n"
256 " ld 22, 176(3)" "\n"
257 " ld 23, 184(3)" "\n"
258 " ld 24, 192(3)" "\n"
259 " ld 25, 200(3)" "\n"
260 " ld 26, 208(3)" "\n"
261 " ld 27, 216(3)" "\n"
262 " ld 28, 224(3)" "\n"
263 " ld 29, 232(3)" "\n"
264 " ld 30, 240(3)" "\n"
265 " ld 31, 248(3)" "\n"
266 " ld 3, 24(3)" "\n"
267 " blr" "\n"
268 "" "\n"
270 ".previous" "\n"
273 #elif defined(VGP_ppc64le_linux)
274 __asm__(
275 ".section \".toc\",\"aw\"" "\n"
277 ".section \".text\"" "\n"
278 ".align 2" "\n"
279 ".p2align 4,,15" "\n"
280 ".globl VG_MINIMAL_SETJMP" "\n"
281 ".type VG_MINIMAL_SETJMP,@function" "\n"
282 "VG_MINIMAL_SETJMP:" "\n"
283 " .localentry VG_MINIMAL_SETJMP, .-VG_MINIMAL_SETJMP" "\n"
284 " std 0, 0(3)" "\n"
285 " std 1, 8(3)" "\n"
286 " std 2, 16(3)" "\n"
287 " std 3, 24(3)" "\n"
288 " std 4, 32(3)" "\n"
289 " std 5, 40(3)" "\n"
290 " std 6, 48(3)" "\n"
291 " std 7, 56(3)" "\n"
292 " std 8, 64(3)" "\n"
293 " std 9, 72(3)" "\n"
294 " std 10, 80(3)" "\n"
295 " std 11, 88(3)" "\n"
296 " std 12, 96(3)" "\n"
297 " std 13, 104(3)" "\n"
298 " std 14, 112(3)" "\n"
299 " std 15, 120(3)" "\n"
300 " std 16, 128(3)" "\n"
301 " std 17, 136(3)" "\n"
302 " std 18, 144(3)" "\n"
303 " std 19, 152(3)" "\n"
304 " std 20, 160(3)" "\n"
305 " std 21, 168(3)" "\n"
306 " std 22, 176(3)" "\n"
307 " std 23, 184(3)" "\n"
308 " std 24, 192(3)" "\n"
309 " std 25, 200(3)" "\n"
310 " std 26, 208(3)" "\n"
311 " std 27, 216(3)" "\n"
312 " std 28, 224(3)" "\n"
313 " std 29, 232(3)" "\n"
314 " std 30, 240(3)" "\n"
315 " std 31, 248(3)" "\n"
316 // must use a caller-save register here as scratch, hence r4
317 " mflr 4" "\n"
318 " std 4, 256(3)" "\n"
319 " mfcr 4" "\n"
320 " std 4, 264(3)" "\n"
321 " li 3, 0" "\n"
322 " blr" "\n"
323 "" "\n"
326 ".globl VG_MINIMAL_LONGJMP" "\n"
327 ".type VG_MINIMAL_LONGJMP, @function" "\n"
328 "VG_MINIMAL_LONGJMP:" "\n"
329 " .localentry VG_MINIMAL_LONGJMP, .-VG_MINIMAL_LONGJMP" "\n"
330 // do r4 = 1
331 // and park it in the restore slot for r3 (the ret reg)
332 " li 4, 1" "\n"
333 " std 4, 24(3)" "\n"
334 // restore everything except r3
335 // then r3 last of all
336 // then blr
337 " ld 0, 256(3)" "\n"
338 " mtlr 0" "\n"
339 " ld 0, 264(3)" "\n"
340 " mtcr 0" "\n"
341 " ld 0, 0(3)" "\n"
342 " ld 1, 8(3)" "\n"
343 " ld 2, 16(3)" "\n"
344 // r3 is done at the end
345 " ld 4, 32(3)" "\n"
346 " ld 5, 40(3)" "\n"
347 " ld 6, 48(3)" "\n"
348 " ld 7, 56(3)" "\n"
349 " ld 8, 64(3)" "\n"
350 " ld 9, 72(3)" "\n"
351 " ld 10, 80(3)" "\n"
352 " ld 11, 88(3)" "\n"
353 " ld 12, 96(3)" "\n"
354 " ld 13, 104(3)" "\n"
355 " ld 14, 112(3)" "\n"
356 " ld 15, 120(3)" "\n"
357 " ld 16, 128(3)" "\n"
358 " ld 17, 136(3)" "\n"
359 " ld 18, 144(3)" "\n"
360 " ld 19, 152(3)" "\n"
361 " ld 20, 160(3)" "\n"
362 " ld 21, 168(3)" "\n"
363 " ld 22, 176(3)" "\n"
364 " ld 23, 184(3)" "\n"
365 " ld 24, 192(3)" "\n"
366 " ld 25, 200(3)" "\n"
367 " ld 26, 208(3)" "\n"
368 " ld 27, 216(3)" "\n"
369 " ld 28, 224(3)" "\n"
370 " ld 29, 232(3)" "\n"
371 " ld 30, 240(3)" "\n"
372 " ld 31, 248(3)" "\n"
373 " ld 3, 24(3)" "\n"
374 " blr" "\n"
375 "" "\n"
377 ".previous" "\n"
379 #endif /* VGP_ppc64be_linux */
382 /* -------- amd64-{linux,darwin,solaris} -------- */
384 #if defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) || \
385 defined(VGP_amd64_solaris)
387 __asm__(
388 ".text" "\n"
389 "" "\n"
391 #if defined(VGP_amd64_linux) || defined(VGP_amd64_solaris)
392 ".global VG_MINIMAL_SETJMP" "\n" // rdi = jmp_buf
393 "VG_MINIMAL_SETJMP:" "\n"
395 #elif defined(VGP_amd64_darwin)
396 ".globl _VG_MINIMAL_SETJMP" "\n" // rdi = jmp_buf
397 "_VG_MINIMAL_SETJMP:" "\n"
399 #else
400 # error "Huh?"
401 #endif
403 " movq %rax, 0(%rdi)" "\n"
404 " movq %rbx, 8(%rdi)" "\n"
405 " movq %rcx, 16(%rdi)" "\n"
406 " movq %rdx, 24(%rdi)" "\n"
407 " movq %rdi, 32(%rdi)" "\n"
408 " movq %rsi, 40(%rdi)" "\n"
409 " movq %rbp, 48(%rdi)" "\n"
410 " movq %rsp, 56(%rdi)" "\n"
411 " movq %r8, 64(%rdi)" "\n"
412 " movq %r9, 72(%rdi)" "\n"
413 " movq %r10, 80(%rdi)" "\n"
414 " movq %r11, 88(%rdi)" "\n"
415 " movq %r12, 96(%rdi)" "\n"
416 " movq %r13, 104(%rdi)" "\n"
417 " movq %r14, 112(%rdi)" "\n"
418 " movq %r15, 120(%rdi)" "\n"
419 // store the return address
420 " movq 0(%rsp), %rax" "\n"
421 " movq %rax, 128(%rdi)" "\n"
422 // and return zero
423 " movq $0, %rax" "\n"
424 " ret" "\n"
425 "" "\n"
428 #if defined(VGP_amd64_linux) || defined(VGP_amd64_solaris)
429 ".global VG_MINIMAL_LONGJMP" "\n"
430 "VG_MINIMAL_LONGJMP:" "\n" // rdi = jmp_buf
432 #elif defined(VGP_amd64_darwin)
433 ".globl _VG_MINIMAL_LONGJMP" "\n"
434 "_VG_MINIMAL_LONGJMP:" "\n" // rdi = jmp_buf
436 #else
437 # error "Huh?"
438 #endif
439 // skip restoring rax; it's pointless
440 " movq 8(%rdi), %rbx" "\n"
441 " movq 16(%rdi), %rcx" "\n"
442 " movq 24(%rdi), %rdx" "\n"
443 // defer restoring rdi; we still need it
444 " movq 40(%rdi), %rsi" "\n"
445 " movq 48(%rdi), %rbp" "\n"
446 " movq 56(%rdi), %rsp" "\n"
447 " movq 64(%rdi), %r8" "\n"
448 " movq 72(%rdi), %r9" "\n"
449 " movq 80(%rdi), %r10" "\n"
450 " movq 88(%rdi), %r11" "\n"
451 " movq 96(%rdi), %r12" "\n"
452 " movq 104(%rdi), %r13" "\n"
453 " movq 112(%rdi), %r14" "\n"
454 " movq 120(%rdi), %r15" "\n"
455 // restore the return address
456 " movq 128(%rdi), %rax" "\n"
457 // restore rdi; this is the last use
458 " movq 32(%rdi), %rdi" "\n"
459 // make %rsp look like we really did a return
460 " addq $8, %rsp" "\n"
461 // continue at RA of original call. Note: this is a
462 // nasty trick. We assume that %rax is nonzero, and so the
463 // caller can differentiate this case from the normal _SETJMP
464 // return case. If the return address ever is zero, then
465 // we're hosed; but that seems pretty unlikely given that it
466 // would mean we'd be executing at the wraparound point of the
467 // address space.
468 " jmp *%rax" "\n"
469 "" "\n"
471 #if !defined(VGP_amd64_darwin)
472 ".previous" "\n"
473 #endif
476 #endif /* VGP_amd64_linux || VGP_amd64_darwin || VGP_amd64_solaris */
479 /* -------- x86-{linux,darwin,solaris} -------- */
481 #if defined(VGP_x86_linux) || defined(VGP_x86_darwin) || \
482 defined(VGP_x86_solaris)
484 __asm__(
485 ".text" "\n"
486 "" "\n"
488 #if defined(VGP_x86_linux) || defined(VGP_x86_solaris)
489 ".global VG_MINIMAL_SETJMP" "\n" // eax = jmp_buf
490 "VG_MINIMAL_SETJMP:" "\n"
492 #elif defined(VGP_x86_darwin)
493 ".globl _VG_MINIMAL_SETJMP" "\n" // eax = jmp_buf
494 "_VG_MINIMAL_SETJMP:" "\n"
496 #else
497 # error "Huh?"
498 #endif
500 " movl %eax, 0(%eax)" "\n"
501 " movl %ebx, 4(%eax)" "\n"
502 " movl %ecx, 8(%eax)" "\n"
503 " movl %edx, 12(%eax)" "\n"
504 " movl %edi, 16(%eax)" "\n"
505 " movl %esi, 20(%eax)" "\n"
506 " movl %ebp, 24(%eax)" "\n"
507 " movl %esp, 28(%eax)" "\n"
508 // store the return address
509 " movl 0(%esp), %ebx" "\n"
510 " movl %ebx, 32(%eax)" "\n"
511 // un-trash ebx (necessary? i don't know)
512 " movl 4(%eax), %ebx" "\n"
513 // and return zero
514 " movl $0, %eax" "\n"
515 " ret" "\n"
516 "" "\n"
519 #if defined(VGP_x86_linux) || defined(VGP_x86_solaris)
520 ".global VG_MINIMAL_LONGJMP" "\n"
521 "VG_MINIMAL_LONGJMP:" "\n" // eax = jmp_buf
523 #elif defined(VGP_x86_darwin)
524 ".globl _VG_MINIMAL_LONGJMP" "\n"
525 "_VG_MINIMAL_LONGJMP:" "\n" // eax = jmp_buf
527 #else
528 # error "Huh?"
529 #endif
531 // skip restoring eax; it's pointless
532 " movl 4(%eax), %ebx" "\n"
533 " movl 8(%eax), %ecx" "\n"
534 " movl 12(%eax), %edx" "\n"
535 " movl 16(%eax), %edi" "\n"
536 " movl 20(%eax), %esi" "\n"
537 " movl 24(%eax), %ebp" "\n"
538 " movl 28(%eax), %esp" "\n"
539 // restore the return address
540 " movl 32(%eax), %eax" "\n"
541 // make %esp look like we really did a return
542 " addl $4, %esp" "\n"
543 // continue at RA of original call. Same zero-vs-nonzero
544 // trick/assumption as documented for the amd64-linux case.
545 " jmp *%eax" "\n"
546 "" "\n"
548 #if !defined(VGP_x86_darwin)
549 ".previous" "\n"
550 #endif
553 #endif /* VGP_x86_linux || VGP_x86_darwin || VGP_x86_solaris */
555 #if defined(VGP_mips32_linux)
557 __asm__(
558 ".text \n\t"
559 ".globl VG_MINIMAL_SETJMP; \n\t"
560 ".set push \n\t"
561 ".set noreorder \n\t"
562 "VG_MINIMAL_SETJMP: \n\t"
563 #if defined(__mips_hard_float)
564 " sdc1 $f20, 56($a0) \n\t"
565 " sdc1 $f22, 64($a0) \n\t"
566 " sdc1 $f24, 72($a0) \n\t"
567 " sdc1 $f26, 80($a0) \n\t"
568 " sdc1 $f28, 88($a0) \n\t"
569 " sdc1 $f30, 96($a0) \n\t"
570 #endif
571 " sw $gp, 44($a0) \n\t"
572 " sw $s0, 8($a0) \n\t"
573 " sw $s1, 12($a0) \n\t"
574 " sw $s2, 16($a0) \n\t"
575 " sw $s3, 20($a0) \n\t"
576 " sw $s4, 24($a0) \n\t"
577 " sw $s5, 28($a0) \n\t"
578 " sw $s6, 32($a0) \n\t"
579 " sw $s7, 36($a0) \n\t"
580 " sw $ra, 0($a0) \n\t"
581 " sw $sp, 4($a0) \n\t"
582 " sw $fp, 40($a0) \n\t"
583 " jr $ra \n\t"
584 " move $v0, $zero \n\t"
585 ".set pop \n\t"
586 ".previous \n\t"
587 " \n\t"
588 ".text \n\t"
589 ".globl VG_MINIMAL_LONGJMP; \n\t"
590 ".set push \n\t"
591 ".set noreorder \n\t"
592 "VG_MINIMAL_LONGJMP: \n\t"
593 #if defined(__mips_hard_float)
594 " ldc1 $f20, 56($a0) \n\t"
595 " ldc1 $f22, 64($a0) \n\t"
596 " ldc1 $f24, 72($a0) \n\t"
597 " ldc1 $f26, 80($a0) \n\t"
598 " ldc1 $f28, 88($a0) \n\t"
599 " ldc1 $f30, 96($a0) \n\t"
600 #endif
601 " lw $gp, 44($a0) \n\t"
602 " lw $s0, 8($a0) \n\t"
603 " lw $s1, 12($a0) \n\t"
604 " lw $s2, 16($a0) \n\t"
605 " lw $s3, 20($a0) \n\t"
606 " lw $s4, 24($a0) \n\t"
607 " lw $s5, 28($a0) \n\t"
608 " lw $s6, 32($a0) \n\t"
609 " lw $s7, 36($a0) \n\t"
610 " lw $ra, 0($a0) \n\t"
611 " lw $sp, 4($a0) \n\t"
612 " bnez $a1, 1f \n\t"
613 " lw $fp, 40($a0) \n\t"
614 " addiu $a1, $a1, 1 \n\t"
615 "1: \n\t"
616 " jr $ra \n\t"
617 " move $v0, $a1 \n\t"
618 ".set pop \n\t"
619 ".previous \n\t"
621 #endif /* VGP_mips32_linux */
623 #if defined(VGP_mips64_linux)
625 __asm__(
626 ".text \n\t"
627 ".globl VG_MINIMAL_SETJMP; \n\t"
628 ".set push \n\t"
629 ".set noreorder \n\t"
630 "VG_MINIMAL_SETJMP: \n\t"
631 #if defined(__mips_hard_float)
632 " sdc1 $f24, 104($a0) \n\t"
633 " sdc1 $f25, 112($a0) \n\t"
634 " sdc1 $f26, 120($a0) \n\t"
635 " sdc1 $f27, 128($a0) \n\t"
636 " sdc1 $f28, 136($a0) \n\t"
637 " sdc1 $f29, 144($a0) \n\t"
638 " sdc1 $f30, 152($a0) \n\t"
639 " sdc1 $f31, 160($a0) \n\t"
640 #endif
641 " sd $gp, 88($a0) \n\t"
642 " sd $s0, 16($a0) \n\t"
643 " sd $s1, 24($a0) \n\t"
644 " sd $s2, 32($a0) \n\t"
645 " sd $s3, 40($a0) \n\t"
646 " sd $s4, 48($a0) \n\t"
647 " sd $s5, 56($a0) \n\t"
648 " sd $s6, 64($a0) \n\t"
649 " sd $s7, 72($a0) \n\t"
650 " sd $ra, 0($a0) \n\t"
651 " sd $sp, 8($a0) \n\t"
652 " sd $fp, 80($a0) \n\t"
653 " jr $ra \n\t"
654 " move $v0, $zero \n\t"
655 ".set pop \n\t"
656 ".previous \n\t"
657 " \n\t"
658 ".text \n\t"
659 ".globl VG_MINIMAL_LONGJMP; \n\t"
660 ".set push \n\t"
661 ".set noreorder \n\t"
662 "VG_MINIMAL_LONGJMP: \n\t"
663 #if defined(__mips_hard_float)
664 " ldc1 $f24, 104($a0) \n\t"
665 " ldc1 $f25, 112($a0) \n\t"
666 " ldc1 $f26, 120($a0) \n\t"
667 " ldc1 $f27, 128($a0) \n\t"
668 " ldc1 $f28, 136($a0) \n\t"
669 " ldc1 $f29, 144($a0) \n\t"
670 " ldc1 $f30, 152($a0) \n\t"
671 " ldc1 $f31, 160($a0) \n\t"
672 #endif
673 " ld $gp, 88($a0) \n\t"
674 " ld $s0, 16($a0) \n\t"
675 " ld $s1, 24($a0) \n\t"
676 " ld $s2, 32($a0) \n\t"
677 " ld $s3, 40($a0) \n\t"
678 " ld $s4, 48($a0) \n\t"
679 " ld $s5, 56($a0) \n\t"
680 " ld $s6, 64($a0) \n\t"
681 " ld $s7, 72($a0) \n\t"
682 " ld $ra, 0($a0) \n\t"
683 " ld $sp, 8($a0) \n\t"
684 " bnez $a1, 1f \n\t"
685 " ld $fp, 80($a0) \n\t"
686 " daddiu $a1, $a1, 1 \n\t"
687 "1: \n\t"
688 " jr $ra \n\t"
689 " move $v0, $a1 \n\t"
690 ".set pop \n\t"
691 ".previous \n\t"
693 #endif /* VGP_mips64_linux */
694 /*--------------------------------------------------------------------*/
695 /*--- end ---*/
696 /*--------------------------------------------------------------------*/