OSDN Git Service

Fix the order of arguments to sys_clone for x86.
authorElliott Hughes <enh@google.com>
Wed, 27 Nov 2013 00:20:50 +0000 (16:20 -0800)
committerElliott Hughes <enh@google.com>
Wed, 27 Nov 2013 00:20:50 +0000 (16:20 -0800)
Unlike x86-64, x86's arguments are just like every other
architecture's.

Change-Id: Ic6da23f2a70599683b68e7e12ab9ba061e0b349c

libc/arch-x86/bionic/__bionic_clone.S

index eb9f545..3823ecc 100644 (file)
@@ -7,29 +7,32 @@ ENTRY(__bionic_clone)
         pushl   %esi
         pushl   %edi
 
-        # insert arguments onto the child stack
+        # Align child stack.
         movl    20(%esp), %ecx
         andl    $~15, %ecx
-        movl    36(%esp), %eax
-        movl    %eax, -16(%ecx)
-        movl    40(%esp), %eax
-        movl    %eax, -12(%ecx)
 
+        # Copy 'fn' and 'arg' onto the child stack
+        movl    36(%esp), %eax   # Read 'fn'.
+        movl    %eax, -16(%ecx)  # Write 'fn'.
+        movl    40(%esp), %eax   # Read 'arg'.
+        movl    %eax, -12(%ecx)  # Write 'arg'.
         subl    $16, %ecx
-        movl    16(%esp), %ebx
-        movl    24(%esp), %edx
-        movl    32(%esp), %esi
-        movl    28(%esp), %edi
 
-        # make system call
+        # Make the system call.
         movl    $__NR_clone, %eax
+        movl    16(%esp), %ebx  # flags
+        #movl   %ecx, %ecx      # child stack (already there)
+        movl    24(%esp), %edx  # parent_tid
+        movl    28(%esp), %esi  # tls
+        movl    32(%esp), %edi  # child_tid
         int     $0x80
 
+        # Check result.
         cmpl    $0, %eax
         je      bc_child
         jg      bc_parent
 
-        # an error occurred, set errno and return -1
+        # An error occurred, so set errno and return -1.
         negl    %eax
         pushl   %eax
         call    __set_errno
@@ -38,9 +41,6 @@ ENTRY(__bionic_clone)
         jmp     bc_return
 
 bc_child:
-        # we're in the child now, call __bionic_clone_entry
-        # with the appropriate arguments on the child stack
-        # we already placed most of them
         call    __bionic_clone_entry
         hlt