* commit 'fb8ce528373555a4b2782343e0b19e0b074e8e92': Add arch-x86_64/bionic.
This commit is contained in:
		@@ -94,7 +94,7 @@ int     chroot(const char*)  all
 | 
			
		||||
# IMPORTANT: Even though <sys/prctl.h> declares prctl(int, ...), the syscall stub must take 6 arguments
 | 
			
		||||
#            to match the kernel implementation.
 | 
			
		||||
int     prctl(int option, unsigned int arg2, unsigned int arg3, unsigned int arg4, unsigned int arg5) all
 | 
			
		||||
long    arch_prctl(int, unsigned long) x86_64
 | 
			
		||||
long    __arch_prctl:arch_prctl(int, unsigned long) x86_64
 | 
			
		||||
int     capget(cap_user_header_t header, cap_user_data_t data) all
 | 
			
		||||
int     capset(cap_user_header_t header, const cap_user_data_t data) all
 | 
			
		||||
int     sigaltstack(const stack_t*, stack_t*) all
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										34
									
								
								libc/arch-x86_64/bionic/__get_sp.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								libc/arch-x86_64/bionic/__get_sp.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
 | 
			
		||||
ENTRY(__get_sp)
 | 
			
		||||
  mov  %rsp, %rax
 | 
			
		||||
  ret
 | 
			
		||||
END(__get_sp)
 | 
			
		||||
							
								
								
									
										33
									
								
								libc/arch-x86_64/bionic/__get_tls.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								libc/arch-x86_64/bionic/__get_tls.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
void* __get_tls(void) {
 | 
			
		||||
  void* tls;
 | 
			
		||||
  asm ("mov %%fs:0, %0" : "=r"(tls));
 | 
			
		||||
  return tls;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								libc/arch-x86_64/bionic/__rt_sigreturn.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								libc/arch-x86_64/bionic/__rt_sigreturn.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <asm/unistd.h>
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
 | 
			
		||||
ENTRY(__rt_sigreturn)
 | 
			
		||||
  .hidden _C_LABEL(__rt_sigreturn) // TODO: add an ENTRY_PRIVATE macro for x86_64.
 | 
			
		||||
  movl $__NR_rt_sigreturn, %eax
 | 
			
		||||
  syscall
 | 
			
		||||
END(__rt_sigreturn)
 | 
			
		||||
							
								
								
									
										38
									
								
								libc/arch-x86_64/bionic/__set_tls.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								libc/arch-x86_64/bionic/__set_tls.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <asm/prctl.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
extern int __arch_prctl(int, unsigned long);
 | 
			
		||||
 | 
			
		||||
int __set_tls(void* ptr) {
 | 
			
		||||
  // We also need to write the location of the tls to ptr[0].
 | 
			
		||||
  *(void**) ptr = ptr;
 | 
			
		||||
  return __arch_prctl(ARCH_SET_FS, (uintptr_t) ptr);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										56
									
								
								libc/arch-x86_64/bionic/_exit_with_stack_teardown.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								libc/arch-x86_64/bionic/_exit_with_stack_teardown.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <asm/unistd.h>
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
/*
 | 
			
		||||
 * void _exit_with_stack_teardown(void *stackBase, int stackSize, int *retCode)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
ENTRY(_exit_with_stack_teardown)
 | 
			
		||||
    /* we can trash %rbx here since this call should never return. */
 | 
			
		||||
    /* We can also take advantage of the fact that the linux syscall trap
 | 
			
		||||
     * handler saves all the registers, so we don't need a stack to keep
 | 
			
		||||
     * the retCode argument for exit while doing the munmap */
 | 
			
		||||
 | 
			
		||||
    /* TODO(dmtriyz): No one expects this code to return, so even if
 | 
			
		||||
     * munmap fails, we have to exit. This should probably be fixed, but
 | 
			
		||||
     * since ARM side does the same thing, leave it as is.
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    /* args passed through registers */
 | 
			
		||||
    mov     $__NR_munmap, %eax        /* shouldn't change %rdx (retCode) */
 | 
			
		||||
    syscall
 | 
			
		||||
    mov     %rdx, %rdi                /* retrieve the retCode */
 | 
			
		||||
    mov     $__NR_exit, %eax
 | 
			
		||||
    syscall
 | 
			
		||||
    /* exit does not return */
 | 
			
		||||
    /* can't have a ret here since we no longer have a usable stack. Seems
 | 
			
		||||
     * that presently, 'hlt' will cause the program to segfault.. but this
 | 
			
		||||
     * should never happen :) */
 | 
			
		||||
    hlt
 | 
			
		||||
							
								
								
									
										82
									
								
								libc/arch-x86_64/bionic/_setjmp.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								libc/arch-x86_64/bionic/_setjmp.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,82 @@
 | 
			
		||||
/*	$OpenBSD: _setjmp.S,v 1.1 2004/01/28 01:44:45 mickey Exp $	*/
 | 
			
		||||
/*	$NetBSD: _setjmp.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $	*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2001 Wasabi Systems, Inc.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Written by Frank van der Linden for Wasabi Systems, Inc.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in the
 | 
			
		||||
 *    documentation and/or other materials provided with the distribution.
 | 
			
		||||
 * 3. All advertising materials mentioning features or use of this software
 | 
			
		||||
 *    must display the following acknowledgement:
 | 
			
		||||
 *      This product includes software developed for the NetBSD Project by
 | 
			
		||||
 *      Wasabi Systems, Inc.
 | 
			
		||||
 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
 | 
			
		||||
 *    or promote products derived from this software without specific prior
 | 
			
		||||
 *    written permission.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
 | 
			
		||||
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 | 
			
		||||
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
 | 
			
		||||
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 | 
			
		||||
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 | 
			
		||||
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 | 
			
		||||
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 | 
			
		||||
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | 
			
		||||
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 | 
			
		||||
 * POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
#include <machine/setjmp.h>
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * C library -- _setjmp, _longjmp
 | 
			
		||||
 *
 | 
			
		||||
 *	_longjmp(a,v)
 | 
			
		||||
 * will generate a "return(v)" from the last call to
 | 
			
		||||
 *	_setjmp(a)
 | 
			
		||||
 * by restoring registers from the stack.
 | 
			
		||||
 * The previous signal state is NOT restored.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
ENTRY(_setjmp)
 | 
			
		||||
	movq    (%rsp),%r11
 | 
			
		||||
	movq    %rbx,(_JB_RBX * 8)(%rdi)
 | 
			
		||||
	movq    %rbp,(_JB_RBP * 8)(%rdi)
 | 
			
		||||
	movq    %r12,(_JB_R12 * 8)(%rdi)
 | 
			
		||||
	movq    %r13,(_JB_R13 * 8)(%rdi)
 | 
			
		||||
	movq    %r14,(_JB_R14 * 8)(%rdi)
 | 
			
		||||
	movq    %r15,(_JB_R15 * 8)(%rdi)
 | 
			
		||||
	movq    %rsp,(_JB_RSP * 8)(%rdi)
 | 
			
		||||
	movq    %r11,(_JB_PC  * 8)(%rdi)
 | 
			
		||||
 | 
			
		||||
	xorl	%eax,%eax
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
ENTRY(_longjmp)
 | 
			
		||||
	movq    (_JB_RBX * 8)(%rdi),%rbx
 | 
			
		||||
	movq    (_JB_RBP * 8)(%rdi),%rbp
 | 
			
		||||
	movq    (_JB_R12 * 8)(%rdi),%r12
 | 
			
		||||
	movq    (_JB_R13 * 8)(%rdi),%r13
 | 
			
		||||
	movq    (_JB_R14 * 8)(%rdi),%r14
 | 
			
		||||
	movq    (_JB_R15 * 8)(%rdi),%r15
 | 
			
		||||
	movq    (_JB_RSP * 8)(%rdi),%rsp
 | 
			
		||||
	movq    (_JB_PC  * 8)(%rdi),%r11
 | 
			
		||||
 | 
			
		||||
	movl	%esi,%eax
 | 
			
		||||
	testl	%eax,%eax
 | 
			
		||||
	jnz	1f
 | 
			
		||||
	incl	%eax
 | 
			
		||||
1:	movq	%r11,0(%rsp)
 | 
			
		||||
	ret
 | 
			
		||||
							
								
								
									
										111
									
								
								libc/arch-x86_64/bionic/clone.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								libc/arch-x86_64/bionic/clone.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,111 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <asm/unistd.h>
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
 | 
			
		||||
// int  __pthread_clone(void* (*fn)(void*), void* tls, int flags, void* arg);
 | 
			
		||||
ENTRY(__pthread_clone)
 | 
			
		||||
        # save tls
 | 
			
		||||
        movq    %rsi, %r11
 | 
			
		||||
        # 16-byte alignment on child stack
 | 
			
		||||
        andq    $~15, %rsi
 | 
			
		||||
 | 
			
		||||
        # insert arguments onto the child stack
 | 
			
		||||
        movq    %rdi, -32(%rsi)
 | 
			
		||||
        movq    %rcx, -24(%rsi)
 | 
			
		||||
        movq    %r11, -16(%rsi)
 | 
			
		||||
 | 
			
		||||
        subq    $32, %rsi
 | 
			
		||||
        movq    %rdx, %rdi
 | 
			
		||||
        movl    $__NR_clone, %eax
 | 
			
		||||
        syscall
 | 
			
		||||
        testl   %eax, %eax
 | 
			
		||||
        jns     1f
 | 
			
		||||
 | 
			
		||||
        # an error occurred, set errno and return -1
 | 
			
		||||
        negl    %eax
 | 
			
		||||
        movl    %eax, %edi
 | 
			
		||||
        call    __set_errno
 | 
			
		||||
        orl     $-1, %eax
 | 
			
		||||
        jmp     2f
 | 
			
		||||
1:
 | 
			
		||||
        jnz     2f
 | 
			
		||||
 | 
			
		||||
        # we're in the child thread now, call __thread_entry
 | 
			
		||||
        # with the appropriate arguments on the child stack
 | 
			
		||||
        # we already placed most of them
 | 
			
		||||
        call    __thread_entry
 | 
			
		||||
        hlt
 | 
			
		||||
2:
 | 
			
		||||
        ret
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * int  __bionic_clone(unsigned long clone_flags,
 | 
			
		||||
 *                     void*         newsp,
 | 
			
		||||
 *                     int           *parent_tidptr,
 | 
			
		||||
 *                     void          *new_tls,
 | 
			
		||||
 *                     int           *child_tidptr,
 | 
			
		||||
 *                     int           (*fn)(void *),
 | 
			
		||||
 *                     void          *arg);
 | 
			
		||||
 */
 | 
			
		||||
ENTRY(__bionic_clone)
 | 
			
		||||
        # insert arguments onto the child stack
 | 
			
		||||
        andq    $~15, %rsi
 | 
			
		||||
        movq    %r9, -16(%rsi)
 | 
			
		||||
        # 7th argument (arg) goes through stack
 | 
			
		||||
        movq    8(%rsp), %rax
 | 
			
		||||
        movq    %rax, -8(%rsi)
 | 
			
		||||
 | 
			
		||||
        subq    $16, %rsi
 | 
			
		||||
        movq    %r8, %r10
 | 
			
		||||
        movq    %rcx, %r8
 | 
			
		||||
        movl    $__NR_clone, %eax
 | 
			
		||||
        syscall
 | 
			
		||||
        testl   %eax, %eax
 | 
			
		||||
        jns     1f
 | 
			
		||||
 | 
			
		||||
        # an error occurred, set errno and return -1
 | 
			
		||||
        negl    %eax
 | 
			
		||||
        movl    %eax, %edi
 | 
			
		||||
        call    __set_errno
 | 
			
		||||
        orl     $-1, %eax
 | 
			
		||||
        jmp     2f
 | 
			
		||||
 | 
			
		||||
1:
 | 
			
		||||
        jnz     2f
 | 
			
		||||
 | 
			
		||||
        # 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
 | 
			
		||||
 | 
			
		||||
2:
 | 
			
		||||
        ret
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										67
									
								
								libc/arch-x86_64/bionic/futex_x86_64.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								libc/arch-x86_64/bionic/futex_x86_64.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,67 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <asm/unistd.h>
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
 | 
			
		||||
#define FUTEX_WAIT 0
 | 
			
		||||
#define FUTEX_WAKE 1
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout)
 | 
			
		||||
 */
 | 
			
		||||
ENTRY(__futex_wait)
 | 
			
		||||
    mov     %rdx, %r10           /* timeout */
 | 
			
		||||
    mov     %esi, %edx           /* val */
 | 
			
		||||
    mov     $FUTEX_WAIT, %esi    /* op */
 | 
			
		||||
    mov     $__NR_futex, %eax
 | 
			
		||||
    syscall
 | 
			
		||||
    ret
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* int __futex_wake(volatile void *ftx, int count) */
 | 
			
		||||
 | 
			
		||||
ENTRY(__futex_wake)
 | 
			
		||||
    mov     %esi, %edx
 | 
			
		||||
    mov     $FUTEX_WAKE, %esi
 | 
			
		||||
    mov     $__NR_futex, %eax
 | 
			
		||||
    syscall
 | 
			
		||||
    ret
 | 
			
		||||
 | 
			
		||||
/* int __futex_syscall3(volatile void *ftx, int op, int count) */
 | 
			
		||||
ENTRY(__futex_syscall3)
 | 
			
		||||
    mov     $__NR_futex, %eax
 | 
			
		||||
    syscall
 | 
			
		||||
    ret
 | 
			
		||||
 | 
			
		||||
/* int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout) */
 | 
			
		||||
ENTRY(__futex_syscall4)
 | 
			
		||||
    mov     %rcx, %r10      /* timeout */
 | 
			
		||||
    mov     $__NR_futex, %eax
 | 
			
		||||
    syscall
 | 
			
		||||
    ret
 | 
			
		||||
							
								
								
									
										103
									
								
								libc/arch-x86_64/bionic/setjmp.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								libc/arch-x86_64/bionic/setjmp.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,103 @@
 | 
			
		||||
/*	$OpenBSD: setjmp.S,v 1.3 2012/08/22 17:19:34 pascal Exp $	*/
 | 
			
		||||
/*	$NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $	*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2001 Wasabi Systems, Inc.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Written by Frank van der Linden for Wasabi Systems, Inc.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in the
 | 
			
		||||
 *    documentation and/or other materials provided with the distribution.
 | 
			
		||||
 * 3. All advertising materials mentioning features or use of this software
 | 
			
		||||
 *    must display the following acknowledgement:
 | 
			
		||||
 *      This product includes software developed for the NetBSD Project by
 | 
			
		||||
 *      Wasabi Systems, Inc.
 | 
			
		||||
 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
 | 
			
		||||
 *    or promote products derived from this software without specific prior
 | 
			
		||||
 *    written permission.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
 | 
			
		||||
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 | 
			
		||||
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
 | 
			
		||||
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 | 
			
		||||
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 | 
			
		||||
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 | 
			
		||||
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 | 
			
		||||
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | 
			
		||||
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 | 
			
		||||
 * POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
#include <machine/setjmp.h>
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * C library -- _setjmp, _longjmp
 | 
			
		||||
 *
 | 
			
		||||
 *	longjmp(a,v)
 | 
			
		||||
 * will generate a "return(v)" from the last call to
 | 
			
		||||
 *	setjmp(a)
 | 
			
		||||
 * by restoring registers from the stack.
 | 
			
		||||
 * The previous signal state is restored.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
ENTRY(setjmp)
 | 
			
		||||
	pushq	%rdi
 | 
			
		||||
	xorq	%rdi,%rdi
 | 
			
		||||
#ifdef __PIC__
 | 
			
		||||
	call	PIC_PLT(_C_LABEL(sigblock))
 | 
			
		||||
#else
 | 
			
		||||
	call	_C_LABEL(sigblock)
 | 
			
		||||
#endif
 | 
			
		||||
	popq	%rdi
 | 
			
		||||
	movq	%rax,(_JB_SIGMASK * 8)(%rdi)
 | 
			
		||||
 | 
			
		||||
	movq	(%rsp),%r11
 | 
			
		||||
	movq	%rbx,(_JB_RBX * 8)(%rdi)
 | 
			
		||||
	movq	%rbp,(_JB_RBP * 8)(%rdi)
 | 
			
		||||
	movq	%r12,(_JB_R12 * 8)(%rdi)
 | 
			
		||||
	movq	%r13,(_JB_R13 * 8)(%rdi)
 | 
			
		||||
	movq	%r14,(_JB_R14 * 8)(%rdi)
 | 
			
		||||
	movq	%r15,(_JB_R15 * 8)(%rdi)
 | 
			
		||||
	movq	%rsp,(_JB_RSP * 8)(%rdi)
 | 
			
		||||
	movq	%r11,(_JB_PC  * 8)(%rdi)
 | 
			
		||||
 | 
			
		||||
2:	xorl	%eax,%eax
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
ENTRY(longjmp)
 | 
			
		||||
	movq	%rdi,%r12
 | 
			
		||||
	movl	%esi,%r8d
 | 
			
		||||
 | 
			
		||||
	movq	(_JB_SIGMASK * 8)(%rdi),%rdi
 | 
			
		||||
	pushq	%r8
 | 
			
		||||
#ifdef __PIC__
 | 
			
		||||
	call	PIC_PLT(_C_LABEL(sigsetmask))
 | 
			
		||||
#else
 | 
			
		||||
	call	_C_LABEL(sigsetmask)
 | 
			
		||||
#endif
 | 
			
		||||
	popq	%r8
 | 
			
		||||
	movq	(_JB_RBX * 8)(%r12),%rbx
 | 
			
		||||
	movq	(_JB_RBP * 8)(%r12),%rbp
 | 
			
		||||
	movq	(_JB_R13 * 8)(%r12),%r13
 | 
			
		||||
	movq	(_JB_R14 * 8)(%r12),%r14
 | 
			
		||||
	movq	(_JB_R15 * 8)(%r12),%r15
 | 
			
		||||
	movq	(_JB_RSP * 8)(%r12),%rsp
 | 
			
		||||
	movq	(_JB_PC  * 8)(%r12),%r11
 | 
			
		||||
	movq	(_JB_R12 * 8)(%r12),%r12
 | 
			
		||||
 | 
			
		||||
	movl	%r8d,%eax
 | 
			
		||||
	testl	%eax,%eax
 | 
			
		||||
	jnz	1f
 | 
			
		||||
	incl	%eax
 | 
			
		||||
1:	movq	%r11,0(%rsp)
 | 
			
		||||
	ret
 | 
			
		||||
							
								
								
									
										52
									
								
								libc/arch-x86_64/bionic/sigaction.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								libc/arch-x86_64/bionic/sigaction.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
extern void __rt_sigreturn(void);
 | 
			
		||||
extern int __rt_sigaction(int, const struct sigaction*, struct sigaction*, size_t);
 | 
			
		||||
 | 
			
		||||
int sigaction(int sig, const struct sigaction* act, struct sigaction* old_act) {
 | 
			
		||||
  struct sigaction sa;
 | 
			
		||||
 | 
			
		||||
  if (act != NULL && !(act->sa_flags & SA_RESTORER)) {
 | 
			
		||||
    sa = *act;
 | 
			
		||||
    act = &sa;
 | 
			
		||||
    sa.sa_flags |= SA_RESTORER;
 | 
			
		||||
    sa.sa_restorer = &__rt_sigreturn;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int result = __rt_sigaction(sig, act, old_act, sizeof(sigset_t));
 | 
			
		||||
 | 
			
		||||
  if (old_act != NULL && (old_act->sa_restorer == &__rt_sigreturn)) {
 | 
			
		||||
    old_act->sa_flags &= ~SA_RESTORER;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										35
									
								
								libc/arch-x86_64/bionic/sigprocmask.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								libc/arch-x86_64/bionic/sigprocmask.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
extern int __rt_sigprocmask(int, const sigset_t*, sigset_t*, size_t);
 | 
			
		||||
 | 
			
		||||
int sigprocmask(int how, const sigset_t* set, sigset_t* old_set) {
 | 
			
		||||
  return __rt_sigprocmask(how, set, old_set, sizeof(sigset_t));
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										107
									
								
								libc/arch-x86_64/bionic/sigsetjmp.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								libc/arch-x86_64/bionic/sigsetjmp.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,107 @@
 | 
			
		||||
/*	$OpenBSD: sigsetjmp.S,v 1.3 2012/08/22 17:19:34 pascal Exp $	*/
 | 
			
		||||
/*	$NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $	*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2001 Wasabi Systems, Inc.
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Written by Frank van der Linden for Wasabi Systems, Inc.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 * 1. Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 * 2. Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in the
 | 
			
		||||
 *    documentation and/or other materials provided with the distribution.
 | 
			
		||||
 * 3. All advertising materials mentioning features or use of this software
 | 
			
		||||
 *    must display the following acknowledgement:
 | 
			
		||||
 *      This product includes software developed for the NetBSD Project by
 | 
			
		||||
 *      Wasabi Systems, Inc.
 | 
			
		||||
 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
 | 
			
		||||
 *    or promote products derived from this software without specific prior
 | 
			
		||||
 *    written permission.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
 | 
			
		||||
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 | 
			
		||||
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 | 
			
		||||
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
 | 
			
		||||
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 | 
			
		||||
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 | 
			
		||||
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 | 
			
		||||
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 | 
			
		||||
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 | 
			
		||||
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 | 
			
		||||
 * POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
#include <machine/setjmp.h>
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * C library -- _setjmp, _longjmp
 | 
			
		||||
 *
 | 
			
		||||
 *	longjmp(a,v)
 | 
			
		||||
 * will generate a "return(v)" from the last call to
 | 
			
		||||
 *	setjmp(a)
 | 
			
		||||
 * by restoring registers from the stack.
 | 
			
		||||
 * The previous signal state is restored.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
ENTRY(sigsetjmp)
 | 
			
		||||
	movl    %esi,(_JB_SIGFLAG  * 8)(%rdi)
 | 
			
		||||
	testl   %esi,%esi
 | 
			
		||||
	jz      2f
 | 
			
		||||
 | 
			
		||||
	pushq	%rdi
 | 
			
		||||
	xorq	%rdi,%rdi
 | 
			
		||||
#ifdef __PIC__
 | 
			
		||||
	call	PIC_PLT(_C_LABEL(sigblock))
 | 
			
		||||
#else
 | 
			
		||||
	call	_C_LABEL(sigblock)
 | 
			
		||||
#endif
 | 
			
		||||
	popq	%rdi
 | 
			
		||||
	movq	%rax,(_JB_SIGMASK * 8)(%rdi)
 | 
			
		||||
 | 
			
		||||
2:	movq	(%rsp),%r11
 | 
			
		||||
	movq	%rbx,(_JB_RBX * 8)(%rdi)
 | 
			
		||||
	movq	%rbp,(_JB_RBP * 8)(%rdi)
 | 
			
		||||
	movq	%r12,(_JB_R12 * 8)(%rdi)
 | 
			
		||||
	movq	%r13,(_JB_R13 * 8)(%rdi)
 | 
			
		||||
	movq	%r14,(_JB_R14 * 8)(%rdi)
 | 
			
		||||
	movq	%r15,(_JB_R15 * 8)(%rdi)
 | 
			
		||||
	movq	%rsp,(_JB_RSP * 8)(%rdi)
 | 
			
		||||
	movq	%r11,(_JB_PC  * 8)(%rdi)
 | 
			
		||||
 | 
			
		||||
2:	xorl	%eax,%eax
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
ENTRY(siglongjmp)
 | 
			
		||||
	movq	%rdi,%r12
 | 
			
		||||
	pushq   %rsi
 | 
			
		||||
	cmpl    $0, (_JB_SIGFLAG * 8)(%rdi)
 | 
			
		||||
	jz      2f
 | 
			
		||||
 | 
			
		||||
	movq	(_JB_SIGMASK * 8)(%rdi),%rdi
 | 
			
		||||
#ifdef __PIC__
 | 
			
		||||
	call	PIC_PLT(_C_LABEL(sigsetmask))
 | 
			
		||||
#else
 | 
			
		||||
	call	_C_LABEL(sigsetmask)
 | 
			
		||||
#endif
 | 
			
		||||
2:	popq	%rax
 | 
			
		||||
	movq	(_JB_RBX * 8)(%r12),%rbx
 | 
			
		||||
	movq	(_JB_RBP * 8)(%r12),%rbp
 | 
			
		||||
	movq	(_JB_R13 * 8)(%r12),%r13
 | 
			
		||||
	movq	(_JB_R14 * 8)(%r12),%r14
 | 
			
		||||
	movq	(_JB_R15 * 8)(%r12),%r15
 | 
			
		||||
	movq	(_JB_RSP * 8)(%r12),%rsp
 | 
			
		||||
	movq	(_JB_PC  * 8)(%r12),%r11
 | 
			
		||||
	movq	(_JB_R12 * 8)(%r12),%r12
 | 
			
		||||
 | 
			
		||||
	testl	%eax,%eax
 | 
			
		||||
	jnz	1f
 | 
			
		||||
	incl	%eax
 | 
			
		||||
1:	movq	%r11,0(%rsp)
 | 
			
		||||
	ret
 | 
			
		||||
							
								
								
									
										35
									
								
								libc/arch-x86_64/bionic/sigsuspend.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								libc/arch-x86_64/bionic/sigsuspend.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
extern int __rt_sigsuspend(const sigset_t*, size_t);
 | 
			
		||||
 | 
			
		||||
int sigsuspend(const sigset_t* set) {
 | 
			
		||||
  return __rt_sigsuspend(set, sizeof(sigset_t));
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										65
									
								
								libc/arch-x86_64/bionic/syscall.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								libc/arch-x86_64/bionic/syscall.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2013 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Generic syscall call.
 | 
			
		||||
 * Upon entry:
 | 
			
		||||
 *   %rax: system call number
 | 
			
		||||
 *   %rdi: arg0 to system call
 | 
			
		||||
 *   %rsi: arg1
 | 
			
		||||
 *   %rdx: arg2
 | 
			
		||||
 *   %rcx: arg3 - syscall expects it at %r10
 | 
			
		||||
 *   %r8: arg4
 | 
			
		||||
 *   %r9: arg5
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <asm/unistd.h>
 | 
			
		||||
#include <linux/err.h>
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
 | 
			
		||||
ENTRY(syscall)
 | 
			
		||||
    # All arguments are passed via registers.
 | 
			
		||||
    # (Not all will be valid, depending on the syscall.)
 | 
			
		||||
    mov     %edi, %eax
 | 
			
		||||
    mov     %rsi, %rdi
 | 
			
		||||
    mov     %rdx, %rsi
 | 
			
		||||
    mov     %rcx, %rdx
 | 
			
		||||
    mov     %r8,  %r10
 | 
			
		||||
    mov     %r9,  %r8
 | 
			
		||||
    mov     8(%rsp), %r9
 | 
			
		||||
 | 
			
		||||
    # Make the system call.
 | 
			
		||||
    syscall
 | 
			
		||||
    cmpq    $-MAX_ERRNO, %rax
 | 
			
		||||
    jb      1f
 | 
			
		||||
    negl    %eax
 | 
			
		||||
    movl    %eax, %edi
 | 
			
		||||
    call    __set_errno
 | 
			
		||||
    orq     $-1, %rax
 | 
			
		||||
1:
 | 
			
		||||
    ret
 | 
			
		||||
@@ -41,7 +41,7 @@ syscall_src += arch-x86_64/syscalls/vfork.S
 | 
			
		||||
syscall_src += arch-x86_64/syscalls/setregid.S
 | 
			
		||||
syscall_src += arch-x86_64/syscalls/chroot.S
 | 
			
		||||
syscall_src += arch-x86_64/syscalls/prctl.S
 | 
			
		||||
syscall_src += arch-x86_64/syscalls/arch_prctl.S
 | 
			
		||||
syscall_src += arch-x86_64/syscalls/__arch_prctl.S
 | 
			
		||||
syscall_src += arch-x86_64/syscalls/capget.S
 | 
			
		||||
syscall_src += arch-x86_64/syscalls/capset.S
 | 
			
		||||
syscall_src += arch-x86_64/syscalls/sigaltstack.S
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
#include <linux/err.h>
 | 
			
		||||
#include <machine/asm.h>
 | 
			
		||||
 | 
			
		||||
ENTRY(arch_prctl)
 | 
			
		||||
ENTRY(__arch_prctl)
 | 
			
		||||
    movl    $__NR_arch_prctl, %eax
 | 
			
		||||
    syscall
 | 
			
		||||
    cmpq    $-MAX_ERRNO, %rax
 | 
			
		||||
@@ -14,4 +14,4 @@ ENTRY(arch_prctl)
 | 
			
		||||
    orq     $-1, %rax
 | 
			
		||||
1:
 | 
			
		||||
    ret
 | 
			
		||||
END(arch_prctl)
 | 
			
		||||
END(__arch_prctl)
 | 
			
		||||
@@ -1,17 +1,18 @@
 | 
			
		||||
_LIBC_ARCH_COMMON_SRC_FILES := \
 | 
			
		||||
    arch-x86_64/bionic/__get_sp.S \
 | 
			
		||||
    arch-x86_64/bionic/__get_tls.c \
 | 
			
		||||
    arch-x86_64/bionic/__set_tls.c \
 | 
			
		||||
    arch-x86_64/bionic/clone.S \
 | 
			
		||||
    arch-x86_64/bionic/_exit_with_stack_teardown.S \
 | 
			
		||||
    arch-x86_64/bionic/futex_x86_64.S \
 | 
			
		||||
    arch-x86_64/bionic/setjmp.S \
 | 
			
		||||
    arch-x86_64/bionic/__get_sp.S \
 | 
			
		||||
    arch-x86_64/bionic/__get_tls.c \
 | 
			
		||||
    arch-x86_64/bionic/__rt_sigreturn.S \
 | 
			
		||||
    arch-x86_64/bionic/_setjmp.S \
 | 
			
		||||
    arch-x86_64/bionic/sigsetjmp.S \
 | 
			
		||||
    arch-x86_64/bionic/syscall.S \
 | 
			
		||||
    arch-x86_64/bionic/sigprocmask.c \
 | 
			
		||||
    arch-x86_64/bionic/setjmp.S \
 | 
			
		||||
    arch-x86_64/bionic/__set_tls.c \
 | 
			
		||||
    arch-x86_64/bionic/sigaction.c \
 | 
			
		||||
    arch-x86_64/bionic/sigprocmask.c \
 | 
			
		||||
    arch-x86_64/bionic/sigsetjmp.S \
 | 
			
		||||
    arch-x86_64/bionic/sigsuspend.c \
 | 
			
		||||
    arch-x86_64/bionic/syscall.S \
 | 
			
		||||
 | 
			
		||||
_LIBC_ARCH_STATIC_SRC_FILES := \
 | 
			
		||||
    bionic/dl_iterate_phdr_static.c \
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user