Fix unwinding through x86-64 __bionic_clone.
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 Change-Id: I40f92c007843c29c933bb6876fe2b4611e1b946b
This commit is contained in:
		@@ -25,8 +25,8 @@ ENTRY(__bionic_clone)
 | 
				
			|||||||
        int     $0x80
 | 
					        int     $0x80
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Check result.
 | 
					        # Check result.
 | 
				
			||||||
        cmpl    $0, %eax
 | 
					        testl    %eax, %eax
 | 
				
			||||||
        je      .L_bc_child
 | 
					        jz      .L_bc_child
 | 
				
			||||||
        jg      .L_bc_parent
 | 
					        jg      .L_bc_parent
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # An error occurred, so set errno and return -1.
 | 
					        # An error occurred, so set errno and return -1.
 | 
				
			||||||
@@ -44,7 +44,7 @@ ENTRY(__bionic_clone)
 | 
				
			|||||||
        hlt
 | 
					        hlt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.L_bc_parent:
 | 
					.L_bc_parent:
 | 
				
			||||||
        # we're the parent; nothing to do.
 | 
					        # We're the parent; nothing to do.
 | 
				
			||||||
.L_bc_return:
 | 
					.L_bc_return:
 | 
				
			||||||
        popl    %edi
 | 
					        popl    %edi
 | 
				
			||||||
        popl    %esi
 | 
					        popl    %esi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,17 +45,23 @@ ENTRY(__bionic_clone)
 | 
				
			|||||||
        # Make the system call.
 | 
					        # Make the system call.
 | 
				
			||||||
        movl    $__NR_clone, %eax
 | 
					        movl    $__NR_clone, %eax
 | 
				
			||||||
        syscall
 | 
					        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.
 | 
					        # An error occurred, set errno and return -1.
 | 
				
			||||||
        negl    %eax
 | 
					        negl    %eax
 | 
				
			||||||
        movl    %eax, %edi
 | 
					        movl    %eax, %edi
 | 
				
			||||||
        call    __set_errno
 | 
					        call    __set_errno
 | 
				
			||||||
        orl     $-1, %eax
 | 
					        orl     $-1, %eax
 | 
				
			||||||
        jmp     2f
 | 
					        ret
 | 
				
			||||||
1:
 | 
					
 | 
				
			||||||
        jnz     2f
 | 
					.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
 | 
					        # We're in the child now, so call __bionic_clone_entry
 | 
				
			||||||
        # with the arguments from the child stack moved into
 | 
					        # with the arguments from the child stack moved into
 | 
				
			||||||
@@ -64,7 +70,9 @@ ENTRY(__bionic_clone)
 | 
				
			|||||||
        popq    %rsi  # arg
 | 
					        popq    %rsi  # arg
 | 
				
			||||||
        call    __bionic_clone_entry
 | 
					        call    __bionic_clone_entry
 | 
				
			||||||
        hlt
 | 
					        hlt
 | 
				
			||||||
2:
 | 
					
 | 
				
			||||||
 | 
					.L_bc_parent:
 | 
				
			||||||
 | 
					        # We're the parent; nothing to do.
 | 
				
			||||||
        ret
 | 
					        ret
 | 
				
			||||||
END(__bionic_clone)
 | 
					END(__bionic_clone)
 | 
				
			||||||
.hidden __bionic_clone
 | 
					.hidden __bionic_clone
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user