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