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