x86-64 needs these CFI directives to stop unwinding here.
I've also cleaned up the assembler a little, and made x86 and x86-64
a little more alike.
Bug:
15195760
(cherry picked from commit
aeb3016f8132689d1b49d30056005b667e3d2d0e)
Change-Id: I511fe238b1ef1a1c16aef735f93bbee9accb0689
int $0x80
# Check result.
- cmpl $0, %eax
- je .L_bc_child
+ testl %eax, %eax
+ jz .L_bc_child
jg .L_bc_parent
# An error occurred, so set errno and return -1.
hlt
.L_bc_parent:
- # we're the parent; nothing to do.
+ # We're the parent; nothing to do.
.L_bc_return:
popl %edi
popl %esi
# Make the system call.
movl $__NR_clone, %eax
syscall
- testl %eax, %eax
- jns 1f
+
+ # Check result.
+ testq %rax, %rax
+ jz .L_bc_child
+ jg .L_bc_parent
# An error occurred, set errno and return -1.
negl %eax
movl %eax, %edi
call __set_errno
orl $-1, %eax
- jmp 2f
-1:
- jnz 2f
+ ret
+
+.L_bc_child:
+ # We don't want anyone to unwind past this point.
+ .cfi_undefined %rip
+ .cfi_undefined %rbp
# We're in the child now, so call __bionic_clone_entry
# with the arguments from the child stack moved into
popq %rsi # arg
call __bionic_clone_entry
hlt
-2:
+
+.L_bc_parent:
+ # We're the parent; nothing to do.
ret
END(__bionic_clone)
.hidden __bionic_clone