clarify the purpose of this project
[nyanglibc.git] / nptl / register-atfork.shared.s
blobdc14ba8767a078b831d478b24da5ed94b9cd420b
1 .text
2 #APP
3 memmove = __GI_memmove
4 memset = __GI_memset
5 memcpy = __GI_memcpy
6 #NO_APP
7 .section __libc_freeres_fn,"ax",@progbits
8 .p2align 4,,15
9 .type free_mem, @function
10 free_mem:
11 pushq %rbx
12 #APP
13 # 145 "register-atfork.c" 1
14 movl %fs:24,%eax
15 # 0 "" 2
16 #NO_APP
17 testl %eax, %eax
18 jne .L2
19 movl $1, %edx
20 #APP
21 # 47 "../sysdeps/unix/sysv/linux/x86/lowlevellock.h" 1
22 cmpxchgl %edx, atfork_lock(%rip)
23 # 0 "" 2
24 #NO_APP
25 .L3:
26 movq 16+fork_handlers(%rip), %rdi
27 leaq 24+fork_handlers(%rip), %rbx
28 cmpq %rbx, %rdi
29 je .L4
30 call free@PLT
31 .L4:
32 movq $0, fork_handlers(%rip)
33 movq $48, 8+fork_handlers(%rip)
34 movq %rbx, 16+fork_handlers(%rip)
35 #APP
36 # 149 "register-atfork.c" 1
37 movl %fs:24,%eax
38 # 0 "" 2
39 #NO_APP
40 testl %eax, %eax
41 jne .L5
42 subl $1, atfork_lock(%rip)
43 .L1:
44 popq %rbx
45 ret
46 .p2align 4,,10
47 .p2align 3
48 .L2:
49 xorl %eax, %eax
50 movl $1, %edx
51 lock cmpxchgl %edx, atfork_lock(%rip)
52 je .L3
53 leaq atfork_lock(%rip), %rdi
54 call __lll_lock_wait_private
55 jmp .L3
56 .p2align 4,,10
57 .p2align 3
58 .L5:
59 xorl %eax, %eax
60 #APP
61 # 149 "register-atfork.c" 1
62 xchgl %eax, atfork_lock(%rip)
63 # 0 "" 2
64 #NO_APP
65 cmpl $1, %eax
66 jle .L1
67 xorl %r10d, %r10d
68 movl $1, %edx
69 movl $129, %esi
70 leaq atfork_lock(%rip), %rdi
71 movl $202, %eax
72 #APP
73 # 149 "register-atfork.c" 1
74 syscall
76 # 0 "" 2
77 #NO_APP
78 popq %rbx
79 ret
80 .size free_mem, .-free_mem
81 .text
82 .p2align 4,,15
83 .globl __GI___register_atfork
84 .hidden __GI___register_atfork
85 .type __GI___register_atfork, @function
86 __GI___register_atfork:
87 pushq %r12
88 pushq %rbp
89 movq %rdi, %r12
90 pushq %rbx
91 movq %rsi, %rbp
92 movq %rdx, %rbx
93 subq $16, %rsp
94 #APP
95 # 40 "register-atfork.c" 1
96 movl %fs:24,%eax
97 # 0 "" 2
98 #NO_APP
99 testl %eax, %eax
100 jne .L10
101 movl $1, %edx
102 #APP
103 # 47 "../sysdeps/unix/sysv/linux/x86/lowlevellock.h" 1
104 cmpxchgl %edx, atfork_lock(%rip)
105 # 0 "" 2
106 #NO_APP
107 .L11:
108 cmpb $0, fork_handler_init(%rip)
109 jne .L12
110 leaq 24+fork_handlers(%rip), %rax
111 movq $48, 8+fork_handlers(%rip)
112 movb $1, fork_handler_init(%rip)
113 movq %rax, 16+fork_handlers(%rip)
114 xorl %eax, %eax
115 .L13:
116 movq %rax, %r8
117 addq $1, %rax
118 salq $5, %r8
119 addq 16+fork_handlers(%rip), %r8
120 movq %rax, fork_handlers(%rip)
121 testq %r8, %r8
122 je .L14
123 movq %r12, (%r8)
124 movq %rbp, 8(%r8)
125 movq %rbx, 16(%r8)
126 movq %rcx, 24(%r8)
127 .L14:
128 #APP
129 # 58 "register-atfork.c" 1
130 movl %fs:24,%eax
131 # 0 "" 2
132 #NO_APP
133 testl %eax, %eax
134 jne .L18
135 subl $1, atfork_lock(%rip)
136 .L19:
137 cmpq $1, %r8
138 sbbl %eax, %eax
139 addq $16, %rsp
140 popq %rbx
141 andl $12, %eax
142 popq %rbp
143 popq %r12
145 .p2align 4,,10
146 .p2align 3
147 .L12:
148 movq 8+fork_handlers(%rip), %rdx
149 cmpq $-1, %rdx
150 je .L21
151 movq fork_handlers(%rip), %rax
152 cmpq %rax, %rdx
153 jne .L13
154 leaq 24+fork_handlers(%rip), %rsi
155 movl $32, %edx
156 movq %rcx, 8(%rsp)
157 leaq -24(%rsi), %rdi
158 call __GI___libc_dynarray_emplace_enlarge
159 testb %al, %al
160 movq 8(%rsp), %rcx
161 je .L27
162 movq fork_handlers(%rip), %rax
163 jmp .L13
164 .p2align 4,,10
165 .p2align 3
166 .L10:
167 xorl %eax, %eax
168 movl $1, %edx
169 lock cmpxchgl %edx, atfork_lock(%rip)
170 je .L11
171 leaq atfork_lock(%rip), %rdi
172 movq %rcx, 8(%rsp)
173 call __lll_lock_wait_private
174 movq 8(%rsp), %rcx
175 jmp .L11
176 .p2align 4,,10
177 .p2align 3
178 .L18:
179 xorl %eax, %eax
180 #APP
181 # 58 "register-atfork.c" 1
182 xchgl %eax, atfork_lock(%rip)
183 # 0 "" 2
184 #NO_APP
185 cmpl $1, %eax
186 jle .L19
187 xorl %r10d, %r10d
188 movl $1, %edx
189 movl $129, %esi
190 leaq atfork_lock(%rip), %rdi
191 movl $202, %eax
192 #APP
193 # 58 "register-atfork.c" 1
194 syscall
196 # 0 "" 2
197 #NO_APP
198 jmp .L19
199 .p2align 4,,10
200 .p2align 3
201 .L21:
202 xorl %r8d, %r8d
203 jmp .L14
204 .L27:
205 movq 16+fork_handlers(%rip), %rdi
206 leaq 24+fork_handlers(%rip), %rbx
207 cmpq %rbx, %rdi
208 je .L16
209 call free@PLT
210 .L16:
211 movq %rbx, 16+fork_handlers(%rip)
212 movq $0, fork_handlers(%rip)
213 xorl %r8d, %r8d
214 movq $-1, 8+fork_handlers(%rip)
215 jmp .L14
216 .size __GI___register_atfork, .-__GI___register_atfork
217 .globl __register_atfork
218 .set __register_atfork,__GI___register_atfork
219 .p2align 4,,15
220 .globl __unregister_atfork
221 .hidden __unregister_atfork
222 .type __unregister_atfork, @function
223 __unregister_atfork:
224 pushq %rbx
225 movq %rdi, %rbx
226 #APP
227 # 80 "register-atfork.c" 1
228 movl %fs:24,%eax
229 # 0 "" 2
230 #NO_APP
231 testl %eax, %eax
232 jne .L29
233 movl $1, %edx
234 #APP
235 # 47 "../sysdeps/unix/sysv/linux/x86/lowlevellock.h" 1
236 cmpxchgl %edx, atfork_lock(%rip)
237 # 0 "" 2
238 #NO_APP
239 .L30:
240 movq fork_handlers(%rip), %rcx
241 testq %rcx, %rcx
242 je .L32
243 movq 16+fork_handlers(%rip), %rsi
244 cmpq 24(%rsi), %rbx
245 je .L46
246 leaq 32(%rsi), %rax
247 xorl %edx, %edx
248 jmp .L34
249 .p2align 4,,10
250 .p2align 3
251 .L35:
252 movq %rax, %r8
253 addq $32, %rax
254 cmpq -8(%rax), %rbx
255 je .L33
256 .L34:
257 addq $1, %rdx
258 cmpq %rdx, %rcx
259 jne .L35
260 .L32:
261 #APP
262 # 106 "register-atfork.c" 1
263 movl %fs:24,%eax
264 # 0 "" 2
265 #NO_APP
266 testl %eax, %eax
267 jne .L43
268 subl $1, atfork_lock(%rip)
269 .L28:
270 popq %rbx
272 .p2align 4,,10
273 .p2align 3
274 .L46:
275 movq %rsi, %r8
276 .p2align 4,,10
277 .p2align 3
278 .L33:
279 movq %rcx, %rax
280 leaq 32(%r8), %rdi
281 movq %r8, %rdx
282 salq $5, %rax
283 addq %rax, %rsi
284 movq %rdi, %rax
285 cmpq %rdi, %rsi
286 je .L45
287 .p2align 4,,10
288 .p2align 3
289 .L38:
290 cmpq %rbx, 24(%rax)
291 je .L37
292 movdqu (%rax), %xmm0
293 addq $32, %rdx
294 movups %xmm0, -32(%rdx)
295 movdqu 16(%rax), %xmm0
296 movups %xmm0, -16(%rdx)
297 .L37:
298 addq $32, %rax
299 cmpq %rax, %rsi
300 jne .L38
301 addq $64, %r8
302 subq %r8, %rsi
303 andq $-32, %rsi
304 leaq 32(%rdi,%rsi), %rdi
305 .L45:
306 subq %rdx, %rdi
307 movq %rdi, %rdx
308 sarq $5, %rdx
309 testq %rdx, %rdx
310 je .L32
311 xorl %esi, %esi
312 xorl %eax, %eax
313 .L42:
314 testq %rcx, %rcx
315 je .L58
316 subq $1, %rcx
317 movl $1, %esi
318 .L40:
319 addq $1, %rax
320 cmpq %rax, %rdx
321 jne .L42
322 testb %sil, %sil
323 je .L32
324 .L59:
325 movq %rcx, fork_handlers(%rip)
326 jmp .L32
327 .p2align 4,,10
328 .p2align 3
329 .L58:
330 addq $1, %rax
331 cmpq %rax, %rdx
332 jne .L40
333 testb %sil, %sil
334 je .L32
335 jmp .L59
336 .p2align 4,,10
337 .p2align 3
338 .L29:
339 xorl %eax, %eax
340 movl $1, %edx
341 lock cmpxchgl %edx, atfork_lock(%rip)
342 je .L30
343 leaq atfork_lock(%rip), %rdi
344 call __lll_lock_wait_private
345 jmp .L30
346 .p2align 4,,10
347 .p2align 3
348 .L43:
349 xorl %eax, %eax
350 #APP
351 # 106 "register-atfork.c" 1
352 xchgl %eax, atfork_lock(%rip)
353 # 0 "" 2
354 #NO_APP
355 cmpl $1, %eax
356 jle .L28
357 xorl %r10d, %r10d
358 movl $1, %edx
359 movl $129, %esi
360 leaq atfork_lock(%rip), %rdi
361 movl $202, %eax
362 #APP
363 # 106 "register-atfork.c" 1
364 syscall
366 # 0 "" 2
367 #NO_APP
368 popq %rbx
370 .size __unregister_atfork, .-__unregister_atfork
371 .p2align 4,,15
372 .globl __run_fork_handlers
373 .hidden __run_fork_handlers
374 .type __run_fork_handlers, @function
375 __run_fork_handlers:
376 pushq %r13
377 pushq %r12
378 movl %esi, %r12d
379 pushq %rbp
380 pushq %rbx
381 movl %edi, %ebp
382 subq $8, %rsp
383 testl %edi, %edi
384 jne .L61
385 testb %sil, %sil
386 je .L63
387 #APP
388 # 117 "register-atfork.c" 1
389 movl %fs:24,%eax
390 # 0 "" 2
391 #NO_APP
392 testl %eax, %eax
393 movl $1, %edx
394 jne .L64
395 #APP
396 # 47 "../sysdeps/unix/sysv/linux/x86/lowlevellock.h" 1
397 cmpxchgl %edx, atfork_lock(%rip)
398 # 0 "" 2
399 #NO_APP
400 .L63:
401 movq fork_handlers(%rip), %rbx
402 testq %rbx, %rbx
403 je .L60
404 leaq -1(%rbx), %rbp
405 salq $5, %rbx
406 subq $32, %rbx
407 .p2align 4,,10
408 .p2align 3
409 .L67:
410 movq 16+fork_handlers(%rip), %rax
411 movq (%rax,%rbx), %rax
412 testq %rax, %rax
413 je .L68
414 call *%rax
415 .L68:
416 testq %rbp, %rbp
417 je .L60
418 movq fork_handlers(%rip), %rdi
419 subq $1, %rbp
420 subq $32, %rbx
421 cmpq %rdi, %rbp
422 jb .L67
423 movq %rbp, %rsi
424 call __GI___libc_dynarray_at_failure
425 .p2align 4,,10
426 .p2align 3
427 .L61:
428 movq fork_handlers(%rip), %r13
429 xorl %ebx, %ebx
430 testq %r13, %r13
431 jne .L71
432 .p2align 4,,10
433 .p2align 3
434 .L76:
435 testb %r12b, %r12b
436 je .L60
437 #APP
438 # 138 "register-atfork.c" 1
439 movl %fs:24,%eax
440 # 0 "" 2
441 #NO_APP
442 testl %eax, %eax
443 jne .L77
444 subl $1, atfork_lock(%rip)
445 .L60:
446 addq $8, %rsp
447 popq %rbx
448 popq %rbp
449 popq %r12
450 popq %r13
452 .p2align 4,,10
453 .p2align 3
454 .L73:
455 cmpl $2, %ebp
456 je .L94
457 .L74:
458 addq $1, %rbx
459 cmpq %r13, %rbx
460 je .L76
461 movq fork_handlers(%rip), %rdi
462 cmpq %rdi, %rbx
463 jnb .L95
464 .L71:
465 movq %rbx, %rdx
466 salq $5, %rdx
467 addq 16+fork_handlers(%rip), %rdx
468 cmpl $1, %ebp
469 jne .L73
470 movq 16(%rdx), %rax
471 testq %rax, %rax
472 je .L74
473 call *%rax
474 jmp .L74
475 .p2align 4,,10
476 .p2align 3
477 .L94:
478 movq 8(%rdx), %rax
479 testq %rax, %rax
480 je .L74
481 call *%rax
482 jmp .L74
483 .p2align 4,,10
484 .p2align 3
485 .L95:
486 movq %rbx, %rsi
487 call __GI___libc_dynarray_at_failure
488 .p2align 4,,10
489 .p2align 3
490 .L64:
491 movl %edi, %eax
492 lock cmpxchgl %edx, atfork_lock(%rip)
493 je .L63
494 leaq atfork_lock(%rip), %rdi
495 call __lll_lock_wait_private
496 jmp .L63
497 .L77:
498 xorl %eax, %eax
499 #APP
500 # 138 "register-atfork.c" 1
501 xchgl %eax, atfork_lock(%rip)
502 # 0 "" 2
503 #NO_APP
504 cmpl $1, %eax
505 jle .L60
506 xorl %r10d, %r10d
507 movl $1, %edx
508 movl $129, %esi
509 leaq atfork_lock(%rip), %rdi
510 movl $202, %eax
511 #APP
512 # 138 "register-atfork.c" 1
513 syscall
515 # 0 "" 2
516 #NO_APP
517 jmp .L60
518 .size __run_fork_handlers, .-__run_fork_handlers
519 .section __libc_subfreeres,"aw",@progbits
520 .align 8
521 .type __elf_set___libc_subfreeres_element_free_mem__, @object
522 .size __elf_set___libc_subfreeres_element_free_mem__, 8
523 __elf_set___libc_subfreeres_element_free_mem__:
524 .quad free_mem
525 .local atfork_lock
526 .comm atfork_lock,4,4
527 .local fork_handler_init
528 .comm fork_handler_init,1,1
529 .local fork_handlers
530 .comm fork_handlers,1560,32
531 .hidden __lll_lock_wait_private