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