Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Pat Beirne <patb@corelcomputer.com>
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* clone() is even more special than fork() as it mucks with stacks
20 and invokes a function in the right context after its all over. */
21
22#include <sysdep.h>
23#include <tcb-offsets.h>
24#define _ERRNO_H 1
25#include <bits/errno.h>
26
27/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
28 pid_t *ptid, struct user_desc *tls, pid_t *ctid); */
29
30 .text
31ENTRY(__clone)
32 @ sanity check args
33 cmp r0, #0
34 ite ne
35 cmpne r1, #0
36 moveq r0, #-EINVAL
37 beq PLTJMP(syscall_error)
38
39 @ insert the args onto the new stack
40 str r3, [r1, #-4]!
41 str r0, [r1, #-4]!
42
43 @ do the system call
44 @ get flags
45 mov r0, r2
46 mov ip, r2
47 @ new sp is already in r1
48 push {r4, r7}
49 cfi_adjust_cfa_offset (8)
50 cfi_rel_offset (r4, 0)
51 cfi_rel_offset (r7, 4)
52 ldr r2, [sp, #8]
53 ldr r3, [sp, #12]
54 ldr r4, [sp, #16]
55 ldr r7, =SYS_ify(clone)
56 swi 0x0
57 cfi_endproc
58 cmp r0, #0
59 beq 1f
60 pop {r4, r7}
61 blt PLTJMP(C_SYMBOL_NAME(__syscall_error))
62 RETINSTR(, lr)
63
64 cfi_startproc
65PSEUDO_END (__clone)
66
671:
68 .fnstart
69 .cantunwind
70 @ pick the function arg and call address off the stack and execute
71 ldr r0, [sp, #4]
72 ldr ip, [sp], #8
73 BLX (ip)
74
75 @ and we are done, passing the return value through r0
76 ldr r7, =SYS_ify(exit)
77 swi 0x0
78
79 .fnend
80
81libc_hidden_def (__clone)
82weak_alias (__clone, clone)
83

Warning: That file was not part of the compilation database. It may have many parsing errors.