clarify the purpose of this project
[nyanglibc.git] / posix / execvpe.shared.s
blob4babf78c876274c49114ee286bb803fa31edb014
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 "/bin/sh"
9 #NO_APP
10 .text
11 .p2align 4,,15
12 .type maybe_script_execute, @function
13 maybe_script_execute:
14 pushq %rbp
15 xorl %ecx, %ecx
16 movq %rsp, %rbp
17 pushq %r13
18 pushq %r12
19 pushq %rbx
20 movq %rdx, %r12
21 subq $40, %rsp
22 cmpq $0, (%rsi)
23 jne .L2
24 jmp .L16
25 .p2align 4,,10
26 .p2align 3
27 .L5:
28 cmpq $2147483646, %rax
29 movq %rax, %rcx
30 je .L17
31 .L2:
32 leaq 1(%rcx), %rax
33 cmpq $0, (%rsi,%rax,8)
34 leaq 0(,%rax,8), %rdx
35 jne .L5
36 leaq 46(,%rcx,8), %rcx
37 movq %rsp, %rbx
38 leaq .LC0(%rip), %r8
39 andq $-16, %rcx
40 subq %rcx, %rsp
41 leaq 7(%rsp), %rcx
42 shrq $3, %rcx
43 cmpq $1, %rax
44 leaq 0(,%rcx,8), %r13
45 movq %r8, 0(,%rcx,8)
46 movq %rdi, 8(,%rcx,8)
47 je .L3
48 leaq 16(%r13), %rdi
49 addq $8, %rsi
50 call __GI_memcpy@PLT
51 .L6:
52 leaq .LC0(%rip), %rdi
53 movq %r12, %rdx
54 movq %r13, %rsi
55 call __execve
56 movq %rbx, %rsp
57 leaq -24(%rbp), %rsp
58 popq %rbx
59 popq %r12
60 popq %r13
61 popq %rbp
62 ret
63 .L16:
64 leaq .LC0(%rip), %rax
65 leaq -64(%rbp), %r13
66 movq %rsp, %rbx
67 movq %rdi, -56(%rbp)
68 movq %rax, -64(%rbp)
69 .p2align 4,,10
70 .p2align 3
71 .L3:
72 movq $0, 16(%r13)
73 jmp .L6
74 .L17:
75 movq __libc_errno@gottpoff(%rip), %rax
76 movl $7, %fs:(%rax)
77 leaq -24(%rbp), %rsp
78 popq %rbx
79 popq %r12
80 popq %r13
81 popq %rbp
82 ret
83 .size maybe_script_execute, .-maybe_script_execute
84 .section .rodata.str1.1
85 .LC1:
86 .string "/bin:/usr/bin"
87 .LC2:
88 .string "PATH"
89 .text
90 .p2align 4,,15
91 .type __execvpe_common, @function
92 __execvpe_common:
93 cmpb $0, (%rdi)
94 je .L70
95 pushq %rbp
96 movq %rsp, %rbp
97 pushq %r15
98 pushq %r14
99 pushq %r13
100 pushq %r12
101 movq %rsi, %r12
102 pushq %rbx
103 movl $47, %esi
104 movl %ecx, %r15d
105 movq %rdx, %r13
106 movq %rdi, %rbx
107 subq $56, %rsp
108 call __GI_strchr
109 testq %rax, %rax
110 je .L21
111 movq %r13, %rdx
112 movq %r12, %rsi
113 movq %rbx, %rdi
114 call __execve
115 movq __libc_errno@gottpoff(%rip), %rax
116 cmpl $8, %fs:(%rax)
117 jne .L20
118 testb %r15b, %r15b
119 jne .L71
120 .L20:
121 leaq -40(%rbp), %rsp
122 movl $-1, %eax
123 popq %rbx
124 popq %r12
125 popq %r13
126 popq %r14
127 popq %r15
128 popq %rbp
130 .p2align 4,,10
131 .p2align 3
132 .L70:
133 movq __libc_errno@gottpoff(%rip), %rax
134 movl $2, %fs:(%rax)
135 movl $-1, %eax
137 .p2align 4,,10
138 .p2align 3
139 .L21:
140 leaq .LC2(%rip), %rdi
141 call __GI_getenv
142 testq %rax, %rax
143 movq %rax, %r14
144 leaq .LC1(%rip), %rax
145 movl $255, %esi
146 movq %rbx, %rdi
147 cmove %rax, %r14
148 call __GI___strnlen
149 movl $4095, %esi
150 movq %r14, %rdi
151 movq %rax, -56(%rbp)
152 call __GI___strnlen
153 movq -56(%rbp), %rdx
154 cmpq $255, %rdx
155 ja .L25
156 leaq 1(%rdx), %rcx
157 addq $1, %rax
158 movq %rax, -64(%rbp)
159 movq %rcx, -72(%rbp)
160 addq %rax, %rcx
161 leaq 1(%rcx), %rdi
162 movq %rcx, -56(%rbp)
163 call __GI___libc_alloca_cutoff
164 testl %eax, %eax
165 movq -56(%rbp), %rdx
166 je .L25
167 addq $16, %rdx
168 movb $0, -73(%rbp)
169 andq $-16, %rdx
170 subq %rdx, %rsp
171 movq %rsp, -56(%rbp)
172 .L27:
173 movl $58, %esi
174 movq %r14, %rdi
175 call __strchrnul@PLT
176 movq %rax, %rdx
177 movq %rax, %r8
178 subq %r14, %rdx
179 cmpq -64(%rbp), %rdx
180 jb .L28
181 cmpb $0, (%rax)
182 jne .L30
183 .L29:
184 cmpb $0, -73(%rbp)
185 je .L20
186 movq __libc_errno@gottpoff(%rip), %rax
187 movl $13, %fs:(%rax)
188 jmp .L20
189 .p2align 4,,10
190 .p2align 3
191 .L25:
192 movq __libc_errno@gottpoff(%rip), %rax
193 movl $36, %fs:(%rax)
194 jmp .L20
195 .p2align 4,,10
196 .p2align 3
197 .L71:
198 movq %r13, %rdx
199 movq %r12, %rsi
200 movq %rbx, %rdi
201 call maybe_script_execute
202 jmp .L20
203 .p2align 4,,10
204 .p2align 3
205 .L28:
206 movq -56(%rbp), %rdi
207 movq %r14, %rsi
208 movq %rax, -88(%rbp)
209 call __GI_mempcpy
210 movq -88(%rbp), %r8
211 movq -72(%rbp), %rsi
212 xorl %edx, %edx
213 movb $47, (%rax)
214 cmpq %r8, %r14
215 setb %dl
216 addq %rdx, %rax
217 cmpl $8, %esi
218 jnb .L31
219 andl $4, %esi
220 jne .L72
221 movq -72(%rbp), %rsi
222 testl %esi, %esi
223 je .L32
224 movzbl (%rbx), %edx
225 andl $2, %esi
226 movb %dl, (%rax)
227 jne .L73
228 .L32:
229 movq -56(%rbp), %rdi
230 movq %r13, %rdx
231 movq %r12, %rsi
232 movq %r8, -88(%rbp)
233 call __execve
234 movq __libc_errno@gottpoff(%rip), %r14
235 movq -88(%rbp), %r8
236 movl %fs:(%r14), %eax
237 cmpl $8, %eax
238 jne .L35
239 testb %r15b, %r15b
240 jne .L74
241 .L35:
242 cmpl $20, %eax
243 jg .L36
244 cmpl $19, %eax
245 jge .L38
246 cmpl $2, %eax
247 je .L38
248 cmpl $13, %eax
249 jne .L20
250 movb $1, -73(%rbp)
251 .L38:
252 cmpb $0, (%r8)
253 leaq 1(%r8), %rax
254 je .L29
255 movq %rax, %r8
256 .L30:
257 movq %r8, %r14
258 jmp .L27
259 .p2align 4,,10
260 .p2align 3
261 .L31:
262 movq (%rbx), %rdx
263 leaq 8(%rax), %rdi
264 movq %rbx, %rsi
265 andq $-8, %rdi
266 movq %rdx, (%rax)
267 movq -72(%rbp), %r9
268 movl %r9d, %edx
269 movq -8(%rbx,%rdx), %rcx
270 movq %rcx, -8(%rax,%rdx)
271 subq %rdi, %rax
272 subq %rax, %rsi
273 addl %r9d, %eax
274 shrl $3, %eax
275 movl %eax, %ecx
276 rep movsq
277 jmp .L32
278 .L36:
279 cmpl $110, %eax
280 je .L38
281 cmpl $116, %eax
282 jne .L20
283 jmp .L38
284 .L74:
285 movq -56(%rbp), %rdi
286 movq %r13, %rdx
287 movq %r12, %rsi
288 call maybe_script_execute
289 movl %fs:(%r14), %eax
290 movq -88(%rbp), %r8
291 jmp .L35
292 .L72:
293 movl (%rbx), %edx
294 movl %edx, (%rax)
295 movl -72(%rbp), %edx
296 movl -4(%rbx,%rdx), %ecx
297 movl %ecx, -4(%rax,%rdx)
298 jmp .L32
299 .L73:
300 movl -72(%rbp), %edx
301 movzwl -2(%rbx,%rdx), %ecx
302 movw %cx, -2(%rax,%rdx)
303 jmp .L32
304 .size __execvpe_common, .-__execvpe_common
305 .p2align 4,,15
306 .globl __execvpe
307 .hidden __execvpe
308 .type __execvpe, @function
309 __execvpe:
310 movl $1, %ecx
311 jmp __execvpe_common
312 .size __execvpe, .-__execvpe
313 .weak execvpe
314 .set execvpe,__execvpe
315 .p2align 4,,15
316 .globl __execvpex
317 .hidden __execvpex
318 .type __execvpex, @function
319 __execvpex:
320 xorl %ecx, %ecx
321 jmp __execvpe_common
322 .size __execvpex, .-__execvpex
323 .hidden __execve