From 6b53c2349a5a3fc70a475de6a66131b615e88e48 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 24 Oct 2013 22:36:58 -0700 Subject: [PATCH] Fix the exit syscall stub's name. I've left the exit_group syscall as _exit because otherwise we'd have to convince the compiler that our _exit (which just calls __exit_group) is actually "noreturn", and it seems like that would be less clean than just cutting out the middleman. We'll just have to trust ourselves not to add anything to SYSCALLS.TXT that ought to be private but that only has a single leading underscore. Hopefully we can manage that. Change-Id: Iac47faea9f516186e1774381846c54cafabc4354 --- libc/SYSCALLS.TXT | 13 ++++++------- libc/arch-arm/syscalls.mk | 2 +- libc/arch-arm/syscalls/{_exit_thread.S => __exit.S} | 4 ++-- libc/arch-mips/syscalls.mk | 2 +- .../arch-mips/syscalls/{_exit_thread.S => __exit.S} | 8 ++++---- libc/arch-x86/syscalls.mk | 2 +- libc/arch-x86/syscalls/{_exit_thread.S => __exit.S} | 4 ++-- libc/arch-x86_64/syscalls.mk | 2 +- .../syscalls/{_exit_thread.S => __exit.S} | 5 +++-- libc/bionic/bionic_clone.c | 4 ++-- libc/bionic/pthread.c | 4 ++-- libc/tools/gensyscalls.py | 1 - 12 files changed, 25 insertions(+), 26 deletions(-) rename libc/arch-arm/syscalls/{_exit_thread.S => __exit.S} (88%) rename libc/arch-mips/syscalls/{_exit_thread.S => __exit.S} (77%) rename libc/arch-x86/syscalls/{_exit_thread.S => __exit.S} (91%) rename libc/arch-x86_64/syscalls/{_exit_thread.S => __exit.S} (85%) diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index 8dc2b8af3..ca1784f17 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -24,13 +24,6 @@ # # This file is processed by a python script named gensyscalls.py. -# process management -void _exit:exit_group(int) all -void _exit_thread:exit(int) all - -pid_t wait4(pid_t, int*, int, struct rusage*) all -int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all - int execve(const char*, char* const*, char* const*) all uid_t getuid:getuid32() arm,x86 @@ -289,6 +282,9 @@ int __epoll_pwait:epoll_pwait(int, struct epoll_event*, int, int, const sigset_t int eventfd:eventfd2(unsigned int, int) all +void _exit:exit_group(int) all +void __exit:exit(int) all + int futex(void*, int, int, void*, void*, int) all int inotify_init1(int) all @@ -298,6 +294,9 @@ int inotify_rm_watch(int, unsigned int) all int __pselect6:pselect6(int, fd_set*, fd_set*, fd_set*, timespec*, void*) all int __ppoll:ppoll(pollfd*, unsigned int, timespec*, const sigset_t*, size_t) all +pid_t wait4(pid_t, int*, int, struct rusage*) all +int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all + # ARM-specific int __set_tls:__ARM_NR_set_tls(void*) arm int cacheflush:__ARM_NR_cacheflush(long start, long end, long flags) arm diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk index e8b67595b..9d24a1d84 100644 --- a/libc/arch-arm/syscalls.mk +++ b/libc/arch-arm/syscalls.mk @@ -3,6 +3,7 @@ syscall_src := syscall_src += arch-arm/syscalls/__brk.S syscall_src += arch-arm/syscalls/__clone.S syscall_src += arch-arm/syscalls/__epoll_pwait.S +syscall_src += arch-arm/syscalls/__exit.S syscall_src += arch-arm/syscalls/__fcntl.S syscall_src += arch-arm/syscalls/__fcntl64.S syscall_src += arch-arm/syscalls/__fstatfs64.S @@ -34,7 +35,6 @@ syscall_src += arch-arm/syscalls/__timer_gettime.S syscall_src += arch-arm/syscalls/__timer_settime.S syscall_src += arch-arm/syscalls/__waitid.S syscall_src += arch-arm/syscalls/_exit.S -syscall_src += arch-arm/syscalls/_exit_thread.S syscall_src += arch-arm/syscalls/accept.S syscall_src += arch-arm/syscalls/acct.S syscall_src += arch-arm/syscalls/bind.S diff --git a/libc/arch-arm/syscalls/_exit_thread.S b/libc/arch-arm/syscalls/__exit.S similarity index 88% rename from libc/arch-arm/syscalls/_exit_thread.S rename to libc/arch-arm/syscalls/__exit.S index 29f335dc9..8cdd0fa3f 100644 --- a/libc/arch-arm/syscalls/_exit_thread.S +++ b/libc/arch-arm/syscalls/__exit.S @@ -4,7 +4,7 @@ #include #include -ENTRY(_exit_thread) +ENTRY(__exit) mov ip, r7 ldr r7, =__NR_exit swi #0 @@ -13,4 +13,4 @@ ENTRY(_exit_thread) bxls lr neg r0, r0 b __set_errno -END(_exit_thread) +END(__exit) diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk index e1c106c62..688287771 100644 --- a/libc/arch-mips/syscalls.mk +++ b/libc/arch-mips/syscalls.mk @@ -3,6 +3,7 @@ syscall_src := syscall_src += arch-mips/syscalls/__brk.S syscall_src += arch-mips/syscalls/__clone.S syscall_src += arch-mips/syscalls/__epoll_pwait.S +syscall_src += arch-mips/syscalls/__exit.S syscall_src += arch-mips/syscalls/__fcntl.S syscall_src += arch-mips/syscalls/__fcntl64.S syscall_src += arch-mips/syscalls/__fstatfs64.S @@ -34,7 +35,6 @@ syscall_src += arch-mips/syscalls/__timer_gettime.S syscall_src += arch-mips/syscalls/__timer_settime.S syscall_src += arch-mips/syscalls/__waitid.S syscall_src += arch-mips/syscalls/_exit.S -syscall_src += arch-mips/syscalls/_exit_thread.S syscall_src += arch-mips/syscalls/_flush_cache.S syscall_src += arch-mips/syscalls/accept.S syscall_src += arch-mips/syscalls/acct.S diff --git a/libc/arch-mips/syscalls/_exit_thread.S b/libc/arch-mips/syscalls/__exit.S similarity index 77% rename from libc/arch-mips/syscalls/_exit_thread.S rename to libc/arch-mips/syscalls/__exit.S index 1ed8ffc3e..529e49c0b 100644 --- a/libc/arch-mips/syscalls/_exit_thread.S +++ b/libc/arch-mips/syscalls/__exit.S @@ -2,11 +2,11 @@ #include .text - .globl _exit_thread + .globl __exit .align 4 - .ent _exit_thread + .ent __exit -_exit_thread: +__exit: .set noreorder .cpload $t9 li $v0, __NR_exit @@ -20,4 +20,4 @@ _exit_thread: j $t9 nop .set reorder - .end _exit_thread + .end __exit diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk index 3b8586b22..ade6d5591 100644 --- a/libc/arch-x86/syscalls.mk +++ b/libc/arch-x86/syscalls.mk @@ -3,6 +3,7 @@ syscall_src := syscall_src += arch-x86/syscalls/__brk.S syscall_src += arch-x86/syscalls/__clone.S syscall_src += arch-x86/syscalls/__epoll_pwait.S +syscall_src += arch-x86/syscalls/__exit.S syscall_src += arch-x86/syscalls/__fcntl.S syscall_src += arch-x86/syscalls/__fcntl64.S syscall_src += arch-x86/syscalls/__fstatfs64.S @@ -34,7 +35,6 @@ syscall_src += arch-x86/syscalls/__timer_gettime.S syscall_src += arch-x86/syscalls/__timer_settime.S syscall_src += arch-x86/syscalls/__waitid.S syscall_src += arch-x86/syscalls/_exit.S -syscall_src += arch-x86/syscalls/_exit_thread.S syscall_src += arch-x86/syscalls/accept.S syscall_src += arch-x86/syscalls/acct.S syscall_src += arch-x86/syscalls/bind.S diff --git a/libc/arch-x86/syscalls/_exit_thread.S b/libc/arch-x86/syscalls/__exit.S similarity index 91% rename from libc/arch-x86/syscalls/_exit_thread.S rename to libc/arch-x86/syscalls/__exit.S index 1dbac6a19..e906ea2d6 100644 --- a/libc/arch-x86/syscalls/_exit_thread.S +++ b/libc/arch-x86/syscalls/__exit.S @@ -4,7 +4,7 @@ #include #include -ENTRY(_exit_thread) +ENTRY(__exit) pushl %ebx mov 8(%esp), %ebx movl $__NR_exit, %eax @@ -19,4 +19,4 @@ ENTRY(_exit_thread) 1: popl %ebx ret -END(_exit_thread) +END(__exit) diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk index 1ec3e0981..c874b6133 100644 --- a/libc/arch-x86_64/syscalls.mk +++ b/libc/arch-x86_64/syscalls.mk @@ -4,6 +4,7 @@ syscall_src += arch-x86_64/syscalls/__arch_prctl.S syscall_src += arch-x86_64/syscalls/__brk.S syscall_src += arch-x86_64/syscalls/__clone.S syscall_src += arch-x86_64/syscalls/__epoll_pwait.S +syscall_src += arch-x86_64/syscalls/__exit.S syscall_src += arch-x86_64/syscalls/__getcpu.S syscall_src += arch-x86_64/syscalls/__getcwd.S syscall_src += arch-x86_64/syscalls/__getpriority.S @@ -27,7 +28,6 @@ syscall_src += arch-x86_64/syscalls/__timer_gettime.S syscall_src += arch-x86_64/syscalls/__timer_settime.S syscall_src += arch-x86_64/syscalls/__waitid.S syscall_src += arch-x86_64/syscalls/_exit.S -syscall_src += arch-x86_64/syscalls/_exit_thread.S syscall_src += arch-x86_64/syscalls/accept.S syscall_src += arch-x86_64/syscalls/acct.S syscall_src += arch-x86_64/syscalls/bind.S diff --git a/libc/arch-x86_64/syscalls/_exit_thread.S b/libc/arch-x86_64/syscalls/__exit.S similarity index 85% rename from libc/arch-x86_64/syscalls/_exit_thread.S rename to libc/arch-x86_64/syscalls/__exit.S index 821308fcf..7e3424576 100644 --- a/libc/arch-x86_64/syscalls/_exit_thread.S +++ b/libc/arch-x86_64/syscalls/__exit.S @@ -4,7 +4,7 @@ #include #include -ENTRY(_exit_thread) +ENTRY(__exit) movl $__NR_exit, %eax syscall cmpq $-MAX_ERRNO, %rax @@ -15,4 +15,5 @@ ENTRY(_exit_thread) orq $-1, %rax 1: ret -END(_exit_thread) +END(__exit) +.hidden _C_LABEL(__exit) diff --git a/libc/bionic/bionic_clone.c b/libc/bionic/bionic_clone.c index b603a3a97..8a17e135e 100644 --- a/libc/bionic/bionic_clone.c +++ b/libc/bionic/bionic_clone.c @@ -39,14 +39,14 @@ extern int __bionic_clone(unsigned long clone_flags, int (*fn)(void *), void *arg); -extern void _exit_thread(int status); +extern void __exit(int status); /* this function is called from the __bionic_clone * assembly fragment to call the thread function * then exit. */ extern void __bionic_clone_entry(int (*fn)(void*), void* arg) { int status = (*fn)(arg); - _exit_thread(status); + __exit(status); } int clone(int (*fn)(void*), void* child_stack, int flags, void* arg, ...) { diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c index 4a4676aec..d2f9254c2 100644 --- a/libc/bionic/pthread.c +++ b/libc/bionic/pthread.c @@ -46,7 +46,7 @@ extern void pthread_debug_mutex_lock_check(pthread_mutex_t *mutex); extern void pthread_debug_mutex_unlock_check(pthread_mutex_t *mutex); extern void _exit_with_stack_teardown(void * stackBase, size_t stackSize, int status); -extern void _exit_thread(int status); +extern void __exit(int status); int __futex_wake_ex(volatile void *ftx, int pshared, int val) { @@ -148,7 +148,7 @@ void pthread_exit(void * retval) if (user_stack) { // Cleaning up this thread's stack is the creator's responsibility, not ours. - _exit_thread(0); + __exit(0); } else { // We need to munmap the stack we're running on before calling exit. // That's not something we can do in C. diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py index 578605d32..5595cd725 100755 --- a/libc/tools/gensyscalls.py +++ b/libc/tools/gensyscalls.py @@ -240,7 +240,6 @@ def add_footer(pointer_length, stub, syscall): stub += function_alias % { "func" : syscall["func"], "alias" : alias } # Use hidden visibility for any functions beginning with underscores. - # TODO: clean up single-underscore names too. if pointer_length == 64 and syscall["func"].startswith("__"): stub += '.hidden _C_LABEL(' + syscall["func"] + ')\n'