-/* Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
#define _ERRNO_H 1
#include <bits/errno.h>
#include <asm-syntax.h>
-#include <bp-sym.h>
-#include <bp-asm.h>
-
-#define CLONE_VM 0x00000100
-#define CLONE_THREAD 0x00010000
/* The userland implementation is:
int clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg),
.text
-ENTRY (BP_SYM (__clone))
+ENTRY (__clone)
/* Sanity check arguments. */
movq $-EINVAL,%rax
testq %rdi,%rdi /* no NULL function pointers */
movq %rdx, %rdi
movq %r8, %rdx
movq %r9, %r8
- movq 8(%rsp), %r10
- movq $SYS_ify(clone),%rax
+ mov 8(%rsp), %R10_LP
+ movl $SYS_ify(clone),%eax
/* End FDE now, because in the child the unwind info will be
wrong. */
jl SYSCALL_ERROR_LABEL
jz L(thread_start)
-L(pseudo_end):
ret
L(thread_start):
+ cfi_startproc;
+ /* Clearing frame pointer is insufficient, use CFI. */
+ cfi_undefined (rip);
/* Clear the frame pointer. The ABI suggests this be done, to mark
the outermost frame obviously. */
- xorq %rbp, %rbp
-
-#ifdef RESET_PID
- testq $CLONE_THREAD, %rdi
- jne 1f
- testq $CLONE_VM, %rdi
- movl $-1, %eax
- jne 2f
- movq $SYS_ify(getpid), %rax
- syscall
-2: movl %eax, %fs:PID
- movl %eax, %fs:TID
-1:
-#endif
+ xorl %ebp, %ebp
/* Set up arguments for the function call. */
popq %rax /* Function to call. */
call *%rax
/* Call exit with return value from function call. */
movq %rax, %rdi
- call HIDDEN_JUMPTARGET (_exit)
+ movl $SYS_ify(exit), %eax
+ syscall
+ cfi_endproc;
cfi_startproc;
-PSEUDO_END (BP_SYM (__clone))
+PSEUDO_END (__clone)
-weak_alias (BP_SYM (__clone), BP_SYM (clone))
+libc_hidden_def (__clone)
+weak_alias (__clone, clone)