clarify the purpose of this project
[nyanglibc.git] / stdlib / cxa_thread_atexit_impl.s
blob65bd1f29822ad7fbb403fc38192de2ba5f7b6d13
1 .text
2 .p2align 4,,15
3 .globl __cxa_thread_atexit_impl
4 .type __cxa_thread_atexit_impl, @function
5 __cxa_thread_atexit_impl:
6 pushq %r13
7 pushq %r12
8 movq %rsi, %r13
9 pushq %rbp
10 pushq %rbx
11 movq %rdi, %rbp
12 movl $32, %esi
13 movl $1, %edi
14 movq %rdx, %r12
15 subq $8, %rsp
16 call calloc@PLT
17 #APP
18 # 102 "cxa_thread_atexit_impl.c" 1
19 xor %fs:48, %rbp
20 rol $2*8+1, %rbp
21 # 0 "" 2
22 #NO_APP
23 cmpq $0, __pthread_mutex_lock@GOTPCREL(%rip)
24 movq %rax, %rbx
25 movq %rbp, (%rax)
26 movq %r13, 8(%rax)
27 movq %fs:tls_dtor_list@tpoff, %rax
28 movq %rbx, %fs:tls_dtor_list@tpoff
29 movq %rax, 24(%rbx)
30 je .L2
31 leaq _dl_load_lock(%rip), %rdi
32 call __pthread_mutex_lock@PLT
33 .L2:
34 testq %r12, %r12
35 jne .L3
36 movq %fs:lm_cache@tpoff, %rax
37 .L4:
38 lock addq $1, 1128(%rax)
39 cmpq $0, __pthread_mutex_unlock@GOTPCREL(%rip)
40 je .L6
41 leaq _dl_load_lock(%rip), %rdi
42 call __pthread_mutex_unlock@PLT
43 .L6:
44 movq %fs:lm_cache@tpoff, %rax
45 movq %rax, 16(%rbx)
46 addq $8, %rsp
47 xorl %eax, %eax
48 popq %rbx
49 popq %rbp
50 popq %r12
51 popq %r13
52 ret
53 .p2align 4,,10
54 .p2align 3
55 .L3:
56 movq %r12, %rdi
57 call _dl_find_dso_for_object@PLT
58 testq %rax, %rax
59 cmove _dl_ns(%rip), %rax
60 movq %rax, %fs:lm_cache@tpoff
61 jmp .L4
62 .size __cxa_thread_atexit_impl, .-__cxa_thread_atexit_impl
63 .p2align 4,,15
64 .weak __call_tls_dtors
65 .hidden __call_tls_dtors
66 .type __call_tls_dtors, @function
67 __call_tls_dtors:
68 pushq %rbx
69 movq %fs:tls_dtor_list@tpoff, %rbx
70 testq %rbx, %rbx
71 je .L15
72 .p2align 4,,10
73 .p2align 3
74 .L17:
75 movq 24(%rbx), %rdx
76 movq (%rbx), %rax
77 movq 8(%rbx), %rdi
78 #APP
79 # 151 "cxa_thread_atexit_impl.c" 1
80 ror $2*8+1, %rax
81 xor %fs:48, %rax
82 # 0 "" 2
83 #NO_APP
84 movq %rdx, %fs:tls_dtor_list@tpoff
85 call *%rax
86 movq 16(%rbx), %rax
87 lock subq $1, 1128(%rax)
88 movq %rbx, %rdi
89 call free@PLT
90 movq %fs:tls_dtor_list@tpoff, %rbx
91 testq %rbx, %rbx
92 jne .L17
93 .L15:
94 popq %rbx
95 ret
96 .size __call_tls_dtors, .-__call_tls_dtors
97 .section .tbss,"awT",@nobits
98 .align 8
99 .type lm_cache, @object
100 .size lm_cache, 8
101 lm_cache:
102 .zero 8
103 .align 8
104 .type tls_dtor_list, @object
105 .size tls_dtor_list, 8
106 tls_dtor_list:
107 .zero 8
108 .weak __pthread_mutex_unlock
109 .weak __pthread_mutex_lock