From bdff26df2749d8d66e5d4eb5a2ecf4a9ff50fad2 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 11 Feb 2013 17:08:16 -0800 Subject: [PATCH] Use ENTRY/END in custom x86 assembler too. Change-Id: Ic2e482e5daff29c65d3b2ab0b2111c996bbc6226 --- libc/arch-x86/bionic/__get_sp.S | 13 +++--- .../bionic/_exit_with_stack_teardown.S | 14 ++----- libc/arch-x86/bionic/clone.S | 16 +++----- libc/arch-x86/bionic/futex_x86.S | 41 ++++++------------- libc/arch-x86/bionic/syscall.S | 9 ++-- libc/arch-x86/bionic/vfork.S | 9 ++-- 6 files changed, 34 insertions(+), 68 deletions(-) diff --git a/libc/arch-x86/bionic/__get_sp.S b/libc/arch-x86/bionic/__get_sp.S index aeaaa664e..0739d7983 100644 --- a/libc/arch-x86/bionic/__get_sp.S +++ b/libc/arch-x86/bionic/__get_sp.S @@ -25,11 +25,10 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - .text - .type __get_sp, @function - .global __get_sp - .align 4 -__get_sp: - mov %esp, %eax - ret +#include + +ENTRY(__get_sp) + mov %esp, %eax + ret +END(__get_sp) diff --git a/libc/arch-x86/bionic/_exit_with_stack_teardown.S b/libc/arch-x86/bionic/_exit_with_stack_teardown.S index 83a504dab..e2bb6ad7d 100644 --- a/libc/arch-x86/bionic/_exit_with_stack_teardown.S +++ b/libc/arch-x86/bionic/_exit_with_stack_teardown.S @@ -1,15 +1,8 @@ +#include #include -.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: +// void _exit_with_stack_teardown(void *stackBase, int stackSize, int *retCode) +ENTRY(_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 @@ -32,3 +25,4 @@ _exit_with_stack_teardown: * that presently, 'hlt' will cause the program to segfault.. but this * should never happen :) */ hlt +END(_exit_with_stack_teardown) diff --git a/libc/arch-x86/bionic/clone.S b/libc/arch-x86/bionic/clone.S index 9266f8453..6f84724c3 100644 --- a/libc/arch-x86/bionic/clone.S +++ b/libc/arch-x86/bionic/clone.S @@ -1,12 +1,8 @@ +#include #include -.text - // int __pthread_clone(int (*fn)(void*), void* tls, int flags, void* arg); -.globl __pthread_clone -.type __pthread_clone, @function -.align 4 -__pthread_clone: +ENTRY(__pthread_clone) pushl %ebx pushl %ecx movl 16(%esp), %ecx @@ -49,6 +45,7 @@ __pthread_clone: popl %ecx popl %ebx ret +END(__pthread_clone) /* @@ -60,11 +57,7 @@ __pthread_clone: * int (*fn)(void *), * void *arg); */ -.text -.globl __bionic_clone -.type __bionic_clone, @function -.align 4 -__bionic_clone: +ENTRY(__bionic_clone) pushl %ebx pushl %esi pushl %edi @@ -107,3 +100,4 @@ __bionic_clone: popl %esi popl %ebx ret +END(__bionic_clone) diff --git a/libc/arch-x86/bionic/futex_x86.S b/libc/arch-x86/bionic/futex_x86.S index e98a391ee..096f72c7f 100644 --- a/libc/arch-x86/bionic/futex_x86.S +++ b/libc/arch-x86/bionic/futex_x86.S @@ -1,17 +1,11 @@ +#include #include #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: +// int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout) +ENTRY(__futex_wait) pushl %ebx pushl %esi mov 12(%esp), %ebx /* ftx */ @@ -23,15 +17,11 @@ __futex_wait: popl %esi popl %ebx ret +END(__futex_wait) -/* int __futex_wake(volatile void *ftx, int count) */ - -.text -.globl __futex_wake -.type __futex_wake, @function -.align 4 -__futex_wake: +// int __futex_wake(volatile void *ftx, int count) +ENTRY(__futex_wake) pushl %ebx mov 8(%esp), %ebx /* ftx */ movl $FUTEX_WAKE, %ecx @@ -40,13 +30,10 @@ __futex_wake: int $0x80 popl %ebx ret +END(__futex_wake) -/* int __futex_syscall3(volatile void *ftx, int op, int count) */ -.text -.globl __futex_syscall3 -.type __futex_syscall3, @function -.align 4 -__futex_syscall3: +// int __futex_syscall3(volatile void *ftx, int op, int count) +ENTRY(__futex_syscall3) pushl %ebx movl 8(%esp), %ebx /* ftx */ movl 12(%esp), %ecx /* op */ @@ -55,13 +42,10 @@ __futex_syscall3: int $0x80 popl %ebx ret +END(__futex_syscall3) -/* int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout) */ -.text -.globl __futex_syscall4 -.type __futex_syscall4, @function -.align 4 -__futex_syscall4: +// int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout) +ENTRY(__futex_syscall4) pushl %ebx pushl %esi movl 12(%esp), %ebx /* ftx */ @@ -73,3 +57,4 @@ __futex_syscall4: popl %esi popl %ebx ret +END(__futex_syscall4) diff --git a/libc/arch-x86/bionic/syscall.S b/libc/arch-x86/bionic/syscall.S index 49d6f8de8..ef816b60d 100644 --- a/libc/arch-x86/bionic/syscall.S +++ b/libc/arch-x86/bionic/syscall.S @@ -10,14 +10,10 @@ * %ebp: arg5 - callee save */ +#include #include - .text - .type syscall, @function - .globl syscall - .align 4 - -syscall: +ENTRY(syscall) # Push the callee save registers. push %ebx push %esi @@ -53,3 +49,4 @@ syscall: pop %esi pop %ebx ret +END(syscall) diff --git a/libc/arch-x86/bionic/vfork.S b/libc/arch-x86/bionic/vfork.S index 53910aba3..235be0c0e 100644 --- a/libc/arch-x86/bionic/vfork.S +++ b/libc/arch-x86/bionic/vfork.S @@ -1,3 +1,4 @@ +#include #include #ifndef __NR_vfork @@ -5,17 +6,12 @@ #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: +ENTRY(vfork) /* grab the return address */ popl %ecx movl $__NR_vfork, %eax @@ -28,3 +24,4 @@ vfork: orl $-1, %eax 1: jmp *%ecx +END(vfork)