summaryrefslogtreecommitdiff
path: root/lib/mlibc/options/internal/x86/setjmp.S
blob: fa6644c7b57a0ccc018764e100b4e0854d5be0ec (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

.type __setjmp, "function"
__setjmp:
	mov 4(%esp), %eax       # Save argument (buffer) in edi
	mov %ebx, 0x00(%eax)
	mov %ebp, 0x04(%eax)
	mov %esi, 0x08(%eax)
	mov %edi, 0x0c(%eax)

	lea 4(%esp), %ecx       # esp before return eip is pushed
	mov %ecx, 0x10(%eax)
	mov (%esp), %ecx        # Return eip
	mov %ecx, 0x14(%eax)

	test %edx, %edx
	jnz 1f
	xor %eax, %eax
	ret

1:
	jmp __sigsetjmp@PLT

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

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

.global longjmp
.type longjmp, "function"
longjmp:
	mov 4(%esp), %ecx
	mov 0x00(%ecx), %ebx
	mov 0x04(%ecx), %ebp
	mov 0x08(%ecx), %esi
	mov 0x0c(%ecx), %edi

	mov 8(%esp), %eax
	test %eax, %eax
	jnz 1f
	inc %eax
1:
	mov 0x10(%ecx), %esp
	jmp *0x14(%ecx)

.section .note.GNU-stack,"",%progbits