am a7ef8188: Merge "Revert "Replaces vfork() implementation with fork()""
				
					
				
			* commit 'a7ef8188e24446d41c5abbe9addf55cc6a128968': Revert "Replaces vfork() implementation with fork()"
This commit is contained in:
		@@ -77,6 +77,7 @@ int prlimit64(pid_t, int, struct rlimit64*, const struct rlimit64*)  arm,mips,x8
 | 
				
			|||||||
int     setgroups:setgroups32(int, const gid_t*)   arm,x86
 | 
					int     setgroups:setgroups32(int, const gid_t*)   arm,x86
 | 
				
			||||||
int     setgroups:setgroups(int, const gid_t*)     arm64,mips,mips64,x86_64
 | 
					int     setgroups:setgroups(int, const gid_t*)     arm64,mips,mips64,x86_64
 | 
				
			||||||
int     setpgid(pid_t, pid_t)  all
 | 
					int     setpgid(pid_t, pid_t)  all
 | 
				
			||||||
 | 
					pid_t   vfork(void)  arm
 | 
				
			||||||
int     setregid:setregid32(gid_t, gid_t)  arm,x86
 | 
					int     setregid:setregid32(gid_t, gid_t)  arm,x86
 | 
				
			||||||
int     setregid:setregid(gid_t, gid_t)    arm64,mips,mips64,x86_64
 | 
					int     setregid:setregid(gid_t, gid_t)    arm64,mips,mips64,x86_64
 | 
				
			||||||
int     chroot(const char*)  all
 | 
					int     chroot(const char*)  all
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								libc/arch-arm/syscalls/vfork.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								libc/arch-arm/syscalls/vfork.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					/* Generated by gensyscalls.py. Do not edit. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <private/bionic_asm.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENTRY(vfork)
 | 
				
			||||||
 | 
					    mov     ip, r7
 | 
				
			||||||
 | 
					    ldr     r7, =__NR_vfork
 | 
				
			||||||
 | 
					    swi     #0
 | 
				
			||||||
 | 
					    mov     r7, ip
 | 
				
			||||||
 | 
					    cmn     r0, #(MAX_ERRNO + 1)
 | 
				
			||||||
 | 
					    bxls    lr
 | 
				
			||||||
 | 
					    neg     r0, r0
 | 
				
			||||||
 | 
					    b       __set_errno
 | 
				
			||||||
 | 
					END(vfork)
 | 
				
			||||||
@@ -36,6 +36,7 @@ libc_bionic_src_files_arm64 := \
 | 
				
			|||||||
    arch-arm64/bionic/__set_tls.c \
 | 
					    arch-arm64/bionic/__set_tls.c \
 | 
				
			||||||
    arch-arm64/bionic/sigsetjmp.S \
 | 
					    arch-arm64/bionic/sigsetjmp.S \
 | 
				
			||||||
    arch-arm64/bionic/syscall.S \
 | 
					    arch-arm64/bionic/syscall.S \
 | 
				
			||||||
 | 
					    arch-arm64/bionic/vfork.S \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
libc_crt_target_cflags_arm64 := \
 | 
					libc_crt_target_cflags_arm64 := \
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										48
									
								
								libc/arch-arm64/bionic/vfork.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								libc/arch-arm64/bionic/vfork.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2013 The Android Open Source Project
 | 
				
			||||||
 | 
					 * All rights reserved.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
 | 
					 * modification, are permitted provided that the following conditions
 | 
				
			||||||
 | 
					 * are met:
 | 
				
			||||||
 | 
					 *  * Redistributions of source code must retain the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer.
 | 
				
			||||||
 | 
					 *  * Redistributions in binary form must reproduce the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer in
 | 
				
			||||||
 | 
					 *    the documentation and/or other materials provided with the
 | 
				
			||||||
 | 
					 *    distribution.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
				
			||||||
 | 
					 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
				
			||||||
 | 
					 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
				
			||||||
 | 
					 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
				
			||||||
 | 
					 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
				
			||||||
 | 
					 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
				
			||||||
 | 
					 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
				
			||||||
 | 
					 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
				
			||||||
 | 
					 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
				
			||||||
 | 
					 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
				
			||||||
 | 
					 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
				
			||||||
 | 
					 * SUCH DAMAGE.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <private/bionic_asm.h>
 | 
				
			||||||
 | 
					#include <asm/signal.h>
 | 
				
			||||||
 | 
					#include <linux/sched.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENTRY(vfork)
 | 
				
			||||||
 | 
					    mov     x0, #(CLONE_VM | CLONE_VFORK | SIGCHLD)
 | 
				
			||||||
 | 
					    mov     x1, xzr
 | 
				
			||||||
 | 
					    mov     x2, xzr
 | 
				
			||||||
 | 
					    mov     x3, xzr
 | 
				
			||||||
 | 
					    mov     x4, xzr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mov     x8, __NR_clone
 | 
				
			||||||
 | 
					    svc     #0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cmn     x0, #(MAX_ERRNO + 1)
 | 
				
			||||||
 | 
					    cneg    x0, x0, hi
 | 
				
			||||||
 | 
					    b.hi    __set_errno
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ret
 | 
				
			||||||
 | 
					END(vfork)
 | 
				
			||||||
							
								
								
									
										58
									
								
								libc/arch-mips/bionic/vfork.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								libc/arch-mips/bionic/vfork.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,58 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2008 The Android Open Source Project
 | 
				
			||||||
 | 
					 * All rights reserved.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
 | 
					 * modification, are permitted provided that the following conditions
 | 
				
			||||||
 | 
					 * are met:
 | 
				
			||||||
 | 
					 *  * Redistributions of source code must retain the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer.
 | 
				
			||||||
 | 
					 *  * Redistributions in binary form must reproduce the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer in
 | 
				
			||||||
 | 
					 *    the documentation and/or other materials provided with the
 | 
				
			||||||
 | 
					 *    distribution.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
				
			||||||
 | 
					 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
				
			||||||
 | 
					 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
				
			||||||
 | 
					 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
				
			||||||
 | 
					 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
				
			||||||
 | 
					 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
				
			||||||
 | 
					 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
				
			||||||
 | 
					 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
				
			||||||
 | 
					 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
				
			||||||
 | 
					 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
				
			||||||
 | 
					 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
				
			||||||
 | 
					 * SUCH DAMAGE.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <private/bionic_asm.h>
 | 
				
			||||||
 | 
					#include <linux/sched.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO: mips' uapi signal.h is missing #ifndef __ASSEMBLY__.
 | 
				
			||||||
 | 
					// #include <asm/signal.h>
 | 
				
			||||||
 | 
					#define SIGCHLD 18
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENTRY(vfork)
 | 
				
			||||||
 | 
						.set	noreorder
 | 
				
			||||||
 | 
						.cpload	t9
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						li	a0, (CLONE_VM | CLONE_VFORK | SIGCHLD)
 | 
				
			||||||
 | 
						li	a1, 0
 | 
				
			||||||
 | 
						li	a2, 0
 | 
				
			||||||
 | 
						li	a3, 0
 | 
				
			||||||
 | 
						subu	sp, 8
 | 
				
			||||||
 | 
						sw	$0, 16(sp)
 | 
				
			||||||
 | 
						li	v0, __NR_clone
 | 
				
			||||||
 | 
						syscall
 | 
				
			||||||
 | 
						addu	sp, 8
 | 
				
			||||||
 | 
						bnez	a3, 1f
 | 
				
			||||||
 | 
						 move	a0, v0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						j	ra
 | 
				
			||||||
 | 
						 nop
 | 
				
			||||||
 | 
					1:
 | 
				
			||||||
 | 
						la	t9, __set_errno
 | 
				
			||||||
 | 
						j	t9
 | 
				
			||||||
 | 
						 nop
 | 
				
			||||||
 | 
					END(vfork)
 | 
				
			||||||
@@ -59,6 +59,7 @@ libc_bionic_src_files_mips += \
 | 
				
			|||||||
    arch-mips/bionic/setjmp.S \
 | 
					    arch-mips/bionic/setjmp.S \
 | 
				
			||||||
    arch-mips/bionic/sigsetjmp.S \
 | 
					    arch-mips/bionic/sigsetjmp.S \
 | 
				
			||||||
    arch-mips/bionic/syscall.S \
 | 
					    arch-mips/bionic/syscall.S \
 | 
				
			||||||
 | 
					    arch-mips/bionic/vfork.S \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ifndef ARCH_MIPS_REV6
 | 
					ifndef ARCH_MIPS_REV6
 | 
				
			||||||
libc_bionic_src_files_mips += \
 | 
					libc_bionic_src_files_mips += \
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										71
									
								
								libc/arch-mips64/bionic/vfork.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								libc/arch-mips64/bionic/vfork.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,71 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2008 The Android Open Source Project
 | 
				
			||||||
 | 
					 * All rights reserved.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
 | 
					 * modification, are permitted provided that the following conditions
 | 
				
			||||||
 | 
					 * are met:
 | 
				
			||||||
 | 
					 *  * Redistributions of source code must retain the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer.
 | 
				
			||||||
 | 
					 *  * Redistributions in binary form must reproduce the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer in
 | 
				
			||||||
 | 
					 *    the documentation and/or other materials provided with the
 | 
				
			||||||
 | 
					 *    distribution.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
				
			||||||
 | 
					 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
				
			||||||
 | 
					 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
				
			||||||
 | 
					 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
				
			||||||
 | 
					 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
				
			||||||
 | 
					 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
				
			||||||
 | 
					 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
				
			||||||
 | 
					 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
				
			||||||
 | 
					 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
				
			||||||
 | 
					 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
				
			||||||
 | 
					 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
				
			||||||
 | 
					 * SUCH DAMAGE.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <private/bionic_asm.h>
 | 
				
			||||||
 | 
					#include <linux/sched.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO: mips' uapi signal.h is missing #ifndef __ASSEMBLY__.
 | 
				
			||||||
 | 
					// #include <asm/signal.h>
 | 
				
			||||||
 | 
					#define SIGCHLD 18
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						.text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
 | 
				
			||||||
 | 
					FRAMESZ		=	MKFSIZ(5,0)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					FRAMESZ		=	MKFSIZ(0,0)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					LEAF(vfork,FRAMESZ)
 | 
				
			||||||
 | 
					#if FRAMESZ!=0
 | 
				
			||||||
 | 
						PTR_SUBU sp, FRAMESZ
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						SETUP_GP64(a5, vfork)
 | 
				
			||||||
 | 
						LI	a0, (CLONE_VM | CLONE_VFORK | SIGCHLD)
 | 
				
			||||||
 | 
						move	a1, $0
 | 
				
			||||||
 | 
						move	a2, $0
 | 
				
			||||||
 | 
						move	a3, $0
 | 
				
			||||||
 | 
					#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
 | 
				
			||||||
 | 
						REG_S	$0, 4*REGSZ(sp)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
						move	a4, $0
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						LI	v0, __NR_clone
 | 
				
			||||||
 | 
						syscall
 | 
				
			||||||
 | 
					#if FRAMESZ!=0
 | 
				
			||||||
 | 
						PTR_ADDU sp,FRAMESZ
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						move	a0, v0
 | 
				
			||||||
 | 
						bnez	a3, 1f
 | 
				
			||||||
 | 
						RESTORE_GP64
 | 
				
			||||||
 | 
						j	ra
 | 
				
			||||||
 | 
					1:
 | 
				
			||||||
 | 
						LA	t9,__set_errno
 | 
				
			||||||
 | 
						RESTORE_GP64
 | 
				
			||||||
 | 
						j	t9
 | 
				
			||||||
 | 
						END(vfork)
 | 
				
			||||||
@@ -46,6 +46,7 @@ libc_bionic_src_files_mips64 := \
 | 
				
			|||||||
    arch-mips64/bionic/setjmp.S \
 | 
					    arch-mips64/bionic/setjmp.S \
 | 
				
			||||||
    arch-mips64/bionic/sigsetjmp.S \
 | 
					    arch-mips64/bionic/sigsetjmp.S \
 | 
				
			||||||
    arch-mips64/bionic/syscall.S \
 | 
					    arch-mips64/bionic/syscall.S \
 | 
				
			||||||
 | 
					    arch-mips64/bionic/vfork.S \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# FIXME TODO
 | 
					# FIXME TODO
 | 
				
			||||||
## libc_bionic_src_files_mips64 += arch-mips64/string/memcpy.S
 | 
					## libc_bionic_src_files_mips64 += arch-mips64/string/memcpy.S
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										44
									
								
								libc/arch-x86/bionic/vfork.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								libc/arch-x86/bionic/vfork.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2008 The Android Open Source Project
 | 
				
			||||||
 | 
					 * All rights reserved.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
 | 
					 * modification, are permitted provided that the following conditions
 | 
				
			||||||
 | 
					 * are met:
 | 
				
			||||||
 | 
					 *  * Redistributions of source code must retain the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer.
 | 
				
			||||||
 | 
					 *  * Redistributions in binary form must reproduce the above copyright
 | 
				
			||||||
 | 
					 *    notice, this list of conditions and the following disclaimer in
 | 
				
			||||||
 | 
					 *    the documentation and/or other materials provided with the
 | 
				
			||||||
 | 
					 *    distribution.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
				
			||||||
 | 
					 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
				
			||||||
 | 
					 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
				
			||||||
 | 
					 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
				
			||||||
 | 
					 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
				
			||||||
 | 
					 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
				
			||||||
 | 
					 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
				
			||||||
 | 
					 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
				
			||||||
 | 
					 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
				
			||||||
 | 
					 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
				
			||||||
 | 
					 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
				
			||||||
 | 
					 * SUCH DAMAGE.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <private/bionic_asm.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// This custom code preserves the return address across the system call.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ENTRY(vfork)
 | 
				
			||||||
 | 
					  popl    %ecx  // Grab the return address.
 | 
				
			||||||
 | 
					  movl    $__NR_vfork, %eax
 | 
				
			||||||
 | 
					  int     $0x80
 | 
				
			||||||
 | 
					  cmpl    $-MAX_ERRNO, %eax
 | 
				
			||||||
 | 
					  jb      1f
 | 
				
			||||||
 | 
					  negl    %eax
 | 
				
			||||||
 | 
					  pushl   %eax
 | 
				
			||||||
 | 
					  call    __set_errno
 | 
				
			||||||
 | 
					1:
 | 
				
			||||||
 | 
					  jmp     *%ecx  // Jump to the stored return address.
 | 
				
			||||||
 | 
					END(vfork)
 | 
				
			||||||
@@ -31,6 +31,7 @@ libc_bionic_src_files_x86 += \
 | 
				
			|||||||
    arch-x86/bionic/__set_tls.c \
 | 
					    arch-x86/bionic/__set_tls.c \
 | 
				
			||||||
    arch-x86/bionic/sigsetjmp.S \
 | 
					    arch-x86/bionic/sigsetjmp.S \
 | 
				
			||||||
    arch-x86/bionic/syscall.S \
 | 
					    arch-x86/bionic/syscall.S \
 | 
				
			||||||
 | 
					    arch-x86/bionic/vfork.S \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## ARCH variant specific source files
 | 
					## ARCH variant specific source files
 | 
				
			||||||
arch_variant_mk := $(LOCAL_PATH)/arch-x86/$(TARGET_ARCH_VARIANT)/$(TARGET_ARCH_VARIANT).mk
 | 
					arch_variant_mk := $(LOCAL_PATH)/arch-x86/$(TARGET_ARCH_VARIANT)/$(TARGET_ARCH_VARIANT).mk
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (C) 2014 The Android Open Source Project
 | 
					 * Copyright (C) 2013 The Android Open Source Project
 | 
				
			||||||
 * All rights reserved.
 | 
					 * All rights reserved.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Redistribution and use in source and binary forms, with or without
 | 
					 * Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
@@ -26,10 +26,20 @@
 | 
				
			|||||||
 * SUCH DAMAGE.
 | 
					 * SUCH DAMAGE.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <private/bionic_asm.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// vfork(2) was removed from POSIX 2008, but it's common enough that we can't
 | 
					// This custom code preserves the return address across the system call.
 | 
				
			||||||
// actually remove it entirely.
 | 
					
 | 
				
			||||||
extern "C" pid_t vfork(void) {
 | 
					ENTRY(vfork)
 | 
				
			||||||
  return fork();
 | 
					  popq    %rdi  // Grab the return address.
 | 
				
			||||||
}
 | 
					  movl    $__NR_vfork, %eax
 | 
				
			||||||
 | 
					  syscall
 | 
				
			||||||
 | 
					  pushq   %rdi  // Restore the return address.
 | 
				
			||||||
 | 
					  cmpq    $-MAX_ERRNO, %rax
 | 
				
			||||||
 | 
					  jb      1f
 | 
				
			||||||
 | 
					  negl    %eax
 | 
				
			||||||
 | 
					  movl    %eax, %edi
 | 
				
			||||||
 | 
					  call    __set_errno
 | 
				
			||||||
 | 
					1:
 | 
				
			||||||
 | 
					  ret
 | 
				
			||||||
 | 
					END(vfork)
 | 
				
			||||||
@@ -37,6 +37,7 @@ libc_bionic_src_files_x86_64 := \
 | 
				
			|||||||
    arch-x86_64/bionic/__set_tls.c \
 | 
					    arch-x86_64/bionic/__set_tls.c \
 | 
				
			||||||
    arch-x86_64/bionic/sigsetjmp.S \
 | 
					    arch-x86_64/bionic/sigsetjmp.S \
 | 
				
			||||||
    arch-x86_64/bionic/syscall.S \
 | 
					    arch-x86_64/bionic/syscall.S \
 | 
				
			||||||
 | 
					    arch-x86_64/bionic/vfork.S \
 | 
				
			||||||
 | 
					
 | 
				
			||||||
libc_bionic_src_files_x86_64 += \
 | 
					libc_bionic_src_files_x86_64 += \
 | 
				
			||||||
    arch-x86_64/string/sse2-memcpy-slm.S \
 | 
					    arch-x86_64/string/sse2-memcpy-slm.S \
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user