aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/internal/x86_64/setjmp.S
blob: aa8a13433b8030c02b88b03cafabd8632f0b67d5 (plain)
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

.type __setjmp, "function"
__setjmp:
	mov %rbx, 0x00(%rdi)
	mov %rbp, 0x08(%rdi)
	mov %r12, 0x10(%rdi)
	mov %r13, 0x18(%rdi)
	mov %r14, 0x20(%rdi)
	mov %r15, 0x28(%rdi)

	lea 8(%rsp), %rax # rsp before return rip is pushed
	mov %rax, 0x30(%rdi)
	mov (%rsp), %rax # return rip
	mov %rax, 0x38(%rdi)

	test %rdx, %rdx
	jnz 1f
	xor %rax, %rax
	ret

1:
	jmp __sigsetjmp

.global setjmp
.type setjmp, "function"
setjmp:
	xor %rdx, %rdx
	jmp __setjmp

.global sigsetjmp
.type sigsetjmp, "function"
sigsetjmp:
	mov $1, %rdx
	jmp __setjmp

.global longjmp
.type longjmp, "function"
longjmp:
	mov 0x00(%rdi), %rbx
	mov 0x08(%rdi), %rbp
	mov 0x10(%rdi), %r12
	mov 0x18(%rdi), %r13
	mov 0x20(%rdi), %r14
	mov 0x28(%rdi), %r15

	mov  %rsi, %rax
	test %rax, %rax
	jnz 1f
	inc %rax
1:
	mov  0x30(%rdi), %rsp
	jmp  *0x38(%rdi)
.section .note.GNU-stack,"",%progbits