]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/unix/sysv/linux/i386/clone.S
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / i386 / clone.S
index 54524ec120c9c33cb39a22ed960e6466074d5bea..9d47a3c5161271bb45b407d62cf24832f41332d7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2000,02,03,04,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Richard Henderson (rth@tamu.edu)
 
@@ -13,9 +13,8 @@
    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
+   <https://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>
 
 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
             pid_t *ptid, struct user_desc *tls, pid_t *ctid); */
 
-#define PARMS  LINKAGE         /* no space for saved regs */
+#define PARMS  4               /* no space for saved regs */
 #define FUNC   PARMS
 #define STACK  FUNC+4
-#define FLAGS  STACK+PTR_SIZE
+#define FLAGS  STACK+4
 #define ARG    FLAGS+4
-#define PTID   ARG+PTR_SIZE
-#define TLS    PTID+PTR_SIZE
-#define CTID   TLS+PTR_SIZE
+#define PTID   ARG+4
+#define TLS    PTID+4
+#define CTID   TLS+4
 
 #define __NR_clone 120
 #define SYS_clone 120
 
-#define CLONE_VM       0x00000100
-#define CLONE_THREAD   0x00010000
-
         .text
-ENTRY (BP_SYM (__clone))
+ENTRY (__clone)
        /* Sanity check arguments.  */
        movl    $-EINVAL,%eax
        movl    FUNC(%esp),%ecx         /* no NULL function pointers */
-#ifdef PIC
-       jecxz   SYSCALL_ERROR_LABEL
-#else
        testl   %ecx,%ecx
        jz      SYSCALL_ERROR_LABEL
-#endif
        movl    STACK(%esp),%ecx        /* no NULL stack pointers */
-#ifdef PIC
-       jecxz   SYSCALL_ERROR_LABEL
-#else
        testl   %ecx,%ecx
        jz      SYSCALL_ERROR_LABEL
-#endif
 
        /* Insert the argument onto the new stack.  Make sure the new
           thread is started with an alignment of (mod 16).  */
@@ -77,9 +63,6 @@ ENTRY (BP_SYM (__clone))
        movl    %eax,8(%ecx)
        /* Don't leak any information.  */
        movl    $0,4(%ecx)
-#ifndef RESET_PID
-       movl    $0,(%ecx)
-#endif
 
        /* Do the system call */
        pushl   %ebx
@@ -98,10 +81,8 @@ ENTRY (BP_SYM (__clone))
        cfi_rel_offset (edi, 0)
        movl    $SYS_ify(clone),%eax
 
-#ifdef RESET_PID
        /* Remember the flag value.  */
        movl    %ebx, (%ecx)
-#endif
 
        /* End FDE now, because in the child the unwind info will be
           wrong.  */
@@ -116,17 +97,14 @@ ENTRY (BP_SYM (__clone))
        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 (eip);
        /* Note: %esi is zero.  */
        movl    %esi,%ebp       /* terminate the stack frame */
-#ifdef RESET_PID
-       testl   $CLONE_THREAD, %edi
-       je      L(newpid)
-L(haspid):
-#endif
        call    *%ebx
 #ifdef PIC
        call    L(here)
@@ -138,22 +116,7 @@ L(here):
        movl    $SYS_ify(exit), %eax
        ENTER_KERNEL
 
-#ifdef RESET_PID
-       .subsection 2
-L(newpid):
-       testl   $CLONE_VM, %edi
-       movl    $-1, %eax
-       jne     L(nomoregetpid)
-       movl    $SYS_ify(getpid), %eax
-       ENTER_KERNEL
-L(nomoregetpid):
-       movl    %eax, %gs:PID
-       movl    %eax, %gs:TID
-       jmp     L(haspid)
-       .previous
-#endif
-
-       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)