011e111d29
The use of the .hidden directive to avoid going via the PLT for __set_errno had the side-effect of actually making __set_errno hidden (which is odd because assembler directives don't usually affect symbols defined in a different file --- you can't even create a weak reference to a symbol that's defined in a different file). This change switches the system call stubs over to a new always-hidden __set_errno_internal and has a visible __set_errno on LP32 just for binary compatibility with old NDK apps. (cherry-pick of 7efad83d430f4d824f2aaa75edea5106f6ff8aae.) Bug: 17423135 Change-Id: I6b6d7a05dda85f923d22e5ffd169a91e23499b7b
53 lines
1.5 KiB
ArmAsm
53 lines
1.5 KiB
ArmAsm
#include <private/bionic_asm.h>
|
|
|
|
// pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
|
|
ENTRY(__bionic_clone)
|
|
pushl %ebx
|
|
pushl %esi
|
|
pushl %edi
|
|
|
|
# Load system call arguments into registers.
|
|
movl 16(%esp), %ebx # flags
|
|
movl 20(%esp), %ecx # child_stack
|
|
movl 24(%esp), %edx # parent_tid
|
|
movl 28(%esp), %esi # tls
|
|
movl 32(%esp), %edi # child_tid
|
|
|
|
# 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
|
|
|
|
# Make the system call.
|
|
movl $__NR_clone, %eax
|
|
int $0x80
|
|
|
|
# Check result.
|
|
testl %eax, %eax
|
|
jz .L_bc_child
|
|
jg .L_bc_parent
|
|
|
|
# An error occurred, so set errno and return -1.
|
|
negl %eax
|
|
pushl %eax
|
|
call __set_errno_internal
|
|
addl $4, %esp
|
|
jmp .L_bc_return
|
|
|
|
.L_bc_child:
|
|
# We don't want anyone to unwind past this point.
|
|
.cfi_undefined %eip
|
|
call __start_thread
|
|
hlt
|
|
|
|
.L_bc_parent:
|
|
# We're the parent; nothing to do.
|
|
.L_bc_return:
|
|
popl %edi
|
|
popl %esi
|
|
popl %ebx
|
|
ret
|
|
END(__bionic_clone)
|
|
.hidden __bionic_clone
|