Some broken software wants to deal with ld.so.cache.
[nyanglibc.git] / iconv / gconv_cache.shared.s.in
blob79171760cac6dc7ea8373cfbd445e21bc5e159e7
1 .text
2 #APP
3 memmove = __GI_memmove
4 memset = __GI_memset
5 memcpy = __GI_memcpy
6 #NO_APP
7 .p2align 4,,15
8 .type find_module_idx, @function
9 find_module_idx:
10 pushq %r15
11 pushq %r14
12 pushq %r13
13 pushq %r12
14 pushq %rbp
15 pushq %rbx
16 subq $40, %rsp
17 movq gconv_cache(%rip), %r14
18 movq %rdi, 16(%rsp)
19 movq %rsi, 24(%rsp)
20 movzwl 4(%r14), %eax
21 movzwl 6(%r14), %r12d
22 movq %rax, 8(%rsp)
23 call __hash_string
24 movzwl 8(%r14), %r13d
25 xorl %edx, %edx
26 movl %eax, %ebp
27 movl cache_size(%rip), %edi
28 divl %r13d
29 leal -2(%r13), %esi
30 movl %ebp, %eax
31 movl %edx, %ebx
32 xorl %edx, %edx
33 divl %esi
34 movzwl 4(%r14), %eax
35 subl %eax, %edi
36 leal 1(%rdx), %ebp
37 movl %edi, 4(%rsp)
38 jmp .L5
39 .p2align 4,,10
40 .p2align 3
41 .L6:
42 movzwl %si, %eax
43 cmpl 4(%rsp), %eax
44 jnb .L3
45 addq 8(%rsp), %rsi
46 movq 16(%rsp), %rdi
47 addq %r14, %rsi
48 call __GI_strcmp
49 testl %eax, %eax
50 je .L10
51 .L3:
52 addl %ebp, %ebx
53 movl %ebx, %edx
54 movl %ebx, %eax
55 subl %r13d, %edx
56 cmpl %ebx, %r13d
57 cmovbe %edx, %eax
58 movl %eax, %ebx
59 .L5:
60 movl %ebx, %eax
61 leaq (%r12,%rax,4), %rdx
62 leaq (%r14,%rdx), %r15
63 movzwl (%r15), %esi
64 testw %si, %si
65 jne .L6
66 addq $40, %rsp
67 movl $-1, %eax
68 popq %rbx
69 popq %rbp
70 popq %r12
71 popq %r13
72 popq %r14
73 popq %r15
74 ret
75 .p2align 4,,10
76 .p2align 3
77 .L10:
78 movzwl 2(%r15), %edx
79 movq 24(%rsp), %rdi
80 movq %rdx, (%rdi)
81 addq $40, %rsp
82 popq %rbx
83 popq %rbp
84 popq %r12
85 popq %r13
86 popq %r14
87 popq %r15
88 ret
89 .size find_module_idx, .-find_module_idx
90 .p2align 4,,15
91 .type find_module, @function
92 find_module:
93 pushq %rbp
94 movq %rsp, %rbp
95 pushq %r15
96 pushq %r14
97 pushq %r13
98 pushq %r12
99 movq %rsi, %r13
100 pushq %rbx
101 movq %rdi, %r14
102 movq %rdx, %rbx
103 subq $8, %rsp
104 call __GI_strlen
105 movq %r13, %rdi
106 movq %rax, %r15
107 call __GI_strlen
108 leaq 1(%rax), %r12
109 movq %r15, %rdx
110 movq %r14, %rsi
111 leaq 15(%r12,%r15), %rax
112 andq $-16, %rax
113 subq %rax, %rsp
114 movq %rsp, %rdi
115 call __GI_mempcpy@PLT
116 movq %r12, %rdx
117 movq %r13, %rsi
118 movq %rax, %rdi
119 call __GI_memcpy@PLT
120 movq %rsp, %rdi
121 call __gconv_find_shlib
122 movq %rax, %rdx
123 movq %rax, (%rbx)
124 movl $1, %eax
125 testq %rdx, %rdx
126 je .L11
127 movq 24(%rdx), %rax
128 movq 32(%rdx), %r12
129 movq $0, 8(%rbx)
130 movq %rax, 40(%rbx)
131 movq 40(%rdx), %rax
132 movq %r12, 56(%rbx)
133 movq $0, 48(%rbx)
134 #APP
135 # 209 "/root/nyanlinux/src/glibc-2.33/iconv/gconv_cache.c" 1
136 ror $2*8+1, %r12
137 xor %fs:48, %r12
138 # 0 "" 2
139 #NO_APP
140 movq %rax, 64(%rbx)
141 xorl %eax, %eax
142 testq %r12, %r12
143 movq $0, 96(%rbx)
144 je .L11
145 movq %r12, %rdi
146 call __GI__dl_mcount_wrapper_check
147 movq %rbx, %rdi
148 call *%r12
149 movq 48(%rbx), %rdx
150 #APP
151 # 216 "/root/nyanlinux/src/glibc-2.33/iconv/gconv_cache.c" 1
152 xor %fs:48, %rdx
153 rol $2*8+1, %rdx
154 # 0 "" 2
155 #NO_APP
156 movq %rdx, 48(%rbx)
157 .L11:
158 leaq -40(%rbp), %rsp
159 popq %rbx
160 popq %r12
161 popq %r13
162 popq %r14
163 popq %r15
164 popq %rbp
166 .size find_module, .-find_module
167 .section __libc_freeres_fn,"ax",@progbits
168 .p2align 4,,15
169 .type free_mem, @function
170 free_mem:
171 movl cache_malloced(%rip), %eax
172 movq gconv_cache(%rip), %rdi
173 testl %eax, %eax
174 jne .L21
175 testq %rdi, %rdi
176 je .L18
177 movq cache_size(%rip), %rsi
178 jmp __GI___munmap
179 .p2align 4,,10
180 .p2align 3
181 .L18:
182 rep ret
183 .p2align 4,,10
184 .p2align 3
185 .L21:
186 jmp free@PLT
187 .size free_mem, .-free_mem
188 .text
189 .p2align 4,,15
190 .globl __gconv_get_cache
191 .type __gconv_get_cache, @function
192 __gconv_get_cache:
193 movq gconv_cache(%rip), %rax
195 .size __gconv_get_cache, .-__gconv_get_cache
196 .section .rodata.str1.1,"aMS",@progbits,1
197 .LC0:
198 .string "GCONV_PATH"
199 .section .rodata.str1.8,"aMS",@progbits,1
200 .align 8
201 .LC1:
202 .string "CONF_PREFIX/lib/gconv"
203 .text
204 .p2align 4,,15
205 .globl __gconv_load_cache
206 .hidden __gconv_load_cache
207 .type __gconv_load_cache, @function
208 __gconv_load_cache:
209 pushq %r12
210 pushq %rbx
211 leaq .LC0(%rip), %rdi
212 subq $168, %rsp
213 call __GI_getenv
214 testq %rax, %rax
215 movq %rax, __gconv_path_envvar(%rip)
216 jne .L50
217 leaq .LC1(%rip), %rdi
218 xorl %edx, %edx
219 xorl %esi, %esi
220 xorl %eax, %eax
221 call __GI___open_nocancel
222 cmpl $-1, %eax
223 movl %eax, %ebx
224 je .L50
225 leaq 16(%rsp), %rsi
226 movl %eax, %edi
227 call __GI___fstat64
228 testl %eax, %eax
229 js .L28
230 movq 64(%rsp), %rsi
231 cmpq $15, %rsi
232 jbe .L28
233 xorl %r9d, %r9d
234 xorl %edi, %edi
235 movl %ebx, %r8d
236 movl $1, %ecx
237 movl $1, %edx
238 movq %rsi, cache_size(%rip)
239 call __GI___mmap
240 cmpq $-1, %rax
241 movq %rax, gconv_cache(%rip)
242 je .L51
243 .L31:
244 movl %ebx, %edi
245 call __GI___close_nocancel
246 movq gconv_cache(%rip), %rdi
247 cmpl $536937252, (%rdi)
248 jne .L35
249 movzwl 4(%rdi), %eax
250 movq cache_size(%rip), %rdx
251 cmpq %rdx, %rax
252 jnb .L35
253 movzwl 6(%rdi), %ecx
254 cmpq %rcx, %rdx
255 jbe .L35
256 movzwl 8(%rdi), %eax
257 testw %ax, %ax
258 je .L35
259 leaq (%rcx,%rax,4), %rax
260 cmpq %rax, %rdx
261 jb .L35
262 movzwl 10(%rdi), %eax
263 cmpq %rax, %rdx
264 jbe .L35
265 movzwl 12(%rdi), %ecx
266 xorl %eax, %eax
267 cmpq %rcx, %rdx
268 jnb .L23
269 .p2align 4,,10
270 .p2align 3
271 .L35:
272 movl cache_malloced(%rip), %eax
273 testl %eax, %eax
274 jne .L52
275 movq cache_size(%rip), %rsi
276 call __GI___munmap
277 .L37:
278 movq $0, gconv_cache(%rip)
279 .L50:
280 movl $-1, %eax
281 .L23:
282 addq $168, %rsp
283 popq %rbx
284 popq %r12
286 .p2align 4,,10
287 .p2align 3
288 .L52:
289 call free@PLT
290 movl $0, cache_malloced(%rip)
291 jmp .L37
292 .p2align 4,,10
293 .p2align 3
294 .L51:
295 movq cache_size(%rip), %rdx
296 movq %rdx, %rdi
297 movq %rdx, 8(%rsp)
298 call malloc@PLT
299 testq %rax, %rax
300 movq %rax, gconv_cache(%rip)
301 je .L28
302 xorl %r12d, %r12d
303 movq 8(%rsp), %rdx
304 jmp .L34
305 .p2align 4,,10
306 .p2align 3
307 .L32:
308 movq cache_size(%rip), %rdx
309 addq %rax, %r12
310 cmpq %r12, %rdx
311 jbe .L33
312 movq gconv_cache(%rip), %rax
313 .L34:
314 leaq (%rax,%r12), %rsi
315 subq %r12, %rdx
316 movl %ebx, %edi
317 call __GI___read
318 cmpq $-1, %rax
319 jne .L32
320 movq gconv_cache(%rip), %rdi
321 call free@PLT
322 movq $0, gconv_cache(%rip)
323 .L28:
324 movl %ebx, %edi
325 call __GI___close_nocancel
326 addq $168, %rsp
327 movl $-1, %eax
328 popq %rbx
329 popq %r12
331 .p2align 4,,10
332 .p2align 3
333 .L33:
334 movl $1, cache_malloced(%rip)
335 jmp .L31
336 .size __gconv_load_cache, .-__gconv_load_cache
337 .p2align 4,,15
338 .globl __gconv_compare_alias_cache
339 .hidden __gconv_compare_alias_cache
340 .type __gconv_compare_alias_cache, @function
341 __gconv_compare_alias_cache:
342 cmpq $0, gconv_cache(%rip)
343 je .L57
344 pushq %r12
345 pushq %rbp
346 movq %rsi, %rbp
347 pushq %rbx
348 movq %rdx, %r12
349 movq %rdi, %rbx
350 subq $16, %rsp
351 movq %rsp, %rsi
352 call find_module_idx
353 testl %eax, %eax
354 je .L55
355 .L56:
356 movq %rbp, %rsi
357 movq %rbx, %rdi
358 call __GI_strcmp
359 movl %eax, (%r12)
360 addq $16, %rsp
361 xorl %eax, %eax
362 popq %rbx
363 popq %rbp
364 popq %r12
366 .p2align 4,,10
367 .p2align 3
368 .L55:
369 leaq 8(%rsp), %rsi
370 movq %rbp, %rdi
371 call find_module_idx
372 testl %eax, %eax
373 jne .L56
374 movq (%rsp), %rdx
375 subl 8(%rsp), %edx
376 movl %edx, (%r12)
377 addq $16, %rsp
378 popq %rbx
379 popq %rbp
380 popq %r12
382 .p2align 4,,10
383 .p2align 3
384 .L57:
385 movl $-1, %eax
387 .size __gconv_compare_alias_cache, .-__gconv_compare_alias_cache
388 .section .rodata.str1.1
389 .LC2:
390 .string "INTERNAL"
391 .text
392 .p2align 4,,15
393 .globl __gconv_lookup_cache
394 .hidden __gconv_lookup_cache
395 .type __gconv_lookup_cache, @function
396 __gconv_lookup_cache:
397 pushq %r15
398 pushq %r14
399 pushq %r13
400 pushq %r12
401 pushq %rbp
402 pushq %rbx
403 movl $2, %ebx
404 subq $88, %rsp
405 movq gconv_cache(%rip), %r13
406 testq %r13, %r13
407 je .L62
408 movq %rsi, %rax
409 leaq 64(%rsp), %rsi
410 movq %rdi, %rbx
411 movq %rax, %rdi
412 movl %r8d, %r12d
413 movq %rcx, %rbp
414 movq %rdx, 8(%rsp)
415 movzwl 4(%r13), %r15d
416 movzwl 10(%r13), %r14d
417 call find_module_idx
418 testl %eax, %eax
419 jne .L65
420 movq 64(%rsp), %rax
421 leaq 3(%rax,%rax,2), %rdx
422 movzwl 10(%r13), %eax
423 salq $2, %rdx
424 addq %rdx, %rax
425 cmpq cache_size(%rip), %rax
426 jbe .L139
427 .L65:
428 movl $1, %ebx
429 .L62:
430 addq $88, %rsp
431 movl %ebx, %eax
432 popq %rbx
433 popq %rbp
434 popq %r12
435 popq %r13
436 popq %r14
437 popq %r15
439 .p2align 4,,10
440 .p2align 3
441 .L139:
442 leaq 72(%rsp), %rsi
443 movq %rbx, %rdi
444 movq %rdx, 16(%rsp)
445 call find_module_idx
446 testl %eax, %eax
447 movl %eax, %ebx
448 jne .L65
449 movq 72(%rsp), %rax
450 movzwl 10(%r13), %esi
451 leaq 3(%rax,%rax,2), %rcx
452 salq $2, %rcx
453 addq %rcx, %rsi
454 cmpq cache_size(%rip), %rsi
455 ja .L65
456 addq %r13, %r14
457 andl $1, %r12d
458 movq 64(%rsp), %rsi
459 leaq -12(%r14,%rcx), %rcx
460 movq 16(%rsp), %rdx
461 jne .L140
462 .L66:
463 addq %r13, %r15
464 testq %rax, %rax
465 leaq -12(%r14,%rdx), %r12
466 je .L67
467 testq %rsi, %rsi
468 jne .L141
469 .L67:
470 testq %rsi, %rsi
471 jne .L68
472 cmpq $0, 72(%rsp)
473 je .L65
474 cmpw $0, 8(%rcx)
475 je .L65
476 movl $208, %edi
477 movq %rsi, 24(%rsp)
478 movq %rcx, 16(%rsp)
479 call malloc@PLT
480 testq %rax, %rax
481 movq %rax, %r14
482 movq 16(%rsp), %rcx
483 movq 24(%rsp), %rsi
484 je .L83
485 movq 8(%rsp), %rax
486 leaq .LC2(%rip), %r13
487 xorl %r12d, %r12d
488 movq %r14, (%rax)
489 movq $0, 0(%rbp)
490 .L82:
491 movzwl (%rcx), %eax
492 addq %r14, %rsi
493 movzwl 2(%rcx), %edi
494 movq %r13, 24(%rsi)
495 movl $1, 16(%rsi)
496 movq $0, 96(%rsi)
497 addq %r15, %rax
498 addq %r15, %rdi
499 movq %rax, 32(%rsi)
500 movzwl 4(%rcx), %eax
501 addq %r15, %rax
502 cmpb $0, (%rdi)
503 je .L78
504 movq %rsi, %rdx
505 movq %rax, %rsi
506 call find_module
507 testl %eax, %eax
508 movl %eax, %r13d
509 jne .L142
510 .L79:
511 addq $1, 0(%rbp)
512 jmp .L62
513 .p2align 4,,10
514 .p2align 3
515 .L141:
516 movzwl 10(%r12), %edx
517 testw %dx, %dx
518 je .L68
519 movzwl 12(%r13), %esi
520 leaq -1(%rsi,%rdx), %r8
521 addq gconv_cache(%rip), %r8
522 movzwl (%r8), %edx
523 testw %dx, %dx
524 je .L68
525 movzwl %dx, %esi
526 subl $1, %esi
527 movslq %esi, %rsi
528 imulq $6, %rsi, %rsi
529 movzwl 2(%r8,%rsi), %esi
530 cmpq %rsi, %rax
531 jne .L70
532 jmp .L69
533 .p2align 4,,10
534 .p2align 3
535 .L143:
536 movzwl %dx, %esi
537 subl $1, %esi
538 movslq %esi, %rsi
539 leaq (%rsi,%rsi,2), %rsi
540 movzwl 2(%r8,%rsi,2), %esi
541 cmpq %rsi, %rax
542 je .L69
543 .L70:
544 leaq (%rdx,%rdx,2), %rdx
545 leaq 2(%r8,%rdx,2), %r8
546 movzwl (%r8), %edx
547 testw %dx, %dx
548 jne .L143
549 .p2align 4,,10
550 .p2align 3
551 .L68:
552 cmpw $0, 4(%r12)
553 je .L65
554 cmpq $0, 72(%rsp)
555 je .L89
556 cmpw $0, 8(%rcx)
557 je .L65
558 .L89:
559 movl $208, %edi
560 movq %rcx, 16(%rsp)
561 call malloc@PLT
562 testq %rax, %rax
563 movq %rax, %r14
564 movq 16(%rsp), %rcx
565 je .L83
566 movq 8(%rsp), %rax
567 movzwl 6(%r12), %edi
568 leaq .LC2(%rip), %r13
569 movq %r14, (%rax)
570 movzwl (%r12), %eax
571 addq %r15, %rdi
572 movq $0, 0(%rbp)
573 movq %r13, 32(%r14)
574 movl $1, 16(%r14)
575 movq $0, 96(%r14)
576 addq %r15, %rax
577 movq %rax, 24(%r14)
578 movzwl 8(%r12), %eax
579 addq %r15, %rax
580 cmpb $0, (%rdi)
581 je .L144
582 movq %r14, %rdx
583 movq %rax, %rsi
584 movq %rcx, 8(%rsp)
585 call find_module
586 testl %eax, %eax
587 movq 8(%rsp), %rcx
588 jne .L145
589 .L76:
590 movq 0(%rbp), %rax
591 addq $1, %rax
592 cmpq $0, 72(%rsp)
593 movq %rax, 0(%rbp)
594 je .L62
595 movl %eax, %r12d
596 cltq
597 imulq $104, %rax, %rsi
598 jmp .L82
599 .L78:
600 movq %rax, %rdi
601 call __gconv_get_builtin_trans
602 jmp .L79
603 .L144:
604 movq %r14, %rsi
605 movq %rax, %rdi
606 movq %rcx, 8(%rsp)
607 call __gconv_get_builtin_trans
608 movq 8(%rsp), %rcx
609 jmp .L76
610 .L83:
611 movl $3, %ebx
612 jmp .L62
613 .L140:
614 cmpq %rsi, %rax
615 jne .L66
616 orl $-1, %ebx
617 jmp .L62
618 .L142:
619 testl %r12d, %r12d
620 je .L80
621 movq %r14, %rdi
622 call __gconv_release_step
623 .L80:
624 movq %r14, %rdi
625 movl %r13d, %ebx
626 call free@PLT
627 jmp .L62
628 .L145:
629 movq %r14, %rdi
630 movl %eax, 8(%rsp)
631 call free@PLT
632 movl 8(%rsp), %eax
633 movl %eax, %ebx
634 jmp .L62
635 .L69:
636 imulq $104, %rdx, %rdi
637 movq %rdx, 0(%rbp)
638 movq %r8, 32(%rsp)
639 movq %rcx, 16(%rsp)
640 call malloc@PLT
641 movq 8(%rsp), %rcx
642 testq %rax, %rax
643 movq %rax, 24(%rsp)
644 movq 32(%rsp), %r8
645 movq %rax, (%rcx)
646 movq 16(%rsp), %rcx
647 je .L83
648 movzwl (%r12), %r10d
649 movq 24(%rsp), %r9
650 leaq 2(%r8), %r11
651 movq %r12, 40(%rsp)
652 movl %ebx, 32(%rsp)
653 movq %r15, %r12
654 movq %rbp, 56(%rsp)
655 movl $0, 16(%rsp)
656 movq %r11, %rbx
657 movq %rcx, 48(%rsp)
658 movq %r9, %r13
659 addq %r15, %r10
660 movq %r8, %r15
661 movq %r10, %rbp
662 jmp .L73
663 .L148:
664 movq %r13, %rdx
665 movq %rax, %rsi
666 call find_module
667 testl %eax, %eax
668 jne .L146
669 .L72:
670 addl $1, 16(%rsp)
671 movzwl (%r15), %eax
672 addq $104, %r13
673 movl 16(%rsp), %ecx
674 addq $6, %rbx
675 cmpl %ecx, %eax
676 jle .L147
677 .L73:
678 movzwl (%rbx), %eax
679 movzwl 2(%rbx), %edi
680 movq %rbp, 24(%r13)
681 leaq (%rax,%rax,2), %rax
682 addq %r12, %rdi
683 movzwl (%r14,%rax,4), %r10d
684 movzwl 4(%rbx), %eax
685 movl $1, 16(%r13)
686 movq $0, 96(%r13)
687 leaq (%r12,%r10), %rbp
688 addq %r12, %rax
689 movq %rbp, 32(%r13)
690 cmpb $0, (%rdi)
691 jne .L148
692 movq %r13, %rsi
693 movq %rax, %rdi
694 call __gconv_get_builtin_trans
695 jmp .L72
696 .L147:
697 movl 32(%rsp), %ebx
698 jmp .L62
699 .L146:
700 movq 48(%rsp), %rcx
701 movq 24(%rsp), %rdi
702 movq %r12, %r15
703 movl 32(%rsp), %ebx
704 movq 40(%rsp), %r12
705 movq 56(%rsp), %rbp
706 movq %rcx, 16(%rsp)
707 call free@PLT
708 movq 64(%rsp), %rsi
709 movq 16(%rsp), %rcx
710 jmp .L67
711 .size __gconv_lookup_cache, .-__gconv_lookup_cache
712 .p2align 4,,15
713 .globl __gconv_release_cache
714 .hidden __gconv_release_cache
715 .type __gconv_release_cache, @function
716 __gconv_release_cache:
717 cmpq $0, gconv_cache(%rip)
718 je .L149
719 jmp free@PLT
720 .p2align 4,,10
721 .p2align 3
722 .L149:
723 rep ret
724 .size __gconv_release_cache, .-__gconv_release_cache
725 .section __libc_subfreeres,"aw",@progbits
726 .align 8
727 .type __elf_set___libc_subfreeres_element_free_mem__, @object
728 .size __elf_set___libc_subfreeres_element_free_mem__, 8
729 __elf_set___libc_subfreeres_element_free_mem__:
730 .quad free_mem
731 .local cache_malloced
732 .comm cache_malloced,4,4
733 .local cache_size
734 .comm cache_size,8,8
735 .local gconv_cache
736 .comm gconv_cache,8,8
737 .hidden __gconv_release_step
738 .hidden __gconv_get_builtin_trans
739 .hidden __gconv_path_envvar
740 .hidden __gconv_find_shlib
741 .hidden __hash_string