clarify the purpose of this project
[nyanglibc.git] / stdlib / system.shared.s
blobced0e7687f196c4c77955c3d2d8e9da4b14eff41
1 .text
2 #APP
3 memmove = __GI_memmove
4 memset = __GI_memset
5 memcpy = __GI_memcpy
6 .section .rodata.str1.1,"aMS",@progbits,1
7 .LC0:
8 .string "sh"
9 .LC1:
10 .string "-c"
11 .LC2:
12 .string "/bin/sh"
13 #NO_APP
14 .text
15 .p2align 4,,15
16 .type do_system, @function
17 do_system:
18 pushq %r13
19 pushq %r12
20 pushq %rbp
21 pushq %rbx
22 movq %rdi, %rbp
23 subq $872, %rsp
24 movl $-1, 8(%rsp)
25 movq $1, 368(%rsp)
26 movl $0, 504(%rsp)
27 movq $0, 376(%rsp)
28 #APP
29 # 118 "../sysdeps/posix/system.c" 1
30 movl %fs:24,%eax
31 # 0 "" 2
32 #NO_APP
33 testl %eax, %eax
34 jne .L2
35 movl $1, %edx
36 #APP
37 # 47 "../sysdeps/unix/sysv/linux/x86/lowlevellock.h" 1
38 cmpxchgl %edx, lock(%rip)
39 # 0 "" 2
40 #NO_APP
41 .L3:
42 movl sa_refcntr(%rip), %eax
43 leaq 368(%rsp), %rbx
44 leal 1(%rax), %edx
45 testl %eax, %eax
46 movl %edx, sa_refcntr(%rip)
47 je .L34
48 .L4:
49 #APP
50 # 125 "../sysdeps/posix/system.c" 1
51 movl %fs:24,%eax
52 # 0 "" 2
53 #NO_APP
54 testl %eax, %eax
55 jne .L5
56 subl $1, lock(%rip)
57 .L6:
58 leaq 112(%rsp), %r12
59 leaq 8(%rbx), %rsi
60 xorl %edi, %edi
61 orq $65536, 376(%rsp)
62 movq %r12, %rdx
63 call __GI___sigprocmask
64 cmpq $1, intr(%rip)
65 movq $0, 240(%rsp)
66 je .L7
67 movq $2, 240(%rsp)
68 .L7:
69 cmpq $1, quit(%rip)
70 je .L8
71 orq $4, 240(%rsp)
72 .L8:
73 leaq 528(%rsp), %rbx
74 movq %rbx, %rdi
75 call __posix_spawnattr_init
76 movq %r12, %rsi
77 movq %rbx, %rdi
78 call __posix_spawnattr_setsigmask
79 leaq 240(%rsp), %rsi
80 movq %rbx, %rdi
81 call __posix_spawnattr_setsigdefault
82 movl $12, %esi
83 movq %rbx, %rdi
84 call __posix_spawnattr_setflags
85 movq __environ@GOTPCREL(%rip), %rax
86 leaq 12(%rsp), %rdi
87 leaq 48(%rsp), %r8
88 leaq .LC2(%rip), %rsi
89 xorl %edx, %edx
90 movq %rbx, %rcx
91 movq %rbp, 64(%rsp)
92 movq $0, 72(%rsp)
93 movq (%rax), %r9
94 leaq .LC0(%rip), %rax
95 movq %rax, 48(%rsp)
96 leaq .LC1(%rip), %rax
97 movq %rax, 56(%rsp)
98 call __GI___posix_spawn
99 movq %rbx, %rdi
100 movl %eax, %ebp
101 call __posix_spawnattr_destroy
102 testl %ebp, %ebp
103 jne .L9
104 leaq quit(%rip), %rax
105 movl __libc_pthread_functions_init(%rip), %r13d
106 movl 12(%rsp), %edi
107 movq %rax, 16(%rsp)
108 leaq intr(%rip), %rax
109 testl %r13d, %r13d
110 movl %edi, 32(%rsp)
111 movq %rax, 24(%rsp)
112 je .L10
113 movq 184+__libc_pthread_functions(%rip), %rax
114 leaq 80(%rsp), %rdi
115 leaq 16(%rsp), %rdx
116 #APP
117 # 167 "../sysdeps/posix/system.c" 1
118 ror $2*8+1, %rax
119 xor %fs:48, %rax
120 # 0 "" 2
121 #NO_APP
122 leaq cancel_handler(%rip), %rsi
123 call *%rax
124 movl 12(%rsp), %edi
125 .L11:
126 leaq 8(%rsp), %rbx
127 jmp .L13
128 .p2align 4,,10
129 .p2align 3
130 .L35:
131 movq __libc_errno@gottpoff(%rip), %rdx
132 cmpl $4, %fs:(%rdx)
133 jne .L14
134 .L13:
135 xorl %edx, %edx
136 movq %rbx, %rsi
137 call __GI___waitpid
138 cmpl $-1, %eax
139 movl 12(%rsp), %edi
140 je .L35
141 .L14:
142 cmpl %edi, %eax
143 je .L15
144 movl $-1, 8(%rsp)
145 .L15:
146 testl %r13d, %r13d
147 je .L17
148 movq 192+__libc_pthread_functions(%rip), %rax
149 leaq 80(%rsp), %rdi
150 xorl %esi, %esi
151 #APP
152 # 175 "../sysdeps/posix/system.c" 1
153 ror $2*8+1, %rax
154 xor %fs:48, %rax
155 # 0 "" 2
156 #NO_APP
157 call *%rax
158 jmp .L17
159 .p2align 4,,10
160 .p2align 3
161 .L9:
162 movl $32512, 8(%rsp)
163 .L17:
164 #APP
165 # 183 "../sysdeps/posix/system.c" 1
166 movl %fs:24,%eax
167 # 0 "" 2
168 #NO_APP
169 testl %eax, %eax
170 jne .L18
171 movl $1, %edx
172 #APP
173 # 47 "../sysdeps/unix/sysv/linux/x86/lowlevellock.h" 1
174 cmpxchgl %edx, lock(%rip)
175 # 0 "" 2
176 #NO_APP
177 .L19:
178 subl $1, sa_refcntr(%rip)
179 je .L36
180 .L20:
181 #APP
182 # 192 "../sysdeps/posix/system.c" 1
183 movl %fs:24,%eax
184 # 0 "" 2
185 #NO_APP
186 testl %eax, %eax
187 jne .L21
188 subl $1, lock(%rip)
189 .L22:
190 testl %ebp, %ebp
191 je .L23
192 movq __libc_errno@gottpoff(%rip), %rax
193 movl %ebp, %fs:(%rax)
194 .L23:
195 movl 8(%rsp), %eax
196 addq $872, %rsp
197 popq %rbx
198 popq %rbp
199 popq %r12
200 popq %r13
202 .p2align 4,,10
203 .p2align 3
204 .L34:
205 leaq intr(%rip), %rdx
206 movq %rbx, %rsi
207 movl $2, %edi
208 call __GI___sigaction
209 leaq quit(%rip), %rdx
210 movq %rbx, %rsi
211 movl $3, %edi
212 call __GI___sigaction
213 jmp .L4
214 .p2align 4,,10
215 .p2align 3
216 .L36:
217 leaq intr(%rip), %rsi
218 xorl %edx, %edx
219 movl $2, %edi
220 call __GI___sigaction
221 leaq quit(%rip), %rsi
222 xorl %edx, %edx
223 movl $3, %edi
224 call __GI___sigaction
225 xorl %edx, %edx
226 movq %r12, %rsi
227 movl $2, %edi
228 call __GI___sigprocmask
229 jmp .L20
230 .p2align 4,,10
231 .p2align 3
232 .L10:
233 leaq cancel_handler(%rip), %rax
234 movq %rax, 80(%rsp)
235 leaq 16(%rsp), %rax
236 movq %rax, 88(%rsp)
237 jmp .L11
238 .p2align 4,,10
239 .p2align 3
240 .L18:
241 xorl %eax, %eax
242 movl $1, %edx
243 lock cmpxchgl %edx, lock(%rip)
244 je .L19
245 leaq lock(%rip), %rdi
246 call __lll_lock_wait_private
247 jmp .L19
248 .p2align 4,,10
249 .p2align 3
250 .L5:
251 xorl %eax, %eax
252 #APP
253 # 125 "../sysdeps/posix/system.c" 1
254 xchgl %eax, lock(%rip)
255 # 0 "" 2
256 #NO_APP
257 cmpl $1, %eax
258 jle .L6
259 xorl %r10d, %r10d
260 movl $1, %edx
261 movl $129, %esi
262 leaq lock(%rip), %rdi
263 movl $202, %eax
264 #APP
265 # 125 "../sysdeps/posix/system.c" 1
266 syscall
268 # 0 "" 2
269 #NO_APP
270 jmp .L6
271 .p2align 4,,10
272 .p2align 3
273 .L21:
274 xorl %eax, %eax
275 #APP
276 # 192 "../sysdeps/posix/system.c" 1
277 xchgl %eax, lock(%rip)
278 # 0 "" 2
279 #NO_APP
280 cmpl $1, %eax
281 jle .L22
282 xorl %r10d, %r10d
283 movl $1, %edx
284 movl $129, %esi
285 leaq lock(%rip), %rdi
286 movl $202, %eax
287 #APP
288 # 192 "../sysdeps/posix/system.c" 1
289 syscall
291 # 0 "" 2
292 #NO_APP
293 jmp .L22
294 .p2align 4,,10
295 .p2align 3
296 .L2:
297 xorl %eax, %eax
298 movl $1, %edx
299 lock cmpxchgl %edx, lock(%rip)
300 je .L3
301 leaq lock(%rip), %rdi
302 call __lll_lock_wait_private
303 jmp .L3
304 .size do_system, .-do_system
305 .p2align 4,,15
306 .type cancel_handler, @function
307 cancel_handler:
308 pushq %rbx
309 movl $9, %esi
310 movq %rdi, %rbx
311 movl $62, %eax
312 subq $16, %rsp
313 movl 16(%rdi), %edi
314 #APP
315 # 43 "../sysdeps/unix/sysv/linux/not-errno.h" 1
316 syscall
318 # 0 "" 2
319 #NO_APP
320 movl __libc_pthread_functions_init(%rip), %edx
321 testl %edx, %edx
322 je .L40
323 movq 104+__libc_pthread_functions(%rip), %rax
324 leaq 12(%rsp), %rsi
325 movl $1, %edi
326 #APP
327 # 85 "../sysdeps/posix/system.c" 1
328 ror $2*8+1, %rax
329 xor %fs:48, %rax
330 # 0 "" 2
331 #NO_APP
332 call *%rax
333 jmp .L40
334 .p2align 4,,10
335 .p2align 3
336 .L49:
337 movq __libc_errno@gottpoff(%rip), %rax
338 cmpl $4, %fs:(%rax)
339 jne .L39
340 .L40:
341 movl 16(%rbx), %edi
342 xorl %edx, %edx
343 xorl %esi, %esi
344 call __GI___waitpid
345 cmpl $-1, %eax
346 je .L49
347 .L39:
348 movl __libc_pthread_functions_init(%rip), %eax
349 testl %eax, %eax
350 je .L41
351 movq 104+__libc_pthread_functions(%rip), %rax
352 xorl %esi, %esi
353 movl 12(%rsp), %edi
354 #APP
355 # 88 "../sysdeps/posix/system.c" 1
356 ror $2*8+1, %rax
357 xor %fs:48, %rax
358 # 0 "" 2
359 #NO_APP
360 call *%rax
361 .L41:
362 #APP
363 # 90 "../sysdeps/posix/system.c" 1
364 movl %fs:24,%eax
365 # 0 "" 2
366 #NO_APP
367 testl %eax, %eax
368 jne .L42
369 movl $1, %edx
370 #APP
371 # 47 "../sysdeps/unix/sysv/linux/x86/lowlevellock.h" 1
372 cmpxchgl %edx, lock(%rip)
373 # 0 "" 2
374 #NO_APP
375 .L43:
376 subl $1, sa_refcntr(%rip)
377 je .L50
378 .L44:
379 #APP
380 # 96 "../sysdeps/posix/system.c" 1
381 movl %fs:24,%eax
382 # 0 "" 2
383 #NO_APP
384 testl %eax, %eax
385 jne .L45
386 subl $1, lock(%rip)
387 .L37:
388 addq $16, %rsp
389 popq %rbx
391 .p2align 4,,10
392 .p2align 3
393 .L50:
394 movq (%rbx), %rsi
395 xorl %edx, %edx
396 movl $3, %edi
397 call __GI___sigaction
398 movq 8(%rbx), %rsi
399 xorl %edx, %edx
400 movl $2, %edi
401 call __GI___sigaction
402 jmp .L44
403 .p2align 4,,10
404 .p2align 3
405 .L42:
406 xorl %eax, %eax
407 movl $1, %edx
408 lock cmpxchgl %edx, lock(%rip)
409 je .L43
410 leaq lock(%rip), %rdi
411 call __lll_lock_wait_private
412 jmp .L43
413 .p2align 4,,10
414 .p2align 3
415 .L45:
416 xorl %eax, %eax
417 #APP
418 # 96 "../sysdeps/posix/system.c" 1
419 xchgl %eax, lock(%rip)
420 # 0 "" 2
421 #NO_APP
422 cmpl $1, %eax
423 jle .L37
424 xorl %r10d, %r10d
425 movl $1, %edx
426 movl $129, %esi
427 leaq lock(%rip), %rdi
428 movl $202, %eax
429 #APP
430 # 96 "../sysdeps/posix/system.c" 1
431 syscall
433 # 0 "" 2
434 #NO_APP
435 jmp .L37
436 .size cancel_handler, .-cancel_handler
437 .section .rodata.str1.1
438 .LC3:
439 .string "exit 0"
440 .text
441 .p2align 4,,15
442 .globl __libc_system
443 .type __libc_system, @function
444 __libc_system:
445 testq %rdi, %rdi
446 je .L55
447 jmp do_system
448 .p2align 4,,10
449 .p2align 3
450 .L55:
451 leaq .LC3(%rip), %rdi
452 subq $8, %rsp
453 call do_system
454 testl %eax, %eax
455 sete %al
456 addq $8, %rsp
457 movzbl %al, %eax
459 .size __libc_system, .-__libc_system
460 .weak system
461 .set system,__libc_system
462 .local lock
463 .comm lock,4,4
464 .local sa_refcntr
465 .comm sa_refcntr,4,4
466 .local quit
467 .comm quit,152,32
468 .local intr
469 .comm intr,152,32
470 .hidden __lll_lock_wait_private
471 .hidden __libc_pthread_functions
472 .hidden __libc_pthread_functions_init
473 .hidden __posix_spawnattr_destroy
474 .hidden __posix_spawnattr_setflags
475 .hidden __posix_spawnattr_setsigdefault
476 .hidden __posix_spawnattr_setsigmask
477 .hidden __posix_spawnattr_init