summaryrefslogtreecommitdiffstats
path: root/libc/arch-x86_64
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-10-04 22:02:06 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-10-04 22:02:07 +0000
commit8fb977ba114e3fcb4965bc0211d3f9a409915994 (patch)
treebf0ddebce7e7444f44529cf3f293e3fb3d6dd936 /libc/arch-x86_64
parentc417d0a5cd0743d691fc63cc1007979b836945a0 (diff)
parent4906e5653c57d49f94940f28556009a88c42a583 (diff)
downloadbionic-8fb977ba114e3fcb4965bc0211d3f9a409915994.zip
bionic-8fb977ba114e3fcb4965bc0211d3f9a409915994.tar.gz
bionic-8fb977ba114e3fcb4965bc0211d3f9a409915994.tar.bz2
Merge "Add arch-x86_64/bionic."
Diffstat (limited to 'libc/arch-x86_64')
-rw-r--r--libc/arch-x86_64/bionic/__get_sp.S34
-rw-r--r--libc/arch-x86_64/bionic/__get_tls.c33
-rw-r--r--libc/arch-x86_64/bionic/__rt_sigreturn.S36
-rw-r--r--libc/arch-x86_64/bionic/__set_tls.c38
-rw-r--r--libc/arch-x86_64/bionic/_exit_with_stack_teardown.S56
-rw-r--r--libc/arch-x86_64/bionic/_setjmp.S82
-rw-r--r--libc/arch-x86_64/bionic/clone.S111
-rw-r--r--libc/arch-x86_64/bionic/futex_x86_64.S67
-rw-r--r--libc/arch-x86_64/bionic/setjmp.S103
-rw-r--r--libc/arch-x86_64/bionic/sigaction.c52
-rw-r--r--libc/arch-x86_64/bionic/sigprocmask.c35
-rw-r--r--libc/arch-x86_64/bionic/sigsetjmp.S107
-rw-r--r--libc/arch-x86_64/bionic/sigsuspend.c35
-rw-r--r--libc/arch-x86_64/bionic/syscall.S65
-rw-r--r--libc/arch-x86_64/syscalls.mk2
-rw-r--r--libc/arch-x86_64/syscalls/__arch_prctl.S (renamed from libc/arch-x86_64/syscalls/arch_prctl.S)4
-rw-r--r--libc/arch-x86_64/x86_64.mk15
17 files changed, 865 insertions, 10 deletions
diff --git a/libc/arch-x86_64/bionic/__get_sp.S b/libc/arch-x86_64/bionic/__get_sp.S
new file mode 100644
index 0000000..0c693b3
--- /dev/null
+++ b/libc/arch-x86_64/bionic/__get_sp.S
@@ -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)
diff --git a/libc/arch-x86_64/bionic/__get_tls.c b/libc/arch-x86_64/bionic/__get_tls.c
new file mode 100644
index 0000000..f21b6b8
--- /dev/null
+++ b/libc/arch-x86_64/bionic/__get_tls.c
@@ -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;
+}
diff --git a/libc/arch-x86_64/bionic/__rt_sigreturn.S b/libc/arch-x86_64/bionic/__rt_sigreturn.S
new file mode 100644
index 0000000..e03bb88
--- /dev/null
+++ b/libc/arch-x86_64/bionic/__rt_sigreturn.S
@@ -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)
diff --git a/libc/arch-x86_64/bionic/__set_tls.c b/libc/arch-x86_64/bionic/__set_tls.c
new file mode 100644
index 0000000..9a69449
--- /dev/null
+++ b/libc/arch-x86_64/bionic/__set_tls.c
@@ -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);
+}
diff --git a/libc/arch-x86_64/bionic/_exit_with_stack_teardown.S b/libc/arch-x86_64/bionic/_exit_with_stack_teardown.S
new file mode 100644
index 0000000..66105f2
--- /dev/null
+++ b/libc/arch-x86_64/bionic/_exit_with_stack_teardown.S
@@ -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
diff --git a/libc/arch-x86_64/bionic/_setjmp.S b/libc/arch-x86_64/bionic/_setjmp.S
new file mode 100644
index 0000000..d9a59f7
--- /dev/null
+++ b/libc/arch-x86_64/bionic/_setjmp.S
@@ -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
diff --git a/libc/arch-x86_64/bionic/clone.S b/libc/arch-x86_64/bionic/clone.S
new file mode 100644
index 0000000..df2929e
--- /dev/null
+++ b/libc/arch-x86_64/bionic/clone.S
@@ -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
+
diff --git a/libc/arch-x86_64/bionic/futex_x86_64.S b/libc/arch-x86_64/bionic/futex_x86_64.S
new file mode 100644
index 0000000..d94792e
--- /dev/null
+++ b/libc/arch-x86_64/bionic/futex_x86_64.S
@@ -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
diff --git a/libc/arch-x86_64/bionic/setjmp.S b/libc/arch-x86_64/bionic/setjmp.S
new file mode 100644
index 0000000..1641add
--- /dev/null
+++ b/libc/arch-x86_64/bionic/setjmp.S
@@ -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
diff --git a/libc/arch-x86_64/bionic/sigaction.c b/libc/arch-x86_64/bionic/sigaction.c
new file mode 100644
index 0000000..d5622be
--- /dev/null
+++ b/libc/arch-x86_64/bionic/sigaction.c
@@ -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;
+}
+
diff --git a/libc/arch-x86_64/bionic/sigprocmask.c b/libc/arch-x86_64/bionic/sigprocmask.c
new file mode 100644
index 0000000..cdafa08
--- /dev/null
+++ b/libc/arch-x86_64/bionic/sigprocmask.c
@@ -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));
+}
diff --git a/libc/arch-x86_64/bionic/sigsetjmp.S b/libc/arch-x86_64/bionic/sigsetjmp.S
new file mode 100644
index 0000000..51b055a
--- /dev/null
+++ b/libc/arch-x86_64/bionic/sigsetjmp.S
@@ -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
diff --git a/libc/arch-x86_64/bionic/sigsuspend.c b/libc/arch-x86_64/bionic/sigsuspend.c
new file mode 100644
index 0000000..40bfaea
--- /dev/null
+++ b/libc/arch-x86_64/bionic/sigsuspend.c
@@ -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));
+}
diff --git a/libc/arch-x86_64/bionic/syscall.S b/libc/arch-x86_64/bionic/syscall.S
new file mode 100644
index 0000000..6b84ba4
--- /dev/null
+++ b/libc/arch-x86_64/bionic/syscall.S
@@ -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
diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk
index 5a7a880..08fdf38 100644
--- a/libc/arch-x86_64/syscalls.mk
+++ b/libc/arch-x86_64/syscalls.mk
@@ -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
diff --git a/libc/arch-x86_64/syscalls/arch_prctl.S b/libc/arch-x86_64/syscalls/__arch_prctl.S
index eaf9494..21d154c 100644
--- a/libc/arch-x86_64/syscalls/arch_prctl.S
+++ b/libc/arch-x86_64/syscalls/__arch_prctl.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)
diff --git a/libc/arch-x86_64/x86_64.mk b/libc/arch-x86_64/x86_64.mk
index 6a2bb9c..d9c8f12 100644
--- a/libc/arch-x86_64/x86_64.mk
+++ b/libc/arch-x86_64/x86_64.mk
@@ -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 \