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