summaryrefslogtreecommitdiffstats
path: root/libc/arch-x86
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:48 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:48 -0800
commit4e468ed2eb86a2406e14f1eca82072ee501d05fd (patch)
tree4e05b3c66eef86531e464521a3bf96a1864d4bf5 /libc/arch-x86
parenta27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 (diff)
downloadbionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.zip
bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.tar.gz
bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'libc/arch-x86')
-rwxr-xr-xlibc/arch-x86/bionic/__get_tls.c4
-rwxr-xr-xlibc/arch-x86/bionic/__set_tls.c14
-rw-r--r--libc/arch-x86/bionic/_exit_with_stack_teardown.S34
-rw-r--r--libc/arch-x86/bionic/_setjmp.S71
-rw-r--r--libc/arch-x86/bionic/atomics_x86.S140
-rw-r--r--libc/arch-x86/bionic/clone.S50
-rw-r--r--libc/arch-x86/bionic/crtbegin_dynamic.S96
-rw-r--r--libc/arch-x86/bionic/crtbegin_so.S29
-rw-r--r--libc/arch-x86/bionic/crtbegin_static.S95
-rw-r--r--libc/arch-x86/bionic/crtend.S13
-rw-r--r--libc/arch-x86/bionic/crtend_so.S47
-rw-r--r--libc/arch-x86/bionic/dl_iterate_phdr_static.c74
-rw-r--r--libc/arch-x86/bionic/setjmp.S93
-rw-r--r--libc/arch-x86/bionic/vfork.S30
-rw-r--r--libc/arch-x86/include/machine/asm.h12
-rw-r--r--libc/arch-x86/include/machine/kernel.h41
-rw-r--r--libc/arch-x86/syscalls.mk171
-rw-r--r--libc/arch-x86/syscalls/__fork.S (renamed from libc/arch-x86/syscalls/fork.S)6
-rw-r--r--libc/arch-x86/syscalls/__pread64.S35
-rw-r--r--libc/arch-x86/syscalls/__pwrite64.S35
-rw-r--r--libc/arch-x86/syscalls/__timer_create.S (renamed from libc/arch-x86/syscalls/timer_create.S)6
-rw-r--r--libc/arch-x86/syscalls/__timer_delete.S (renamed from libc/arch-x86/syscalls/timer_delete.S)6
-rw-r--r--libc/arch-x86/syscalls/__timer_getoverrun.S (renamed from libc/arch-x86/syscalls/timer_getoverrun.S)6
-rw-r--r--libc/arch-x86/syscalls/__timer_gettime.S (renamed from libc/arch-x86/syscalls/timer_gettime.S)6
-rw-r--r--libc/arch-x86/syscalls/__timer_settime.S (renamed from libc/arch-x86/syscalls/timer_settime.S)6
-rw-r--r--libc/arch-x86/syscalls/accept.S27
-rw-r--r--libc/arch-x86/syscalls/bind.S27
-rw-r--r--libc/arch-x86/syscalls/connect.S27
-rw-r--r--libc/arch-x86/syscalls/getitimer.S26
-rw-r--r--libc/arch-x86/syscalls/getpeername.S27
-rw-r--r--libc/arch-x86/syscalls/getsockname.S27
-rw-r--r--libc/arch-x86/syscalls/getsockopt.S27
-rw-r--r--libc/arch-x86/syscalls/listen.S27
-rw-r--r--libc/arch-x86/syscalls/recvfrom.S27
-rw-r--r--libc/arch-x86/syscalls/recvmsg.S27
-rw-r--r--libc/arch-x86/syscalls/sendmsg.S27
-rw-r--r--libc/arch-x86/syscalls/sendto.S27
-rw-r--r--libc/arch-x86/syscalls/setsockopt.S27
-rw-r--r--libc/arch-x86/syscalls/shutdown.S27
-rw-r--r--libc/arch-x86/syscalls/socket.S27
-rw-r--r--libc/arch-x86/syscalls/socketpair.S27
-rw-r--r--libc/arch-x86/syscalls/vfork.S23
42 files changed, 1529 insertions, 45 deletions
diff --git a/libc/arch-x86/bionic/__get_tls.c b/libc/arch-x86/bionic/__get_tls.c
index 68dda86..5ac6e44 100755
--- a/libc/arch-x86/bionic/__get_tls.c
+++ b/libc/arch-x86/bionic/__get_tls.c
@@ -26,12 +26,12 @@
* SUCH DAMAGE.
*/
/* see the implementation of __set_tls and pthread.c to understand this
- * code. Basically, the content of fs:[0] always is a pointer to the base
+ * code. Basically, the content of gs:[0] always is a pointer to the base
* address of the tls region
*/
void* __get_tls(void)
{
void* tls;
- asm ( " movl %%fs:0,%0" : "=r"(tls) );
+ asm ( " movl %%gs:0, %0" : "=r"(tls) );
return tls;
}
diff --git a/libc/arch-x86/bionic/__set_tls.c b/libc/arch-x86/bionic/__set_tls.c
index 8dff8d7..48b55f0 100755
--- a/libc/arch-x86/bionic/__set_tls.c
+++ b/libc/arch-x86/bionic/__set_tls.c
@@ -27,6 +27,7 @@
*/
#include <pthread.h>
+
struct user_desc {
unsigned int entry_number;
unsigned long base_addr;
@@ -40,6 +41,8 @@ struct user_desc {
unsigned int empty:25;
};
+extern int __set_thread_area(struct user_desc *u_info);
+
/* the following can't be const, since the first call will
* update the 'entry_number' field
*/
@@ -57,7 +60,11 @@ static struct user_desc _tls_desc =
0
};
-/* we implement thread local storage through the fs: segment descriptor
+struct _thread_area_head {
+ void *self;
+};
+
+/* we implement thread local storage through the gs: segment descriptor
* we create a segment descriptor for the tls
*/
int __set_tls(void *ptr)
@@ -66,6 +73,9 @@ int __set_tls(void *ptr)
_tls_desc.base_addr = (unsigned long)ptr;
+ /* We also need to write the location of the tls to ptr[0] */
+ ((struct _thread_area_head *)ptr)->self = ptr;
+
rc = __set_thread_area( &_tls_desc );
if (rc != 0)
{
@@ -76,7 +86,7 @@ int __set_tls(void *ptr)
/* this weird computation comes from GLibc */
segment = _tls_desc.entry_number*8 + 3;
asm __volatile__ (
- " movw %w0, %%fs" :: "r"(segment)
+ " movw %w0, %%gs" :: "q"(segment)
);
return 0;
}
diff --git a/libc/arch-x86/bionic/_exit_with_stack_teardown.S b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
new file mode 100644
index 0000000..83a504d
--- /dev/null
+++ b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
@@ -0,0 +1,34 @@
+#include <sys/linux-syscalls.h>
+
+.text
+.type _exit_with_stack_teardown, @function
+.globl _exit_with_stack_teardown
+.align 4
+
+/*
+ * void _exit_with_stack_teardown(void *stackBase, int stackSize, int *retCode)
+ */
+
+_exit_with_stack_teardown:
+ /* we can trash %ebx 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.
+ */
+ mov 4(%esp), %ebx /* stackBase */
+ mov 8(%esp), %ecx /* stackSize */
+ mov 12(%esp), %edx /* retCode, not used for munmap */
+ mov $__NR_munmap, %eax
+ int $0x80
+ mov %edx, %ebx /* retrieve the retCode */
+ movl $__NR_exit, %eax
+ int $0x80
+ /* 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/bionic/_setjmp.S b/libc/arch-x86/bionic/_setjmp.S
new file mode 100644
index 0000000..ac62635
--- /dev/null
+++ b/libc/arch-x86/bionic/_setjmp.S
@@ -0,0 +1,71 @@
+/* $OpenBSD: _setjmp.S,v 1.5 2005/08/07 11:30:38 espie Exp $ */
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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>
+
+/*
+ * 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)
+ movl 4(%esp),%eax
+ movl 0(%esp),%edx
+ movl %edx, 0(%eax) /* rta */
+ movl %ebx, 4(%eax)
+ movl %esp, 8(%eax)
+ movl %ebp,12(%eax)
+ movl %esi,16(%eax)
+ movl %edi,20(%eax)
+ xorl %eax,%eax
+ ret
+
+ENTRY(_longjmp)
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ movl 0(%edx),%ecx
+ movl 4(%edx),%ebx
+ movl 8(%edx),%esp
+ movl 12(%edx),%ebp
+ movl 16(%edx),%esi
+ movl 20(%edx),%edi
+ testl %eax,%eax
+ jnz 1f
+ incl %eax
+1: movl %ecx,0(%esp)
+ ret
diff --git a/libc/arch-x86/bionic/atomics_x86.S b/libc/arch-x86/bionic/atomics_x86.S
new file mode 100644
index 0000000..2370f23
--- /dev/null
+++ b/libc/arch-x86/bionic/atomics_x86.S
@@ -0,0 +1,140 @@
+#include <sys/linux-syscalls.h>
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+
+
+/*
+ * int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout)
+ */
+.text
+.globl __futex_wait
+.type __futex_wait, @function
+.align 4
+__futex_wait:
+ pushl %ebx
+ pushl %esi
+ mov 12(%esp), %ebx /* ftx */
+ movl $FUTEX_WAIT, %ecx
+ mov 16(%esp), %edx /* val */
+ mov 20(%esp), %esi /* timeout */
+ movl $__NR_futex, %eax
+ int $0x80
+ popl %esi
+ popl %ebx
+ ret
+
+
+/* int __futex_wake(volatile void *ftx, int count) */
+
+.text
+.globl __futex_wake
+.type __futex_wake, @function
+.align 4
+__futex_wake:
+ pushl %ebx
+ mov 8(%esp), %ebx /* ftx */
+ movl $FUTEX_WAKE, %ecx
+ mov 12(%esp), %edx /* count */
+ movl $__NR_futex, %eax
+ int $0x80
+ popl %ebx
+ ret
+
+
+/* int __atomic_cmpxchg(int old, int new, volatile int* addr) */
+
+.text
+.globl __atomic_cmpxchg
+.type __atomic_cmpxchg, @function
+.align 4
+__atomic_cmpxchg:
+ mov 4(%esp), %eax /* old */
+ mov 8(%esp), %ecx /* new */
+ mov 12(%esp), %edx /* addr */
+ lock cmpxchg %ecx, (%edx)
+ jnz 1f
+ xor %eax, %eax
+ jmp 2f
+1:
+ movl $1, %eax
+2:
+ ret /* 0 == success, 1 == failure */
+
+
+/* int __atomic_swap(int new, volatile int* addr) */
+
+.text
+.globl __atomic_swap
+.type __atomic_swap, @function
+.align 4
+__atomic_swap:
+ mov 4(%esp), %ecx /* new */
+ mov 8(%esp), %edx /* addr */
+ lock xchg %ecx, (%edx)
+ mov %ecx, %eax
+ ret
+
+
+/*
+ * int __atomic_dec(volatile int* addr)
+ *
+ * My x86 asm is really rusty.. this is probably suboptimal
+ */
+
+.text
+.globl __atomic_dec
+.type __atomic_dec, @function
+.align 4
+__atomic_dec:
+ pushl %ebx
+ pushl %esi
+ movl 12(%esp), %ebx /* addr */
+
+1:
+ movl (%ebx), %esi /* old = *addr */
+ movl %esi, %edx
+ subl $1, %edx /* new = old - 1 */
+
+ pushl %ebx
+ pushl %edx
+ pushl %esi
+ call __atomic_cmpxchg
+ addl $12, %esp
+ test %eax, %eax
+ jnz 1b
+
+ movl %esi, %eax /* return old */
+ popl %esi
+ popl %ebx
+ ret
+
+
+.text
+/* int __atomic_inc(volatile int* addr) */
+.globl __atomic_inc
+.type __atomic_inc, @function
+.align 4
+__atomic_inc:
+ pushl %ebx
+ pushl %esi
+ movl 12(%esp), %ebx /* addr */
+
+1:
+ movl (%ebx), %esi /* old = *addr */
+ movl %esi, %edx
+ addl $1, %edx /* new = old + 1 */
+
+ pushl %ebx
+ pushl %edx
+ pushl %esi
+ call __atomic_cmpxchg
+ addl $12, %esp
+ test %eax, %eax
+ jnz 1b
+
+ movl %esi, %eax /* return old */
+ popl %esi
+ popl %ebx
+ ret
+
diff --git a/libc/arch-x86/bionic/clone.S b/libc/arch-x86/bionic/clone.S
new file mode 100644
index 0000000..361808d
--- /dev/null
+++ b/libc/arch-x86/bionic/clone.S
@@ -0,0 +1,50 @@
+#include <sys/linux-syscalls.h>
+
+.text
+
+/*
+ * int __pthread_clone(int (*fn)(void*), void *tls, int flags,
+ * void *arg);
+ */
+.globl __pthread_clone
+.type __pthread_clone, @function
+.align 4
+__pthread_clone:
+ pushl %ebx
+ pushl %ecx
+ movl 16(%esp), %ecx
+ movl 20(%esp), %ebx
+
+ # insert arguments onto the child stack
+ movl 12(%esp), %eax
+ movl %eax, -12(%ecx)
+ movl 24(%esp), %eax
+ movl %eax, -8(%ecx)
+ lea (%ecx), %eax
+ movl %eax, -4(%ecx)
+
+ movl $__NR_clone, %eax
+ int $0x80
+ test %eax, %eax
+ jns 1f
+
+ # an error occured, set errno and return -1
+ negl %eax
+ 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
+ subl $16, %esp
+ jmp __thread_entry
+ hlt
+
+2:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/bionic/crtbegin_dynamic.S b/libc/arch-x86/bionic/crtbegin_dynamic.S
new file mode 100644
index 0000000..3b47b18
--- /dev/null
+++ b/libc/arch-x86/bionic/crtbegin_dynamic.S
@@ -0,0 +1,96 @@
+# bionic/arch-x86/bionic/crtbegin_dynamic.S
+#
+# Copyright 2006, The Android Open Source Project
+#
+# 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.
+# * Neither the name of Google Inc. nor the names of its contributors may
+# be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY Google 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 Google 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.
+
+ .text
+ .align 4
+ .type _start, @function
+ .globl _start
+
+# this is the small startup code that is first run when
+# any executable that is statically-linked with Bionic
+# runs.
+#
+# it's purpose is to call __libc_init with appropriate
+# arguments, which are:
+#
+# - the address of the raw data block setup by the Linux
+# kernel ELF loader
+#
+# - address of an "onexit" function, not used on any
+# platform supported by Bionic
+#
+# - address of the "main" function of the program. We
+# can't hard-code it in the adr pseudo instruction
+# so we use a tiny trampoline that will get relocated
+# by the dynamic linker before this code runs
+#
+# - address of the constructor list
+#
+_start:
+ mov %esp, %eax
+ mov $1f, %edx
+ pushl %edx
+ mov $0f, %edx
+ pushl %edx
+ mov $0, %edx
+ pushl %edx
+ pushl %eax
+ call __libc_init
+
+0:
+ jmp main
+
+1: .long __PREINIT_ARRAY__
+ .long __INIT_ARRAY__
+ .long __FINI_ARRAY__
+ .long __CTOR_LIST__
+
+# the .ctors section contains a list of pointers to "constructor"
+# functions that need to be called in order during C library initialization,
+# just before the program is being run. This is a C++ requirement
+#
+# the last entry shall be 0, and is defined in crtend.S
+#
+ .section .preinit_array, "aw"
+ .globl __PREINIT_ARRAY__
+__PREINIT_ARRAY__:
+ .long -1
+
+ .section .init_array, "aw"
+ .globl __INIT_ARRAY__
+__INIT_ARRAY__:
+ .long -1
+
+ .section .fini_array, "aw"
+ .globl __FINI_ARRAY__
+__FINI_ARRAY__:
+ .long -1
+
+ .section .ctors, "aw"
+ .globl __CTOR_LIST__
+__CTOR_LIST__:
+ .long -1
+
diff --git a/libc/arch-x86/bionic/crtbegin_so.S b/libc/arch-x86/bionic/crtbegin_so.S
new file mode 100644
index 0000000..d49e9df
--- /dev/null
+++ b/libc/arch-x86/bionic/crtbegin_so.S
@@ -0,0 +1,29 @@
+/* we put the _init() function here in case the user files for the shared
+ * libs want to drop things into .init section.
+ * We then will call our ctors from crtend_so.o */
+.section .init
+.align 4
+.type _init, @function
+.globl _init
+_init:
+
+.section .init_array, "aw"
+.align 4
+.type __INIT_ARRAY__, @object
+.globl __INIT_ARRAY__
+__INIT_ARRAY__:
+ .long -1
+
+.section .fini_array, "aw"
+.align 4
+.type __FINI_ARRAY__, @object
+.globl __FINI_ARRAY__
+__FINI_ARRAY__:
+ .long -1
+
+.section .ctors, "aw"
+.align 4
+.type __CTOR_LIST__, @object
+.globl __CTOR_LIST__
+__CTOR_LIST__:
+ .long -1
diff --git a/libc/arch-x86/bionic/crtbegin_static.S b/libc/arch-x86/bionic/crtbegin_static.S
new file mode 100644
index 0000000..eb4acee
--- /dev/null
+++ b/libc/arch-x86/bionic/crtbegin_static.S
@@ -0,0 +1,95 @@
+# bionic/arch-x86/bionic/crtbegin_static.S
+#
+# Copyright 2006, The Android Open Source Project
+#
+# 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.
+# * Neither the name of Google Inc. nor the names of its contributors may
+# be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY Google 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 Google 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.
+
+ .text
+ .align 4
+ .type _start, @function
+ .globl _start
+
+# this is the small startup code that is first run when
+# any executable that is statically-linked with Bionic
+# runs.
+#
+# it's purpose is to call __libc_init with appropriate
+# arguments, which are:
+#
+# - the address of the raw data block setup by the Linux
+# kernel ELF loader
+#
+# - address of an "onexit" function, not used on any
+# platform supported by Bionic
+#
+# - address of the "main" function of the program. We
+# can't hard-code it in the adr pseudo instruction
+# so we use a tiny trampoline that will get relocated
+# by the dynamic linker before this code runs
+#
+# - address of the constructor list
+#
+_start:
+ mov %esp, %eax
+ mov $1f, %edx
+ pushl %edx
+ mov $0f, %edx
+ pushl %edx
+ mov $0, %edx
+ pushl %edx
+ pushl %eax
+ call __libc_init
+
+0: jmp main
+
+1: .long __PREINIT_ARRAY__
+ .long __INIT_ARRAY__
+ .long __FINI_ARRAY__
+ .long __CTOR_LIST__
+
+# the .ctors section contains a list of pointers to "constructor"
+# functions that need to be called in order during C library initialization,
+# just before the program is being run. This is a C++ requirement
+#
+# the last entry shall be 0, and is defined in crtend.S
+#
+ .section .preinit_array, "aw"
+ .globl __PREINIT_ARRAY__
+__PREINIT_ARRAY__:
+ .long -1
+
+ .section .init_array, "aw"
+ .globl __INIT_ARRAY__
+__INIT_ARRAY__:
+ .long -1
+
+ .section .fini_array, "aw"
+ .globl __FINI_ARRAY__
+__FINI_ARRAY__:
+ .long -1
+
+ .section .ctors, "aw"
+ .globl __CTOR_LIST__
+__CTOR_LIST__:
+ .long -1
+
diff --git a/libc/arch-x86/bionic/crtend.S b/libc/arch-x86/bionic/crtend.S
new file mode 100644
index 0000000..7f5fb66
--- /dev/null
+++ b/libc/arch-x86/bionic/crtend.S
@@ -0,0 +1,13 @@
+
+ .section .preinit_array, "aw"
+ .long 0
+
+ .section .init_array, "aw"
+ .long 0
+
+ .section .fini_array, "aw"
+ .long 0
+
+ .section .ctors, "aw"
+ .long 0
+
diff --git a/libc/arch-x86/bionic/crtend_so.S b/libc/arch-x86/bionic/crtend_so.S
new file mode 100644
index 0000000..7fb2280
--- /dev/null
+++ b/libc/arch-x86/bionic/crtend_so.S
@@ -0,0 +1,47 @@
+.text
+.align 4
+.type __bionic_call_ctors, @function
+
+/*
+ * The CTORS_LIST is marked by -1 (start) and 0 (end).
+ * We mark the end of the .ctors section with the __CTOR_END__ section so
+ * that we can just iterate backwards from it until we hit -1 and execute
+ * all the function pointers. This seems to be the way to do it for SVR4
+ * derived systems.
+ */
+__bionic_call_ctors:
+ pushl %esi
+ mov $__CTOR_END__, %esi
+
+0:
+ /* now grab the next function pointer and check if its -1. If not,
+ * call it, otherwise we're done. We use %esi since it's callee saved.
+ */
+ subl $4, %esi
+ mov (%esi), %eax
+ cmp $0xffffffff, %eax
+ je 1f
+ call *%eax
+ jmp 0b
+
+1:
+ /* we're done */
+ popl %esi
+ ret
+
+.section .init
+.align 4
+ call __bionic_call_ctors
+ ret
+
+.section .ctors, "aw", @progbits
+.align 4
+.type __CTOR_END__, @object
+__CTOR_END__:
+ .long 0
+
+.section .init_array, "aw"
+ .long 0
+
+.section .fini_array, "aw"
+ .long 0
diff --git a/libc/arch-x86/bionic/dl_iterate_phdr_static.c b/libc/arch-x86/bionic/dl_iterate_phdr_static.c
new file mode 100644
index 0000000..fd12106
--- /dev/null
+++ b/libc/arch-x86/bionic/dl_iterate_phdr_static.c
@@ -0,0 +1,74 @@
+/* bionic/arch-x86/bionic/dl_iterate_phdr_static.c
+**
+** Copyright 2006, The Android Open Source Project
+**
+** 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.
+** * Neither the name of Google Inc. nor the names of its contributors may
+** be used to endorse or promote products derived from this software
+** without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY Google 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 Google 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 <sys/types.h>
+#include <linux/elf.h>
+
+/* TODO: Move this into a header that linker.h can also pull it in.
+ * Silly to have same struct in 2 places. This is temporary. */
+struct dl_phdr_info
+{
+ Elf32_Addr dlpi_addr;
+ const char *dlpi_name;
+ const Elf32_Phdr *dlpi_phdr;
+ Elf32_Half dlpi_phnum;
+};
+
+/* Dynamic binaries get this from the dynamic linker (system/linker), which
+ * we don't pull in for static bins. We also don't have a list of so's to
+ * iterate over, since there's really only a single monolithic blob of
+ * code/data.
+ *
+ * All we need to do is to find where the executable is in memory, and grab the
+ * phdr and phnum from there.
+ */
+
+/* ld provides this to us in the default link script */
+extern void *__executable_start;
+
+int
+dl_iterate_phdr(int (*cb)(struct dl_phdr_info *info, size_t size, void *data),
+ void *data)
+{
+ struct dl_phdr_info dl_info;
+ Elf32_Ehdr *ehdr = (Elf32_Ehdr *) &__executable_start;
+ Elf32_Phdr *phdr = (Elf32_Phdr *)((unsigned long)ehdr + ehdr->e_phoff);
+
+ /* TODO: again, copied from linker.c. Find a better home for this
+ * later. */
+ if (ehdr->e_ident[EI_MAG0] != ELFMAG0) return -1;
+ if (ehdr->e_ident[EI_MAG1] != ELFMAG1) return -1;
+ if (ehdr->e_ident[EI_MAG2] != ELFMAG2) return -1;
+ if (ehdr->e_ident[EI_MAG3] != ELFMAG3) return -1;
+
+ dl_info.dlpi_addr = 0;
+ dl_info.dlpi_name = NULL;
+ dl_info.dlpi_phdr = phdr;
+ dl_info.dlpi_phnum = ehdr->e_phnum;
+ return cb(&dl_info, sizeof (struct dl_phdr_info), data);
+}
+
diff --git a/libc/arch-x86/bionic/setjmp.S b/libc/arch-x86/bionic/setjmp.S
new file mode 100644
index 0000000..bcb5f9d
--- /dev/null
+++ b/libc/arch-x86/bionic/setjmp.S
@@ -0,0 +1,93 @@
+/* $OpenBSD: setjmp.S,v 1.8 2005/08/07 11:30:38 espie Exp $ */
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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>
+
+/*
+ * 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)
+ PIC_PROLOGUE
+ pushl $0
+#ifdef PIC
+ call PIC_PLT(_C_LABEL(sigblock))
+#else
+ call _C_LABEL(sigblock)
+#endif
+ addl $4,%esp
+ PIC_EPILOGUE
+
+ movl 4(%esp),%ecx
+ movl 0(%esp),%edx
+ movl %edx, 0(%ecx)
+ movl %ebx, 4(%ecx)
+ movl %esp, 8(%ecx)
+ movl %ebp,12(%ecx)
+ movl %esi,16(%ecx)
+ movl %edi,20(%ecx)
+ movl %eax,24(%ecx)
+ xorl %eax,%eax
+ ret
+
+ENTRY(longjmp)
+ movl 4(%esp),%edx
+ PIC_PROLOGUE
+ pushl 24(%edx)
+#ifdef PIC
+ call PIC_PLT(_C_LABEL(sigsetmask))
+#else
+ call _C_LABEL(sigsetmask)
+#endif
+ addl $4,%esp
+ PIC_EPILOGUE
+
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ movl 0(%edx),%ecx
+ movl 4(%edx),%ebx
+ movl 8(%edx),%esp
+ movl 12(%edx),%ebp
+ movl 16(%edx),%esi
+ movl 20(%edx),%edi
+ testl %eax,%eax
+ jnz 1f
+ incl %eax
+1: movl %ecx,0(%esp)
+ ret
diff --git a/libc/arch-x86/bionic/vfork.S b/libc/arch-x86/bionic/vfork.S
new file mode 100644
index 0000000..53910ab
--- /dev/null
+++ b/libc/arch-x86/bionic/vfork.S
@@ -0,0 +1,30 @@
+#include <sys/linux-syscalls.h>
+
+#ifndef __NR_vfork
+#define __NR_vfork 190
+#endif
+
+
+ .text
+ .type vfork, @function
+ .globl vfork
+ .align 4
+
+/* Get rid of the stack modifications (popl/ret) after vfork() success.
+ * vfork is VERY sneaky. One has to be very careful about what can be done
+ * between a successful vfork and a a subsequent execve()
+ */
+
+vfork:
+ /* grab the return address */
+ popl %ecx
+ movl $__NR_vfork, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ orl $-1, %eax
+1:
+ jmp *%ecx
diff --git a/libc/arch-x86/include/machine/asm.h b/libc/arch-x86/include/machine/asm.h
index f2da575..7a23060 100644
--- a/libc/arch-x86/include/machine/asm.h
+++ b/libc/arch-x86/include/machine/asm.h
@@ -38,6 +38,17 @@
#ifndef _I386_ASM_H_
#define _I386_ASM_H_
+/* This is borrowed from FreeBSD /src/sys/i386/include/asmacros.h v1.27 */
+/*
+ * CNAME and HIDENAME manage the relationship between symbol names in C
+ * and the equivalent assembly language names. CNAME is given a name as
+ * it would be used in a C program. It expands to the equivalent assembly
+ * language name. HIDENAME is given an assembly-language name, and expands
+ * to a possibly-modified form that will be invisible to C programs.
+ */
+#define CNAME(csym) csym
+#define HIDENAME(asmsym) .asmsym
+
#ifdef PIC
#define PIC_PROLOGUE \
pushl %ebx; \
@@ -108,5 +119,6 @@
#define ASMSTR .asciz
#define RCSID(x) .text; .asciz x
+#define __FBSDID(x) RCSID(x)
#endif /* !_I386_ASM_H_ */
diff --git a/libc/arch-x86/include/machine/kernel.h b/libc/arch-x86/include/machine/kernel.h
new file mode 100644
index 0000000..19d1577
--- /dev/null
+++ b/libc/arch-x86/include/machine/kernel.h
@@ -0,0 +1,41 @@
+/* bionic/arch-arm/include/machine/kernel.h
+**
+** Copyright 2006-2008, The Android Open Source Project
+**
+** 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.
+** * Neither the name of Google Inc. nor the names of its contributors may
+** be used to endorse or promote products derived from this software
+** without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY Google 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 Google 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.
+*/
+#ifndef _ARCH_X86_KERNEL_H
+#define _ARCH_X86_KERNEL_H
+
+/* this file contains kernel-specific definitions that were optimized out of
+ our processed kernel headers, but still useful nonetheless... */
+
+typedef unsigned long __kernel_blkcnt_t;
+typedef unsigned long __kernel_blksize_t;
+
+/* these aren't really defined by the kernel headers though... */
+typedef unsigned long __kernel_fsblkcnt_t;
+typedef unsigned long __kernel_fsfilcnt_t;
+typedef unsigned int __kernel_id_t;
+
+#endif /* _ARCH_X86_KERNEL_H */
diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk
new file mode 100644
index 0000000..86d2308
--- /dev/null
+++ b/libc/arch-x86/syscalls.mk
@@ -0,0 +1,171 @@
+# auto-generated by gensyscalls.py, do not touch
+syscall_src :=
+syscall_src += arch-x86/syscalls/_exit.S
+syscall_src += arch-x86/syscalls/_exit_thread.S
+syscall_src += arch-x86/syscalls/__fork.S
+syscall_src += arch-x86/syscalls/_waitpid.S
+syscall_src += arch-x86/syscalls/waitid.S
+syscall_src += arch-x86/syscalls/__clone.S
+syscall_src += arch-x86/syscalls/execve.S
+syscall_src += arch-x86/syscalls/setuid.S
+syscall_src += arch-x86/syscalls/getuid.S
+syscall_src += arch-x86/syscalls/getgid.S
+syscall_src += arch-x86/syscalls/geteuid.S
+syscall_src += arch-x86/syscalls/getegid.S
+syscall_src += arch-x86/syscalls/getresuid.S
+syscall_src += arch-x86/syscalls/getresgid.S
+syscall_src += arch-x86/syscalls/gettid.S
+syscall_src += arch-x86/syscalls/getgroups.S
+syscall_src += arch-x86/syscalls/getpgid.S
+syscall_src += arch-x86/syscalls/getppid.S
+syscall_src += arch-x86/syscalls/setsid.S
+syscall_src += arch-x86/syscalls/setgid.S
+syscall_src += arch-x86/syscalls/setreuid.S
+syscall_src += arch-x86/syscalls/setresuid.S
+syscall_src += arch-x86/syscalls/setresgid.S
+syscall_src += arch-x86/syscalls/__brk.S
+syscall_src += arch-x86/syscalls/kill.S
+syscall_src += arch-x86/syscalls/tkill.S
+syscall_src += arch-x86/syscalls/__ptrace.S
+syscall_src += arch-x86/syscalls/__set_thread_area.S
+syscall_src += arch-x86/syscalls/__getpriority.S
+syscall_src += arch-x86/syscalls/setpriority.S
+syscall_src += arch-x86/syscalls/setrlimit.S
+syscall_src += arch-x86/syscalls/getrlimit.S
+syscall_src += arch-x86/syscalls/getrusage.S
+syscall_src += arch-x86/syscalls/setgroups.S
+syscall_src += arch-x86/syscalls/setpgid.S
+syscall_src += arch-x86/syscalls/setregid.S
+syscall_src += arch-x86/syscalls/chroot.S
+syscall_src += arch-x86/syscalls/prctl.S
+syscall_src += arch-x86/syscalls/capget.S
+syscall_src += arch-x86/syscalls/capset.S
+syscall_src += arch-x86/syscalls/acct.S
+syscall_src += arch-x86/syscalls/read.S
+syscall_src += arch-x86/syscalls/write.S
+syscall_src += arch-x86/syscalls/__pread64.S
+syscall_src += arch-x86/syscalls/__pwrite64.S
+syscall_src += arch-x86/syscalls/__open.S
+syscall_src += arch-x86/syscalls/__openat.S
+syscall_src += arch-x86/syscalls/close.S
+syscall_src += arch-x86/syscalls/lseek.S
+syscall_src += arch-x86/syscalls/__llseek.S
+syscall_src += arch-x86/syscalls/getpid.S
+syscall_src += arch-x86/syscalls/__mmap2.S
+syscall_src += arch-x86/syscalls/munmap.S
+syscall_src += arch-x86/syscalls/mremap.S
+syscall_src += arch-x86/syscalls/msync.S
+syscall_src += arch-x86/syscalls/mprotect.S
+syscall_src += arch-x86/syscalls/madvise.S
+syscall_src += arch-x86/syscalls/mlock.S
+syscall_src += arch-x86/syscalls/munlock.S
+syscall_src += arch-x86/syscalls/mincore.S
+syscall_src += arch-x86/syscalls/__ioctl.S
+syscall_src += arch-x86/syscalls/readv.S
+syscall_src += arch-x86/syscalls/writev.S
+syscall_src += arch-x86/syscalls/__fcntl.S
+syscall_src += arch-x86/syscalls/flock.S
+syscall_src += arch-x86/syscalls/fchmod.S
+syscall_src += arch-x86/syscalls/dup.S
+syscall_src += arch-x86/syscalls/pipe.S
+syscall_src += arch-x86/syscalls/dup2.S
+syscall_src += arch-x86/syscalls/select.S
+syscall_src += arch-x86/syscalls/ftruncate.S
+syscall_src += arch-x86/syscalls/getdents.S
+syscall_src += arch-x86/syscalls/fsync.S
+syscall_src += arch-x86/syscalls/fchown.S
+syscall_src += arch-x86/syscalls/sync.S
+syscall_src += arch-x86/syscalls/__fcntl64.S
+syscall_src += arch-x86/syscalls/fstatfs.S
+syscall_src += arch-x86/syscalls/sendfile.S
+syscall_src += arch-x86/syscalls/fstatat.S
+syscall_src += arch-x86/syscalls/mkdirat.S
+syscall_src += arch-x86/syscalls/fchownat.S
+syscall_src += arch-x86/syscalls/fchmodat.S
+syscall_src += arch-x86/syscalls/renameat.S
+syscall_src += arch-x86/syscalls/link.S
+syscall_src += arch-x86/syscalls/unlink.S
+syscall_src += arch-x86/syscalls/unlinkat.S
+syscall_src += arch-x86/syscalls/chdir.S
+syscall_src += arch-x86/syscalls/mknod.S
+syscall_src += arch-x86/syscalls/chmod.S
+syscall_src += arch-x86/syscalls/chown.S
+syscall_src += arch-x86/syscalls/lchown.S
+syscall_src += arch-x86/syscalls/mount.S
+syscall_src += arch-x86/syscalls/umount2.S
+syscall_src += arch-x86/syscalls/fstat.S
+syscall_src += arch-x86/syscalls/stat.S
+syscall_src += arch-x86/syscalls/lstat.S
+syscall_src += arch-x86/syscalls/mkdir.S
+syscall_src += arch-x86/syscalls/readlink.S
+syscall_src += arch-x86/syscalls/rmdir.S
+syscall_src += arch-x86/syscalls/rename.S
+syscall_src += arch-x86/syscalls/__getcwd.S
+syscall_src += arch-x86/syscalls/access.S
+syscall_src += arch-x86/syscalls/symlink.S
+syscall_src += arch-x86/syscalls/fchdir.S
+syscall_src += arch-x86/syscalls/truncate.S
+syscall_src += arch-x86/syscalls/__statfs64.S
+syscall_src += arch-x86/syscalls/pause.S
+syscall_src += arch-x86/syscalls/gettimeofday.S
+syscall_src += arch-x86/syscalls/settimeofday.S
+syscall_src += arch-x86/syscalls/times.S
+syscall_src += arch-x86/syscalls/nanosleep.S
+syscall_src += arch-x86/syscalls/clock_gettime.S
+syscall_src += arch-x86/syscalls/clock_settime.S
+syscall_src += arch-x86/syscalls/clock_getres.S
+syscall_src += arch-x86/syscalls/clock_nanosleep.S
+syscall_src += arch-x86/syscalls/getitimer.S
+syscall_src += arch-x86/syscalls/setitimer.S
+syscall_src += arch-x86/syscalls/__timer_create.S
+syscall_src += arch-x86/syscalls/__timer_settime.S
+syscall_src += arch-x86/syscalls/__timer_gettime.S
+syscall_src += arch-x86/syscalls/__timer_getoverrun.S
+syscall_src += arch-x86/syscalls/__timer_delete.S
+syscall_src += arch-x86/syscalls/utimes.S
+syscall_src += arch-x86/syscalls/sigaction.S
+syscall_src += arch-x86/syscalls/sigprocmask.S
+syscall_src += arch-x86/syscalls/__sigsuspend.S
+syscall_src += arch-x86/syscalls/__rt_sigaction.S
+syscall_src += arch-x86/syscalls/__rt_sigprocmask.S
+syscall_src += arch-x86/syscalls/__rt_sigtimedwait.S
+syscall_src += arch-x86/syscalls/sigpending.S
+syscall_src += arch-x86/syscalls/socket.S
+syscall_src += arch-x86/syscalls/bind.S
+syscall_src += arch-x86/syscalls/connect.S
+syscall_src += arch-x86/syscalls/listen.S
+syscall_src += arch-x86/syscalls/accept.S
+syscall_src += arch-x86/syscalls/getsockname.S
+syscall_src += arch-x86/syscalls/getpeername.S
+syscall_src += arch-x86/syscalls/socketpair.S
+syscall_src += arch-x86/syscalls/sendto.S
+syscall_src += arch-x86/syscalls/recvfrom.S
+syscall_src += arch-x86/syscalls/shutdown.S
+syscall_src += arch-x86/syscalls/setsockopt.S
+syscall_src += arch-x86/syscalls/getsockopt.S
+syscall_src += arch-x86/syscalls/sendmsg.S
+syscall_src += arch-x86/syscalls/recvmsg.S
+syscall_src += arch-x86/syscalls/sched_setscheduler.S
+syscall_src += arch-x86/syscalls/sched_getscheduler.S
+syscall_src += arch-x86/syscalls/sched_yield.S
+syscall_src += arch-x86/syscalls/sched_setparam.S
+syscall_src += arch-x86/syscalls/sched_getparam.S
+syscall_src += arch-x86/syscalls/sched_get_priority_max.S
+syscall_src += arch-x86/syscalls/sched_get_priority_min.S
+syscall_src += arch-x86/syscalls/sched_rr_get_interval.S
+syscall_src += arch-x86/syscalls/uname.S
+syscall_src += arch-x86/syscalls/__wait4.S
+syscall_src += arch-x86/syscalls/umask.S
+syscall_src += arch-x86/syscalls/__reboot.S
+syscall_src += arch-x86/syscalls/__syslog.S
+syscall_src += arch-x86/syscalls/init_module.S
+syscall_src += arch-x86/syscalls/delete_module.S
+syscall_src += arch-x86/syscalls/klogctl.S
+syscall_src += arch-x86/syscalls/futex.S
+syscall_src += arch-x86/syscalls/epoll_create.S
+syscall_src += arch-x86/syscalls/epoll_ctl.S
+syscall_src += arch-x86/syscalls/epoll_wait.S
+syscall_src += arch-x86/syscalls/inotify_init.S
+syscall_src += arch-x86/syscalls/inotify_add_watch.S
+syscall_src += arch-x86/syscalls/inotify_rm_watch.S
+syscall_src += arch-x86/syscalls/poll.S
diff --git a/libc/arch-x86/syscalls/fork.S b/libc/arch-x86/syscalls/__fork.S
index fbc1af3..4b5d1c6 100644
--- a/libc/arch-x86/syscalls/fork.S
+++ b/libc/arch-x86/syscalls/__fork.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type fork, @function
- .globl fork
+ .type __fork, @function
+ .globl __fork
.align 4
-fork:
+__fork:
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_fork, %eax
diff --git a/libc/arch-x86/syscalls/__pread64.S b/libc/arch-x86/syscalls/__pread64.S
new file mode 100644
index 0000000..3114673
--- /dev/null
+++ b/libc/arch-x86/syscalls/__pread64.S
@@ -0,0 +1,35 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type __pread64, @function
+ .globl __pread64
+ .align 4
+
+__pread64:
+ pushl %ebx
+ pushl %ecx
+ pushl %edx
+ pushl %esi
+ pushl %edi
+ mov 24(%esp), %ebx
+ mov 28(%esp), %ecx
+ mov 32(%esp), %edx
+ mov 36(%esp), %esi
+ mov 40(%esp), %edi
+ movl $__NR_pread64, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %edi
+ popl %esi
+ popl %edx
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/__pwrite64.S b/libc/arch-x86/syscalls/__pwrite64.S
new file mode 100644
index 0000000..28f6536
--- /dev/null
+++ b/libc/arch-x86/syscalls/__pwrite64.S
@@ -0,0 +1,35 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type __pwrite64, @function
+ .globl __pwrite64
+ .align 4
+
+__pwrite64:
+ pushl %ebx
+ pushl %ecx
+ pushl %edx
+ pushl %esi
+ pushl %edi
+ mov 24(%esp), %ebx
+ mov 28(%esp), %ecx
+ mov 32(%esp), %edx
+ mov 36(%esp), %esi
+ mov 40(%esp), %edi
+ movl $__NR_pwrite64, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %edi
+ popl %esi
+ popl %edx
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/timer_create.S b/libc/arch-x86/syscalls/__timer_create.S
index a215210..66b0cea 100644
--- a/libc/arch-x86/syscalls/timer_create.S
+++ b/libc/arch-x86/syscalls/__timer_create.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_create, @function
- .globl timer_create
+ .type __timer_create, @function
+ .globl __timer_create
.align 4
-timer_create:
+__timer_create:
pushl %ebx
pushl %ecx
pushl %edx
diff --git a/libc/arch-x86/syscalls/timer_delete.S b/libc/arch-x86/syscalls/__timer_delete.S
index f939db6..4344d08 100644
--- a/libc/arch-x86/syscalls/timer_delete.S
+++ b/libc/arch-x86/syscalls/__timer_delete.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_delete, @function
- .globl timer_delete
+ .type __timer_delete, @function
+ .globl __timer_delete
.align 4
-timer_delete:
+__timer_delete:
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_timer_delete, %eax
diff --git a/libc/arch-x86/syscalls/timer_getoverrun.S b/libc/arch-x86/syscalls/__timer_getoverrun.S
index 0a1fa1d..4371415 100644
--- a/libc/arch-x86/syscalls/timer_getoverrun.S
+++ b/libc/arch-x86/syscalls/__timer_getoverrun.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_getoverrun, @function
- .globl timer_getoverrun
+ .type __timer_getoverrun, @function
+ .globl __timer_getoverrun
.align 4
-timer_getoverrun:
+__timer_getoverrun:
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_timer_getoverrun, %eax
diff --git a/libc/arch-x86/syscalls/timer_gettime.S b/libc/arch-x86/syscalls/__timer_gettime.S
index 07258be..3923b0a 100644
--- a/libc/arch-x86/syscalls/timer_gettime.S
+++ b/libc/arch-x86/syscalls/__timer_gettime.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_gettime, @function
- .globl timer_gettime
+ .type __timer_gettime, @function
+ .globl __timer_gettime
.align 4
-timer_gettime:
+__timer_gettime:
pushl %ebx
pushl %ecx
mov 12(%esp), %ebx
diff --git a/libc/arch-x86/syscalls/timer_settime.S b/libc/arch-x86/syscalls/__timer_settime.S
index 6c3784a..cabb7df 100644
--- a/libc/arch-x86/syscalls/timer_settime.S
+++ b/libc/arch-x86/syscalls/__timer_settime.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_settime, @function
- .globl timer_settime
+ .type __timer_settime, @function
+ .globl __timer_settime
.align 4
-timer_settime:
+__timer_settime:
pushl %ebx
pushl %ecx
pushl %edx
diff --git a/libc/arch-x86/syscalls/accept.S b/libc/arch-x86/syscalls/accept.S
new file mode 100644
index 0000000..ccd56e7
--- /dev/null
+++ b/libc/arch-x86/syscalls/accept.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type accept, @function
+ .globl accept
+ .align 4
+
+accept:
+ pushl %ebx
+ pushl %ecx
+ mov $5, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/bind.S b/libc/arch-x86/syscalls/bind.S
new file mode 100644
index 0000000..2172cfb
--- /dev/null
+++ b/libc/arch-x86/syscalls/bind.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type bind, @function
+ .globl bind
+ .align 4
+
+bind:
+ pushl %ebx
+ pushl %ecx
+ mov $2, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/connect.S b/libc/arch-x86/syscalls/connect.S
new file mode 100644
index 0000000..8b8ce4e
--- /dev/null
+++ b/libc/arch-x86/syscalls/connect.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type connect, @function
+ .globl connect
+ .align 4
+
+connect:
+ pushl %ebx
+ pushl %ecx
+ mov $3, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/getitimer.S b/libc/arch-x86/syscalls/getitimer.S
new file mode 100644
index 0000000..f170ebf
--- /dev/null
+++ b/libc/arch-x86/syscalls/getitimer.S
@@ -0,0 +1,26 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type getitimer, @function
+ .globl getitimer
+ .align 4
+
+getitimer:
+ pushl %ebx
+ pushl %ecx
+ mov 12(%esp), %ebx
+ mov 16(%esp), %ecx
+ movl $__NR_getitimer, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/getpeername.S b/libc/arch-x86/syscalls/getpeername.S
new file mode 100644
index 0000000..b6f8eb8
--- /dev/null
+++ b/libc/arch-x86/syscalls/getpeername.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type getpeername, @function
+ .globl getpeername
+ .align 4
+
+getpeername:
+ pushl %ebx
+ pushl %ecx
+ mov $7, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/getsockname.S b/libc/arch-x86/syscalls/getsockname.S
new file mode 100644
index 0000000..884acd9
--- /dev/null
+++ b/libc/arch-x86/syscalls/getsockname.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type getsockname, @function
+ .globl getsockname
+ .align 4
+
+getsockname:
+ pushl %ebx
+ pushl %ecx
+ mov $6, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/getsockopt.S b/libc/arch-x86/syscalls/getsockopt.S
new file mode 100644
index 0000000..a606532
--- /dev/null
+++ b/libc/arch-x86/syscalls/getsockopt.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type getsockopt, @function
+ .globl getsockopt
+ .align 4
+
+getsockopt:
+ pushl %ebx
+ pushl %ecx
+ mov $15, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/listen.S b/libc/arch-x86/syscalls/listen.S
new file mode 100644
index 0000000..de310cf
--- /dev/null
+++ b/libc/arch-x86/syscalls/listen.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type listen, @function
+ .globl listen
+ .align 4
+
+listen:
+ pushl %ebx
+ pushl %ecx
+ mov $4, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/recvfrom.S b/libc/arch-x86/syscalls/recvfrom.S
new file mode 100644
index 0000000..3a38518
--- /dev/null
+++ b/libc/arch-x86/syscalls/recvfrom.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type recvfrom, @function
+ .globl recvfrom
+ .align 4
+
+recvfrom:
+ pushl %ebx
+ pushl %ecx
+ mov $12, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/recvmsg.S b/libc/arch-x86/syscalls/recvmsg.S
new file mode 100644
index 0000000..aee69d6
--- /dev/null
+++ b/libc/arch-x86/syscalls/recvmsg.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type recvmsg, @function
+ .globl recvmsg
+ .align 4
+
+recvmsg:
+ pushl %ebx
+ pushl %ecx
+ mov $17, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/sendmsg.S b/libc/arch-x86/syscalls/sendmsg.S
new file mode 100644
index 0000000..5f26623
--- /dev/null
+++ b/libc/arch-x86/syscalls/sendmsg.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type sendmsg, @function
+ .globl sendmsg
+ .align 4
+
+sendmsg:
+ pushl %ebx
+ pushl %ecx
+ mov $16, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/sendto.S b/libc/arch-x86/syscalls/sendto.S
new file mode 100644
index 0000000..d79a2ba
--- /dev/null
+++ b/libc/arch-x86/syscalls/sendto.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type sendto, @function
+ .globl sendto
+ .align 4
+
+sendto:
+ pushl %ebx
+ pushl %ecx
+ mov $11, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/setsockopt.S b/libc/arch-x86/syscalls/setsockopt.S
new file mode 100644
index 0000000..d1c986a
--- /dev/null
+++ b/libc/arch-x86/syscalls/setsockopt.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type setsockopt, @function
+ .globl setsockopt
+ .align 4
+
+setsockopt:
+ pushl %ebx
+ pushl %ecx
+ mov $14, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/shutdown.S b/libc/arch-x86/syscalls/shutdown.S
new file mode 100644
index 0000000..45f0664
--- /dev/null
+++ b/libc/arch-x86/syscalls/shutdown.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type shutdown, @function
+ .globl shutdown
+ .align 4
+
+shutdown:
+ pushl %ebx
+ pushl %ecx
+ mov $13, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/socket.S b/libc/arch-x86/syscalls/socket.S
new file mode 100644
index 0000000..89a8358
--- /dev/null
+++ b/libc/arch-x86/syscalls/socket.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type socket, @function
+ .globl socket
+ .align 4
+
+socket:
+ pushl %ebx
+ pushl %ecx
+ mov $1, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/socketpair.S b/libc/arch-x86/syscalls/socketpair.S
new file mode 100644
index 0000000..0222989
--- /dev/null
+++ b/libc/arch-x86/syscalls/socketpair.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type socketpair, @function
+ .globl socketpair
+ .align 4
+
+socketpair:
+ pushl %ebx
+ pushl %ecx
+ mov $8, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/vfork.S b/libc/arch-x86/syscalls/vfork.S
deleted file mode 100644
index 55cb9f0..0000000
--- a/libc/arch-x86/syscalls/vfork.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
-
- .text
- .type vfork, @function
- .globl vfork
- .align 4
-
-vfork:
- pushl %ebx
- mov 8(%esp), %ebx
- movl $__NR_vfork, %eax
- int $0x80
- cmpl $-129, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- popl %ebx
- ret