aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/sysdeps/linux/x86/thread_entry.S
blob: 031a6aaa141e29f9426d3f70d6c84684daaa3ce4 (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
55
56
57
58
59
60
61
#define FLAGS 4
#define STACK FLAGS+4
#define PTID STACK+4
#define CTID PTID+4
#define TLS CTID+4

.section .text
.global __mlibc_spawn_thread
.type __mlibc_spawn_thread, "function"
.cfi_startproc
__mlibc_spawn_thread:
	push %ebx
	.cfi_adjust_cfa_offset 4
	.cfi_rel_offset ebx, 0
	push %esi
	.cfi_adjust_cfa_offset 4
	.cfi_rel_offset esi, 0
	push %edi
	.cfi_adjust_cfa_offset 4
	.cfi_rel_offset edi, 0

	xor %eax, %eax
	mov 12+FLAGS(%esp), %ebx
	mov 12+STACK(%esp), %ecx
	mov 12+PTID(%esp), %edx
	/* On x86-32 tls and child_tid have to be reversed */
	mov 12+TLS(%esp), %esi
	mov 12+CTID(%esp), %edi
	mov $120, %al

	int $0x80

	test %eax, %eax
	jnz .parent_exit

	xor %ebp, %ebp
	.cfi_undefined %eip
	.cfi_undefined %ebp

	call 1f
1:
	pop %ebx
	addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx

	call __mlibc_enter_thread@plt
	hlt

.parent_exit:
	pop %edi
	.cfi_adjust_cfa_offset -4
	.cfi_restore edi
	pop %esi
	.cfi_adjust_cfa_offset -4
	.cfi_restore esi
	pop %ebx
	.cfi_adjust_cfa_offset -4
	.cfi_restore ebx
	ret
.cfi_endproc

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