1 | /* Copyright (C) 1999-2022 Free Software Foundation, Inc. |
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 |
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. |
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 |
12 | Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with the GNU C Library. If not, see |
16 | <https://www.gnu.org/licenses/>. */ |
17 | |
18 | #include <sysdep.h> |
19 | #define _ERRNO_H 1 |
20 | #include <bits/errno.h> |
21 | #include <tcb-offsets.h> |
22 | |
23 | |
24 | /* Clone the calling process, but without copying the whole address space. |
25 | The calling process is suspended until the new process exits or is |
26 | replaced by a call to `execve'. Return -1 for errors, 0 to the new process, |
27 | and the process ID of the new process to the old process. */ |
28 | |
29 | ENTRY (__vfork) |
30 | /* The DO_CALL macro saves r7 on the stack, to enable generation |
31 | of ARM unwind info. Since the stack is initially shared between |
32 | parent and child of vfork, that saved value could be corrupted. |
33 | To avoid this problem, we save r7 into ip as well, and restore |
34 | from there. */ |
35 | mov ip, r7 |
36 | cfi_register (r7, ip) |
37 | .fnstart |
38 | push { r7 } |
39 | cfi_adjust_cfa_offset (4) |
40 | .save { r7 } |
41 | ldr r7, =SYS_ify (vfork) |
42 | swi 0x0 |
43 | .fnend |
44 | add sp, sp, #4 |
45 | cfi_adjust_cfa_offset (-4) |
46 | mov r7, ip |
47 | cfi_restore (r7) |
48 | |
49 | cmn a1, #4096 |
50 | it cc |
51 | RETINSTR(cc, lr) |
52 | |
53 | b PLTJMP(SYSCALL_ERROR) |
54 | PSEUDO_END (__vfork) |
55 | libc_hidden_def (__vfork) |
56 | |
57 | weak_alias (__vfork, vfork) |
58 | strong_alias (__vfork, __libc_vfork) |
59 | |