From 851e68a2402fa414544e66650e09dfdaac813e51 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 19 Feb 2014 16:53:20 -0800 Subject: [PATCH] Unify our assembler macros. Our files were modified from upstream, to the extent that no architecture was actually using the upstream ENTRY or END macros, assuming that architecture even had such a macro upstream. This patch moves everyone to the same macros, with just a few tweaks remaining in the files, which no one should now use directly. I've removed most of the unused cruft from the files, though there's still rather a lot in the mips/mips64 ones. Bug: 12229603 Change-Id: I2fff287dc571ac1087abe9070362fb9420d85d6d --- libc/arch-arm/bionic/__get_sp.S | 2 +- libc/arch-arm/bionic/_setjmp.S | 2 +- libc/arch-arm/bionic/abort_arm.S | 2 +- libc/arch-arm/bionic/memcmp.S | 2 +- libc/arch-arm/bionic/memcmp16.S | 2 +- libc/arch-arm/bionic/memcpy.S | 2 +- libc/arch-arm/bionic/memcpy.a9.S | 2 +- libc/arch-arm/bionic/setjmp.S | 4 +- libc/arch-arm/bionic/sigsetjmp.S | 2 +- libc/arch-arm/bionic/strcmp.S | 2 +- libc/arch-arm/cortex-a15/bionic/__strcat_chk.S | 4 +- libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S | 4 +- libc/arch-arm/cortex-a15/bionic/memcpy.S | 4 +- libc/arch-arm/cortex-a15/bionic/memset.S | 4 +- libc/arch-arm/cortex-a15/bionic/strcat.S | 2 +- libc/arch-arm/cortex-a15/bionic/strcmp.S | 2 +- libc/arch-arm/cortex-a15/bionic/strcpy.S | 2 +- libc/arch-arm/cortex-a15/bionic/strlen.S | 2 +- libc/arch-arm/cortex-a9/bionic/__strcat_chk.S | 4 +- libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S | 4 +- libc/arch-arm/cortex-a9/bionic/memcpy.S | 4 +- libc/arch-arm/cortex-a9/bionic/memset.S | 5 +- libc/arch-arm/cortex-a9/bionic/strcat.S | 2 +- libc/arch-arm/cortex-a9/bionic/strcmp.S | 2 +- libc/arch-arm/cortex-a9/bionic/strcpy.S | 2 +- libc/arch-arm/cortex-a9/bionic/strlen.S | 2 +- libc/arch-arm/generic/bionic/memcpy.S | 4 +- libc/arch-arm/generic/bionic/memset.S | 4 +- libc/arch-arm/generic/bionic/strcmp.S | 2 +- libc/arch-arm/generic/bionic/strcpy.S | 2 +- libc/arch-arm/include/machine/asm.h | 101 ++------------ libc/arch-arm/krait/bionic/__strcat_chk.S | 4 +- libc/arch-arm/krait/bionic/__strcpy_chk.S | 4 +- libc/arch-arm/krait/bionic/memcpy.S | 4 +- libc/arch-arm/krait/bionic/memset.S | 4 +- libc/arch-arm/krait/bionic/strcmp.S | 2 +- libc/arch-arm64/bionic/__get_sp.S | 2 +- libc/arch-arm64/bionic/__rt_sigreturn.S | 3 +- libc/arch-arm64/bionic/_setjmp.S | 2 +- libc/arch-arm64/bionic/setjmp.S | 2 +- libc/arch-arm64/bionic/sigsetjmp.S | 2 +- libc/arch-arm64/include/machine/asm.h | 84 +----------- libc/arch-mips/bionic/__bionic_clone.S | 46 +++---- libc/arch-mips/bionic/__get_sp.S | 16 +-- libc/arch-mips/bionic/_exit_with_stack_teardown.S | 19 +-- libc/arch-mips/bionic/_setjmp.S | 9 +- libc/arch-mips/bionic/bzero.S | 26 ++-- libc/arch-mips/bionic/futex_mips.S | 32 ++--- libc/arch-mips/bionic/memcmp16.S | 41 +++--- libc/arch-mips/bionic/setjmp.S | 12 +- libc/arch-mips/bionic/sigsetjmp.S | 2 +- libc/arch-mips/bionic/syscall.S | 44 +++--- libc/arch-mips/bionic/vfork.S | 40 +++--- libc/arch-mips/include/machine/asm.h | 121 ++--------------- libc/arch-mips/include/machine/signal.h | 2 - libc/arch-mips/string/memcpy.S | 6 +- libc/arch-mips/string/memset.S | 9 +- libc/arch-mips64/bionic/__bionic_clone.S | 6 +- libc/arch-mips64/bionic/__get_sp.S | 15 +-- .../arch-mips64/bionic/_exit_with_stack_teardown.S | 27 ++-- libc/arch-mips64/bionic/_setjmp.S | 9 +- libc/arch-mips64/bionic/bzero.S | 4 +- libc/arch-mips64/bionic/memcmp16.S | 2 +- libc/arch-mips64/bionic/setjmp.S | 12 +- libc/arch-mips64/bionic/sigsetjmp.S | 2 +- libc/arch-mips64/bionic/syscall.S | 3 +- libc/arch-mips64/bionic/vfork.S | 5 +- libc/arch-mips64/include/machine/asm.h | 119 ++--------------- libc/arch-mips64/include/machine/signal.h | 2 - libc/arch-mips64/string/memcpy.S | 6 +- libc/arch-mips64/string/memset.S | 9 +- libc/arch-x86/bionic/__bionic_clone.S | 3 +- libc/arch-x86/bionic/__get_sp.S | 2 +- libc/arch-x86/bionic/_setjmp.S | 2 +- libc/arch-x86/bionic/setjmp.S | 2 +- libc/arch-x86/bionic/sigsetjmp.S | 2 +- libc/arch-x86/include/machine/asm.h | 147 --------------------- libc/arch-x86/string/bcopy.S | 2 +- libc/arch-x86/string/memcmp.S | 2 +- libc/arch-x86/string/strcat.S | 2 +- libc/arch-x86/string/strcmp.S | 2 +- libc/arch-x86/string/strncmp.S | 2 +- libc/arch-x86/string/swab.S | 2 +- libc/arch-x86_64/bionic/__bionic_clone.S | 3 +- libc/arch-x86_64/bionic/__get_sp.S | 2 +- libc/arch-x86_64/bionic/__rt_sigreturn.S | 6 +- libc/arch-x86_64/bionic/_setjmp.S | 3 +- libc/arch-x86_64/bionic/setjmp.S | 3 +- libc/arch-x86_64/bionic/sigsetjmp.S | 2 +- libc/arch-x86_64/include/machine/asm.h | 89 ------------- libc/private/bionic_asm.h | 34 +++-- linker/arch/arm64/begin.S | 2 +- linker/arch/mips64/begin.S | 2 +- linker/arch/x86_64/begin.S | 2 +- 94 files changed, 298 insertions(+), 963 deletions(-) diff --git a/libc/arch-arm/bionic/__get_sp.S b/libc/arch-arm/bionic/__get_sp.S index 2a7e7b771..aabec6d8c 100644 --- a/libc/arch-arm/bionic/__get_sp.S +++ b/libc/arch-arm/bionic/__get_sp.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include ENTRY(__get_sp) mov r0, sp diff --git a/libc/arch-arm/bionic/_setjmp.S b/libc/arch-arm/bionic/_setjmp.S index 239947e0b..64a0a31c9 100644 --- a/libc/arch-arm/bionic/_setjmp.S +++ b/libc/arch-arm/bionic/_setjmp.S @@ -34,7 +34,7 @@ * SUCH DAMAGE. */ -#include +#include #include #include diff --git a/libc/arch-arm/bionic/abort_arm.S b/libc/arch-arm/bionic/abort_arm.S index 1d01ed274..6b181efb7 100644 --- a/libc/arch-arm/bionic/abort_arm.S +++ b/libc/arch-arm/bionic/abort_arm.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include /* * Coding the abort function in assembly so that registers are guaranteed to diff --git a/libc/arch-arm/bionic/memcmp.S b/libc/arch-arm/bionic/memcmp.S index 0dc3af0ca..70a2a58ce 100644 --- a/libc/arch-arm/bionic/memcmp.S +++ b/libc/arch-arm/bionic/memcmp.S @@ -27,7 +27,7 @@ */ #include -#include +#include #ifdef HAVE_32_BYTE_CACHE_LINE diff --git a/libc/arch-arm/bionic/memcmp16.S b/libc/arch-arm/bionic/memcmp16.S index afbb1b047..3f2f2f12d 100644 --- a/libc/arch-arm/bionic/memcmp16.S +++ b/libc/arch-arm/bionic/memcmp16.S @@ -27,7 +27,7 @@ */ #include -#include +#include /* * Optimized memcmp16() for ARM9. diff --git a/libc/arch-arm/bionic/memcpy.S b/libc/arch-arm/bionic/memcpy.S index f25b3e356..2c9b10c1e 100644 --- a/libc/arch-arm/bionic/memcpy.S +++ b/libc/arch-arm/bionic/memcpy.S @@ -27,7 +27,7 @@ */ #include -#include +#include #if defined(__ARM_NEON__) && !defined(ARCH_ARM_USE_NON_NEON_MEMCPY) diff --git a/libc/arch-arm/bionic/memcpy.a9.S b/libc/arch-arm/bionic/memcpy.a9.S index 2ba1ff51d..259701d67 100644 --- a/libc/arch-arm/bionic/memcpy.a9.S +++ b/libc/arch-arm/bionic/memcpy.a9.S @@ -44,7 +44,7 @@ */ #include -#include +#include .syntax unified /* This implementation requires ARM state. */ diff --git a/libc/arch-arm/bionic/setjmp.S b/libc/arch-arm/bionic/setjmp.S index 892708658..ed59d07f1 100644 --- a/libc/arch-arm/bionic/setjmp.S +++ b/libc/arch-arm/bionic/setjmp.S @@ -34,7 +34,7 @@ * SUCH DAMAGE. */ -#include +#include #include #include @@ -112,7 +112,7 @@ ENTRY(longjmp) add sp, sp, #4 /* unalign the stack */ .cfi_adjust_cfa_offset -4 - ldmfd sp!, {r0, r1, r14} + ldmfd sp!, {r0, r1, r14} .cfi_def_cfa_offset 0 #ifdef __ARM_HAVE_VFP diff --git a/libc/arch-arm/bionic/sigsetjmp.S b/libc/arch-arm/bionic/sigsetjmp.S index 59ab9da9b..7016f500c 100644 --- a/libc/arch-arm/bionic/sigsetjmp.S +++ b/libc/arch-arm/bionic/sigsetjmp.S @@ -35,7 +35,7 @@ #define _ALIGN_TEXT .align 0 -#include +#include #include /* diff --git a/libc/arch-arm/bionic/strcmp.S b/libc/arch-arm/bionic/strcmp.S index 42d41d143..6dba942d0 100644 --- a/libc/arch-arm/bionic/strcmp.S +++ b/libc/arch-arm/bionic/strcmp.S @@ -28,7 +28,7 @@ */ #include -#include +#include .text diff --git a/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S b/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S index dc86150d5..36da2d9d8 100644 --- a/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S +++ b/libc/arch-arm/cortex-a15/bionic/__strcat_chk.S @@ -26,8 +26,8 @@ * SUCH DAMAGE. */ -#include -#include "private/libc_events.h" +#include +#include .syntax unified diff --git a/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S b/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S index 95aaf4f56..c3e3e14fa 100644 --- a/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S +++ b/libc/arch-arm/cortex-a15/bionic/__strcpy_chk.S @@ -26,8 +26,8 @@ * SUCH DAMAGE. */ -#include -#include "private/libc_events.h" +#include +#include .syntax unified diff --git a/libc/arch-arm/cortex-a15/bionic/memcpy.S b/libc/arch-arm/cortex-a15/bionic/memcpy.S index badc93bf1..da4f3dd79 100644 --- a/libc/arch-arm/cortex-a15/bionic/memcpy.S +++ b/libc/arch-arm/cortex-a15/bionic/memcpy.S @@ -55,8 +55,8 @@ // Prototype: void *memcpy (void *dst, const void *src, size_t count). -#include -#include "private/libc_events.h" +#include +#include .text .syntax unified diff --git a/libc/arch-arm/cortex-a15/bionic/memset.S b/libc/arch-arm/cortex-a15/bionic/memset.S index 4e6d322d6..12c68d6a9 100644 --- a/libc/arch-arm/cortex-a15/bionic/memset.S +++ b/libc/arch-arm/cortex-a15/bionic/memset.S @@ -27,8 +27,8 @@ */ #include -#include -#include "private/libc_events.h" +#include +#include /* * Optimized memset() for ARM. diff --git a/libc/arch-arm/cortex-a15/bionic/strcat.S b/libc/arch-arm/cortex-a15/bionic/strcat.S index 72d4e9eb0..b95be940e 100644 --- a/libc/arch-arm/cortex-a15/bionic/strcat.S +++ b/libc/arch-arm/cortex-a15/bionic/strcat.S @@ -53,7 +53,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include .syntax unified diff --git a/libc/arch-arm/cortex-a15/bionic/strcmp.S b/libc/arch-arm/cortex-a15/bionic/strcmp.S index 0cccf06c9..12da1158d 100644 --- a/libc/arch-arm/cortex-a15/bionic/strcmp.S +++ b/libc/arch-arm/cortex-a15/bionic/strcmp.S @@ -27,7 +27,7 @@ */ #include -#include +#include #ifdef __ARMEB__ #define S2LOMEM lsl diff --git a/libc/arch-arm/cortex-a15/bionic/strcpy.S b/libc/arch-arm/cortex-a15/bionic/strcpy.S index 577354034..cb878c44f 100644 --- a/libc/arch-arm/cortex-a15/bionic/strcpy.S +++ b/libc/arch-arm/cortex-a15/bionic/strcpy.S @@ -53,7 +53,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include .syntax unified diff --git a/libc/arch-arm/cortex-a15/bionic/strlen.S b/libc/arch-arm/cortex-a15/bionic/strlen.S index 08f6d193b..9a0ce62a9 100644 --- a/libc/arch-arm/cortex-a15/bionic/strlen.S +++ b/libc/arch-arm/cortex-a15/bionic/strlen.S @@ -53,7 +53,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include .syntax unified diff --git a/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S b/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S index 700916822..651aefc7d 100644 --- a/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S +++ b/libc/arch-arm/cortex-a9/bionic/__strcat_chk.S @@ -26,8 +26,8 @@ * SUCH DAMAGE. */ -#include -#include "private/libc_events.h" +#include +#include .syntax unified .fpu neon diff --git a/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S b/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S index 908eec4c0..244778024 100644 --- a/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S +++ b/libc/arch-arm/cortex-a9/bionic/__strcpy_chk.S @@ -26,8 +26,8 @@ * SUCH DAMAGE. */ -#include -#include "private/libc_events.h" +#include +#include .syntax unified .fpu neon diff --git a/libc/arch-arm/cortex-a9/bionic/memcpy.S b/libc/arch-arm/cortex-a9/bionic/memcpy.S index 72c1a668c..8dcd937fc 100644 --- a/libc/arch-arm/cortex-a9/bionic/memcpy.S +++ b/libc/arch-arm/cortex-a9/bionic/memcpy.S @@ -26,8 +26,8 @@ * SUCH DAMAGE. */ -#include -#include "private/libc_events.h" +#include +#include /* * This code assumes it is running on a processor that supports all arm v7 diff --git a/libc/arch-arm/cortex-a9/bionic/memset.S b/libc/arch-arm/cortex-a9/bionic/memset.S index 7f77dad42..a5057eb04 100644 --- a/libc/arch-arm/cortex-a9/bionic/memset.S +++ b/libc/arch-arm/cortex-a9/bionic/memset.S @@ -26,9 +26,8 @@ * SUCH DAMAGE. */ -#include -#include -#include "private/libc_events.h" +#include +#include /* * This code assumes it is running on a processor that supports all arm v7 diff --git a/libc/arch-arm/cortex-a9/bionic/strcat.S b/libc/arch-arm/cortex-a9/bionic/strcat.S index 0f5baef4c..f5a855e39 100644 --- a/libc/arch-arm/cortex-a9/bionic/strcat.S +++ b/libc/arch-arm/cortex-a9/bionic/strcat.S @@ -53,7 +53,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include .syntax unified diff --git a/libc/arch-arm/cortex-a9/bionic/strcmp.S b/libc/arch-arm/cortex-a9/bionic/strcmp.S index eacdb8904..2411c654c 100644 --- a/libc/arch-arm/cortex-a9/bionic/strcmp.S +++ b/libc/arch-arm/cortex-a9/bionic/strcmp.S @@ -27,7 +27,7 @@ */ #include -#include +#include #ifdef __ARMEB__ #define S2LOMEM lsl diff --git a/libc/arch-arm/cortex-a9/bionic/strcpy.S b/libc/arch-arm/cortex-a9/bionic/strcpy.S index 9aa4f883d..9e9610bf3 100644 --- a/libc/arch-arm/cortex-a9/bionic/strcpy.S +++ b/libc/arch-arm/cortex-a9/bionic/strcpy.S @@ -53,7 +53,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include .syntax unified diff --git a/libc/arch-arm/cortex-a9/bionic/strlen.S b/libc/arch-arm/cortex-a9/bionic/strlen.S index 259eda0c4..b92b04352 100644 --- a/libc/arch-arm/cortex-a9/bionic/strlen.S +++ b/libc/arch-arm/cortex-a9/bionic/strlen.S @@ -53,7 +53,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include .syntax unified diff --git a/libc/arch-arm/generic/bionic/memcpy.S b/libc/arch-arm/generic/bionic/memcpy.S index 699b88d7c..cd4a13d12 100644 --- a/libc/arch-arm/generic/bionic/memcpy.S +++ b/libc/arch-arm/generic/bionic/memcpy.S @@ -27,8 +27,8 @@ */ #include -#include -#include "private/libc_events.h" +#include +#include /* * Optimized memcpy() for ARM. diff --git a/libc/arch-arm/generic/bionic/memset.S b/libc/arch-arm/generic/bionic/memset.S index baeb51966..be35de9ff 100644 --- a/libc/arch-arm/generic/bionic/memset.S +++ b/libc/arch-arm/generic/bionic/memset.S @@ -26,8 +26,8 @@ * SUCH DAMAGE. */ -#include -#include "private/libc_events.h" +#include +#include /* * Optimized memset() for ARM. diff --git a/libc/arch-arm/generic/bionic/strcmp.S b/libc/arch-arm/generic/bionic/strcmp.S index 42d41d143..6dba942d0 100644 --- a/libc/arch-arm/generic/bionic/strcmp.S +++ b/libc/arch-arm/generic/bionic/strcmp.S @@ -28,7 +28,7 @@ */ #include -#include +#include .text diff --git a/libc/arch-arm/generic/bionic/strcpy.S b/libc/arch-arm/generic/bionic/strcpy.S index cc997f448..802a62da8 100644 --- a/libc/arch-arm/generic/bionic/strcpy.S +++ b/libc/arch-arm/generic/bionic/strcpy.S @@ -30,7 +30,7 @@ */ #include -#include +#include ENTRY(strcpy) pld [r1, #0] diff --git a/libc/arch-arm/include/machine/asm.h b/libc/arch-arm/include/machine/asm.h index f16baf882..7954f05f1 100644 --- a/libc/arch-arm/include/machine/asm.h +++ b/libc/arch-arm/include/machine/asm.h @@ -38,107 +38,22 @@ #ifndef _ARM32_ASM_H_ #define _ARM32_ASM_H_ -#ifdef __ELF__ -# define _C_LABEL(x) x -#else -# ifdef __STDC__ -# define _C_LABEL(x) _ ## x -# else -# define _C_LABEL(x) _/**/x -# endif -#endif -#define _ASM_LABEL(x) x - -#ifdef __STDC__ -# define __CONCAT(x,y) x ## y -# define __STRING(x) #x -#else -# define __CONCAT(x,y) x/**/y -# define __STRING(x) "x" -#endif - #ifndef _ALIGN_TEXT # define _ALIGN_TEXT .align 0 #endif -/* - * gas/arm uses @ as a single comment character and thus cannot be used here - * Instead it recognised the # instead of an @ symbols in .type directives - * We define a couple of macros so that assembly code will not be dependant - * on one or the other. - */ -#define _ASM_TYPE_FUNCTION #function -#define _ASM_TYPE_OBJECT #object -#define _ENTRY(x) \ - .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: .fnstart; .cfi_startproc; - -#define _ASM_SIZE(x) .size x, .-x; - -#define _END(x) \ - .fnend; .cfi_endproc; \ - _ASM_SIZE(x) - -#ifdef GPROF -# ifdef __ELF__ -# define _PROF_PROLOGUE \ - mov ip, lr; bl __mcount -# else -# define _PROF_PROLOGUE \ - mov ip,lr; bl mcount -# endif -#else -# define _PROF_PROLOGUE -#endif - -#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE -#define ENTRY_NP(y) _ENTRY(_C_LABEL(y)) -#define END(y) _END(_C_LABEL(y)) -#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE -#define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y)) -#define ASEND(y) _END(_ASM_LABEL(y)) - -#ifdef __ELF__ -#define ENTRY_PRIVATE(y) ENTRY(y); .hidden _C_LABEL(y) -#else -#define ENTRY_PRIVATE(y) ENTRY(y) -#endif +#undef __bionic_asm_custom_entry +#undef __bionic_asm_custom_end +#define __bionic_asm_custom_entry(f) .fnstart +#define __bionic_asm_custom_end(f) .fnend -#define ASMSTR .asciz +#undef __bionic_asm_function_type +#define __bionic_asm_function_type #function #if defined(__ELF__) && defined(PIC) -#ifdef __STDC__ -#define PIC_SYM(x,y) x ## ( ## y ## ) +#define PIC_SYM(x,y) x ## ( ## y ## ) #else -#define PIC_SYM(x,y) x/**/(/**/y/**/) +#define PIC_SYM(x,y) x #endif -#else -#define PIC_SYM(x,y) x -#endif - -#ifdef __ELF__ -#define RCSID(x) .section ".ident"; .asciz x -#else -#define RCSID(x) .text; .asciz x -#endif - -#ifdef __ELF__ -#define WEAK_ALIAS(alias,sym) \ - .weak alias; \ - alias = sym -#endif - -#ifdef __STDC__ -#define WARN_REFERENCES(sym,msg) \ - .stabs msg ## ,30,0,0,0 ; \ - .stabs __STRING(_C_LABEL(sym)) ## ,1,0,0,0 -#elif defined(__ELF__) -#define WARN_REFERENCES(sym,msg) \ - .stabs msg,30,0,0,0 ; \ - .stabs __STRING(sym),1,0,0,0 -#else -#define WARN_REFERENCES(sym,msg) \ - .stabs msg,30,0,0,0 ; \ - .stabs __STRING(_/**/sym),1,0,0,0 -#endif /* __STDC__ */ #endif /* !_ARM_ASM_H_ */ diff --git a/libc/arch-arm/krait/bionic/__strcat_chk.S b/libc/arch-arm/krait/bionic/__strcat_chk.S index a5d06f3f8..34becdbbf 100644 --- a/libc/arch-arm/krait/bionic/__strcat_chk.S +++ b/libc/arch-arm/krait/bionic/__strcat_chk.S @@ -26,8 +26,8 @@ * SUCH DAMAGE. */ -#include -#include "private/libc_events.h" +#include +#include .syntax unified diff --git a/libc/arch-arm/krait/bionic/__strcpy_chk.S b/libc/arch-arm/krait/bionic/__strcpy_chk.S index 95aaf4f56..c3e3e14fa 100644 --- a/libc/arch-arm/krait/bionic/__strcpy_chk.S +++ b/libc/arch-arm/krait/bionic/__strcpy_chk.S @@ -26,8 +26,8 @@ * SUCH DAMAGE. */ -#include -#include "private/libc_events.h" +#include +#include .syntax unified diff --git a/libc/arch-arm/krait/bionic/memcpy.S b/libc/arch-arm/krait/bionic/memcpy.S index 54405fa9d..0b7b27659 100644 --- a/libc/arch-arm/krait/bionic/memcpy.S +++ b/libc/arch-arm/krait/bionic/memcpy.S @@ -28,8 +28,8 @@ /* Assumes neon instructions and a cache line size of 32 bytes. */ -#include -#include "private/libc_events.h" +#include +#include /* * This code assumes it is running on a processor that supports all arm v7 diff --git a/libc/arch-arm/krait/bionic/memset.S b/libc/arch-arm/krait/bionic/memset.S index 1563327c4..5d1943b72 100644 --- a/libc/arch-arm/krait/bionic/memset.S +++ b/libc/arch-arm/krait/bionic/memset.S @@ -27,8 +27,8 @@ */ #include -#include -#include "private/libc_events.h" +#include +#include /* * This code assumes it is running on a processor that supports all arm v7 diff --git a/libc/arch-arm/krait/bionic/strcmp.S b/libc/arch-arm/krait/bionic/strcmp.S index f735fb5e7..eacb82a6e 100644 --- a/libc/arch-arm/krait/bionic/strcmp.S +++ b/libc/arch-arm/krait/bionic/strcmp.S @@ -27,7 +27,7 @@ */ #include -#include +#include #ifdef __ARMEB__ #define S2LOMEM lsl diff --git a/libc/arch-arm64/bionic/__get_sp.S b/libc/arch-arm64/bionic/__get_sp.S index 3cd4ceb16..d495b6aff 100644 --- a/libc/arch-arm64/bionic/__get_sp.S +++ b/libc/arch-arm64/bionic/__get_sp.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include ENTRY(__get_sp) mov x0, sp diff --git a/libc/arch-arm64/bionic/__rt_sigreturn.S b/libc/arch-arm64/bionic/__rt_sigreturn.S index d176ea39f..8fb6f0c28 100644 --- a/libc/arch-arm64/bionic/__rt_sigreturn.S +++ b/libc/arch-arm64/bionic/__rt_sigreturn.S @@ -26,8 +26,7 @@ * SUCH DAMAGE. */ -#include -#include +#include ENTRY_PRIVATE(__rt_sigreturn) mov x8, __NR_rt_sigreturn diff --git a/libc/arch-arm64/bionic/_setjmp.S b/libc/arch-arm64/bionic/_setjmp.S index 6cbf5c6ba..dfa861b19 100644 --- a/libc/arch-arm64/bionic/_setjmp.S +++ b/libc/arch-arm64/bionic/_setjmp.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include #include /* diff --git a/libc/arch-arm64/bionic/setjmp.S b/libc/arch-arm64/bionic/setjmp.S index 2d8631b2c..9a68d8646 100644 --- a/libc/arch-arm64/bionic/setjmp.S +++ b/libc/arch-arm64/bionic/setjmp.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include #include /* diff --git a/libc/arch-arm64/bionic/sigsetjmp.S b/libc/arch-arm64/bionic/sigsetjmp.S index cde1cbb2b..4fdb3679d 100644 --- a/libc/arch-arm64/bionic/sigsetjmp.S +++ b/libc/arch-arm64/bionic/sigsetjmp.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include #include /* diff --git a/libc/arch-arm64/include/machine/asm.h b/libc/arch-arm64/include/machine/asm.h index 3f8b908c6..4bfabaf95 100644 --- a/libc/arch-arm64/include/machine/asm.h +++ b/libc/arch-arm64/include/machine/asm.h @@ -38,91 +38,17 @@ #ifndef _AARCH64_ASM_H_ #define _AARCH64_ASM_H_ -/* TODO: Add cfi directives for creating/restoring FP */ -#ifdef __ELF__ -# define _C_LABEL(x) x -#else -# ifdef __STDC__ -# define _C_LABEL(x) _ ## x -# else -# define _C_LABEL(x) _/**/x -# endif -#endif -#define _ASM_LABEL(x) x - -#ifdef __STDC__ -# define __CONCAT(x,y) x ## y -# define __STRING(x) #x -#else -# define __CONCAT(x,y) x/**/y -# define __STRING(x) "x" -#endif - #ifndef _ALIGN_TEXT -# define _ALIGN_TEXT .align 0 +# define _ALIGN_TEXT .align 0 #endif -#define _ASM_TYPE_FUNCTION %function -#define _ASM_TYPE_OBJECT %object -#define _ENTRY(x) \ - .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: .cfi_startproc - -#define _ASM_SIZE(x) .size x, .-x; - -#define _END(x) \ - .cfi_endproc; \ - _ASM_SIZE(x) - -#define ENTRY(y) _ENTRY(_C_LABEL(y)); -#define ENTRY_NP(y) _ENTRY(_C_LABEL(y)) -#define END(y) _END(_C_LABEL(y)) -#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE -#define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y)) -#define ASEND(y) _END(_ASM_LABEL(y)) - -#ifdef __ELF__ -#define ENTRY_PRIVATE(y) ENTRY(y); .hidden _C_LABEL(y) -#else -#define ENTRY_PRIVATE(y) ENTRY(y) -#endif - -#define ASMSTR .asciz +#undef __bionic_asm_function_type +#define __bionic_asm_function_type %function #if defined(__ELF__) && defined(PIC) -#ifdef __STDC__ -#define PIC_SYM(x,y) x ## ( ## y ## ) -#else -#define PIC_SYM(x,y) x/**/(/**/y/**/) -#endif -#else -#define PIC_SYM(x,y) x -#endif - -#ifdef __ELF__ -#define RCSID(x) .section ".ident"; .asciz x +#define PIC_SYM(x,y) x ## ( ## y ## ) #else -#define RCSID(x) .text; .asciz x +#define PIC_SYM(x,y) x #endif -#ifdef __ELF__ -#define WEAK_ALIAS(alias,sym) \ - .weak alias; \ - alias = sym -#endif - -#ifdef __STDC__ -#define WARN_REFERENCES(sym,msg) \ - .stabs msg ## ,30,0,0,0 ; \ - .stabs __STRING(_C_LABEL(sym)) ## ,1,0,0,0 -#elif defined(__ELF__) -#define WARN_REFERENCES(sym,msg) \ - .stabs msg,30,0,0,0 ; \ - .stabs __STRING(sym),1,0,0,0 -#else -#define WARN_REFERENCES(sym,msg) \ - .stabs msg,30,0,0,0 ; \ - .stabs __STRING(_/**/sym),1,0,0,0 -#endif /* __STDC__ */ - #endif /* _AARCH64_ASM_H_ */ - diff --git a/libc/arch-mips/bionic/__bionic_clone.S b/libc/arch-mips/bionic/__bionic_clone.S index 8970b6ec7..92731347d 100644 --- a/libc/arch-mips/bionic/__bionic_clone.S +++ b/libc/arch-mips/bionic/__bionic_clone.S @@ -26,49 +26,43 @@ * SUCH DAMAGE. */ -#include +#include #include #include // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg); - .text - .type __bionic_clone, @function - .global __bionic_clone - .align 4 - .ent __bionic_clone -__bionic_clone: +ENTRY(__bionic_clone) .set noreorder - .cpload $t9 + .cpload t9 .set reorder # set up child stack - subu $a1,16 - lw $t0,20($sp) # fn - lw $t1,24($sp) # arg - sw $t0,0($a1) # fn - sw $t1,4($a1) # arg + subu a1,16 + lw t0,20(sp) # fn + lw t1,24(sp) # arg + sw t0,0(a1) # fn + sw t1,4(a1) # arg # remainder of arguments are correct for clone system call - li $v0,__NR_clone + li v0,__NR_clone syscall - bnez $a3,.L__error_bc + bnez a3,.L__error_bc - beqz $v0,.L__thread_start_bc + beqz v0,.L__thread_start_bc - j $ra + j ra .L__thread_start_bc: - lw $a0,0($sp) # fn - lw $a1,4($sp) # arg + lw a0,0(sp) # fn + lw a1,4(sp) # arg # void __bionic_clone_entry(int (*func)(void*), void *arg) - la $t9,__bionic_clone_entry - j $t9 + la t9,__bionic_clone_entry + j t9 .L__error_bc: - move $a0,$v0 - la $t9,__set_errno - j $t9 - - .end __bionic_clone + move a0,v0 + la t9,__set_errno + j t9 +END(__bionic_clone) diff --git a/libc/arch-mips/bionic/__get_sp.S b/libc/arch-mips/bionic/__get_sp.S index 834c89d82..d4b278b24 100644 --- a/libc/arch-mips/bionic/__get_sp.S +++ b/libc/arch-mips/bionic/__get_sp.S @@ -25,15 +25,11 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - .text -/* void *__get_sp(void) */ +#include - .type __get_sp, @function - .global __get_sp - .align 4 - .ent __get_sp -__get_sp: - move $v0, $sp - j $ra - .end __get_sp +// void* __get_sp() +ENTRY(__get_sp) + move v0, sp + j ra +END(__get_sp) diff --git a/libc/arch-mips/bionic/_exit_with_stack_teardown.S b/libc/arch-mips/bionic/_exit_with_stack_teardown.S index 8f624c324..129e3f9a3 100644 --- a/libc/arch-mips/bionic/_exit_with_stack_teardown.S +++ b/libc/arch-mips/bionic/_exit_with_stack_teardown.S @@ -26,23 +26,16 @@ * SUCH DAMAGE. */ -#include - - .text +#include // void _exit_with_stack_teardown(void* stackBase, size_t stackSize) - - .type _exit_with_stack_teardown, @function - .global _exit_with_stack_teardown - .align 4 - .ent _exit_with_stack_teardown -_exit_with_stack_teardown: - li $v0, __NR_munmap +ENTRY(_exit_with_stack_teardown) + li v0, __NR_munmap syscall // If munmap failed, we ignore the failure and exit anyway. - li $a0, 0 - li $v0, __NR_exit + li a0, 0 + li v0, __NR_exit syscall // The exit syscall does not return. - .end _exit_with_stack_teardown +END(_exit_with_stack_teardown) diff --git a/libc/arch-mips/bionic/_setjmp.S b/libc/arch-mips/bionic/_setjmp.S index e7083ae29..4465cd20e 100644 --- a/libc/arch-mips/bionic/_setjmp.S +++ b/libc/arch-mips/bionic/_setjmp.S @@ -2,7 +2,7 @@ /* * Copyright (c) 2002 Opsycon AB (www.opsycon.se / www.opsycon.com) - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -29,7 +29,7 @@ * */ -#include +#include #include #include @@ -48,13 +48,13 @@ GPOFF= FRAMESZ-2*REGSZ swc1 FPR, OFF(BASE) ; \ mfhc1 t0, FPR ; \ sw t0, OFF+4(BASE) ; - + #define FPREG64_L(FPR, OFF, BASE) \ lw t0, OFF+4(BASE) ; \ lw t1, OFF(BASE) ; \ mtc1 t1, FPR ; \ mthc1 t0, FPR ; \ - + LEAF(_setjmp, FRAMESZ) PTR_SUBU sp, FRAMESZ SETUP_GP64(GPOFF, _setjmp) @@ -185,4 +185,3 @@ botch: RESTORE_GP64 PTR_ADDU sp, FRAMESZ END(_longjmp) - diff --git a/libc/arch-mips/bionic/bzero.S b/libc/arch-mips/bionic/bzero.S index 67393455a..6e5d2947f 100644 --- a/libc/arch-mips/bionic/bzero.S +++ b/libc/arch-mips/bionic/bzero.S @@ -25,21 +25,15 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - .text -/* - * void bzero(void *s, size_t n); - */ - .type bzero, @function - .global bzero - .align 4 - .ent bzero - .set noreorder -bzero: - .cpload $t9 - move $a2,$a1 - la $t9,memset - j $t9 - move $a1,$zero - .end bzero +#include +// void bzero(void*, size_t); +ENTRY(bzero) + .set noreorder + .cpload t9 + move a2,a1 + la t9,memset + j t9 + move a1,zero +END(bzero) diff --git a/libc/arch-mips/bionic/futex_mips.S b/libc/arch-mips/bionic/futex_mips.S index 285beacfa..7626a7ca1 100644 --- a/libc/arch-mips/bionic/futex_mips.S +++ b/libc/arch-mips/bionic/futex_mips.S @@ -32,11 +32,7 @@ #define FUTEX_WAKE 1 // int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout) - .type __futex_wait, @function - .global __futex_wait - .align 4 - .ent __futex_wait -__futex_wait: +ENTRY(__futex_wait) subu sp,4*6 sw $0,20(sp) /* val3 */ sw $0,16(sp) /* addr2 */ @@ -54,14 +50,10 @@ __futex_wait: .set reorder addu sp,4*6 j ra - .end __futex_wait +END(__futex_wait) // int __futex_wake(volatile void* ftx, int count) - .type __futex_wake, @function - .globl __futex_wake - .align 4 - .ent __futex_wake -__futex_wake: +ENTRY(__futex_wake) subu sp,4*6 sw $0,20(sp) /* val3 */ sw $0,16(sp) /* addr2 */ @@ -79,14 +71,10 @@ __futex_wake: .set reorder addu sp,4*6 j ra - .end __futex_wake +END(__futex_wake) // int __futex_syscall3(volatile void* ftx, int op, int count) - .type __futex_syscall3, @function - .global __futex_syscall3 - .align 4 - .ent __futex_syscall3 -__futex_syscall3: +ENTRY(__futex_syscall3) subu sp,4*6 sw $0,20(sp) /* val3 */ sw $0,16(sp) /* addr2 */ @@ -104,14 +92,10 @@ __futex_syscall3: .set reorder addu sp,4*6 j ra - .end __futex_syscall3 +END(__futex_syscall3) // int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout) - .type __futex_syscall4, @function - .global __futex_syscall4 - .align 4 - .ent __futex_syscall4 -__futex_syscall4: +ENTRY(__futex_syscall4) subu sp,4*6 sw $0,20(sp) /* val3 */ sw $0,16(sp) /* addr2 */ @@ -129,4 +113,4 @@ __futex_syscall4: .set reorder addu sp,4*6 j ra - .end __futex_syscall4 +END(__futex_syscall4) diff --git a/libc/arch-mips/bionic/memcmp16.S b/libc/arch-mips/bionic/memcmp16.S index a2b254439..f9d14a93a 100644 --- a/libc/arch-mips/bionic/memcmp16.S +++ b/libc/arch-mips/bionic/memcmp16.S @@ -25,31 +25,26 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - .text -/* - * u4 __memcmp16(const u2* s0, const u2* s1, size_t count); - */ - .type __memcmp16, @function - .global __memcmp16 - .align 4 - .ent __memcmp16 -__memcmp16: - li $t0,0 - li $t1,0 - beqz $a2,done /* 0 length string */ - beq $a0,$a1,done /* strings are identical */ +#include + +// u4 __memcmp16(const u2*, const u2*, size_t); +ENTRY(__memcmp16) + li t0,0 + li t1,0 + beqz a2,done /* 0 length string */ + beq a0,a1,done /* strings are identical */ /* Unoptimised... */ -1: lhu $t0,0($a0) - lhu $t1,0($a1) - addu $a1,2 - bne $t0,$t1,done - addu $a0,2 - subu $a2,1 - bnez $a2,1b +1: lhu t0,0(a0) + lhu t1,0(a1) + addu a1,2 + bne t0,t1,done + addu a0,2 + subu a2,1 + bnez a2,1b done: - subu $v0,$t0,$t1 - j $ra - .end __memcmp16 + subu v0,t0,t1 + j ra +END(__memcmp16) diff --git a/libc/arch-mips/bionic/setjmp.S b/libc/arch-mips/bionic/setjmp.S index 7c21195b6..2af1fbdce 100644 --- a/libc/arch-mips/bionic/setjmp.S +++ b/libc/arch-mips/bionic/setjmp.S @@ -29,7 +29,7 @@ * */ -#include +#include #include #include @@ -49,13 +49,13 @@ RAOFF= FRAMESZ-1*REGSZ swc1 FPR, OFF(BASE) ; \ mfhc1 t0, FPR ; \ sw t0, OFF+4(BASE) ; - + #define FPREG64_L(FPR, OFF, BASE) \ lw t0, OFF+4(BASE) ; \ lw t1, OFF(BASE) ; \ mtc1 t1, FPR ; \ mthc1 t0, FPR ; \ - + NON_LEAF(setjmp, FRAMESZ, ra) .mask 0x80000000, RAOFF PTR_SUBU sp, FRAMESZ # allocate stack frame @@ -154,7 +154,7 @@ LEAF(longjmp, FRAMESZ) lw a0, A0OFF(sp) lw a1, A1OFF(sp) - .set noreorder + .set noreorder REG_L v0, SC_REGS+ZERO*REGSZ(a0) bne v0, 0xACEDBADE, botch # jump if error REG_L ra, SC_PC(a0) @@ -169,9 +169,9 @@ LEAF(longjmp, FRAMESZ) REG_L s8, SC_REGS+S8*REGSZ(a0) REG_L gp, SC_REGS+GP*REGSZ(a0) REG_L sp, SC_REGS+SP*REGSZ(a0) - + #if !defined(SOFTFLOAT) - REG_L v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0) + REG_L v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0) ctc1 v0, $31 #if _MIPS_FPSET == 32 FPREG64_L($f20, SC_FPREGS+((F20-F0)*REGSZ_FP), a0) diff --git a/libc/arch-mips/bionic/sigsetjmp.S b/libc/arch-mips/bionic/sigsetjmp.S index b05454c28..9d2e5ea87 100644 --- a/libc/arch-mips/bionic/sigsetjmp.S +++ b/libc/arch-mips/bionic/sigsetjmp.S @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include +#include #include #include diff --git a/libc/arch-mips/bionic/syscall.S b/libc/arch-mips/bionic/syscall.S index af5bcc9ab..db477a506 100644 --- a/libc/arch-mips/bionic/syscall.S +++ b/libc/arch-mips/bionic/syscall.S @@ -26,11 +26,7 @@ * SUCH DAMAGE. */ -#include - .text - .globl syscall - .align 4 - .ent syscall +#include /* * The caller is only required to allocate 16 bytes of stack for a0-a3. @@ -38,28 +34,28 @@ */ #define STACKSIZE 2*4 -syscall: +ENTRY(syscall) .set noreorder - .cpload $t9 - move $v0, $a0 - move $a0, $a1 - move $a1, $a2 - move $a2, $a3 - lw $a3, 16($sp) - lw $t0, 20($sp) - lw $t1, 24($sp) - subu $sp, STACKSIZE - sw $t0, 16($sp) - sw $t1, 20($sp) + .cpload t9 + move v0, a0 + move a0, a1 + move a1, a2 + move a2, a3 + lw a3, 16(sp) + lw t0, 20(sp) + lw t1, 24(sp) + subu sp, STACKSIZE + sw t0, 16(sp) + sw t1, 20(sp) syscall - addu $sp, STACKSIZE - bnez $a3, 1f - move $a0, $v0 - j $ra + addu sp, STACKSIZE + bnez a3, 1f + move a0, v0 + j ra nop 1: - la $t9,__set_errno - j $t9 + la t9,__set_errno + j t9 nop .set reorder - .end syscall +END(syscall) diff --git a/libc/arch-mips/bionic/vfork.S b/libc/arch-mips/bionic/vfork.S index 414caaf4e..96de69e20 100644 --- a/libc/arch-mips/bionic/vfork.S +++ b/libc/arch-mips/bionic/vfork.S @@ -26,39 +26,33 @@ * SUCH DAMAGE. */ -#include +#include #include // TODO: mips' uapi signal.h is missing #ifndef __ASSEMBLY__. // #include #define SIGCHLD 18 - .text - - .type vfork, @function - .global vfork - .align 4 - .ent vfork -vfork: +ENTRY(vfork) .set noreorder - .cpload $t9 + .cpload t9 - li $a0, (CLONE_VM | CLONE_VFORK | SIGCHLD) - li $a1, 0 - li $a2, 0 - li $a3, 0 - subu $sp, 8 - sw $0, 16($sp) - li $v0, __NR_clone + li a0, (CLONE_VM | CLONE_VFORK | SIGCHLD) + li a1, 0 + li a2, 0 + li a3, 0 + subu sp, 8 + sw $0, 16(sp) + li v0, __NR_clone syscall - addu $sp, 8 - bnez $a3, 1f - move $a0, $v0 + addu sp, 8 + bnez a3, 1f + move a0, v0 - j $ra + j ra nop 1: - la $t9, __set_errno - j $t9 + la t9, __set_errno + j t9 nop - .end vfork +END(vfork) diff --git a/libc/arch-mips/include/machine/asm.h b/libc/arch-mips/include/machine/asm.h index 43dbc09a8..5eacde3df 100644 --- a/libc/arch-mips/include/machine/asm.h +++ b/libc/arch-mips/include/machine/asm.h @@ -28,25 +28,24 @@ #ifndef _MIPS64_ASM_H #define _MIPS64_ASM_H -#include - -#ifdef NEED_OLD_RM7KFIX -#define ITLBNOPFIX nop;nop;nop;nop;nop;nop;nop;nop;nop;nop; -#else -#define ITLBNOPFIX nop;nop;nop;nop +#ifndef _ALIGN_TEXT +# define _ALIGN_TEXT .align 4 #endif +#undef __bionic_asm_custom_entry +#undef __bionic_asm_custom_end +#define __bionic_asm_custom_entry(f) .ent f +#define __bionic_asm_custom_end(f) .end f + +#include + #define _MIPS_ISA_MIPS1 1 /* R2000/R3000 */ #define _MIPS_ISA_MIPS2 2 /* R4000/R6000 */ #define _MIPS_ISA_MIPS3 3 /* R4000 */ #define _MIPS_ISA_MIPS4 4 /* TFP (R1x000) */ -#ifdef __linux__ #define _MIPS_ISA_MIPS5 5 #define _MIPS_ISA_MIPS32 6 #define _MIPS_ISA_MIPS64 7 -#else -#define _MIPS_ISA_MIPS32 32 /* MIPS32 */ -#endif #if !defined(ABICALLS) && !defined(_NO_ABICALLS) #define ABICALLS .abicalls @@ -56,8 +55,6 @@ ABICALLS #endif -#define _C_LABEL(x) x /* XXX Obsolete but keep for a while */ - #if !defined(__MIPSEL__) && !defined(__MIPSEB__) #error "__MIPSEL__ or __MIPSEB__ must be defined" #endif @@ -90,15 +87,6 @@ */ #if defined(ABICALLS) && !defined(_KERNEL) && !defined(_STANDALONE) -#ifndef _MIPS_SIM -#define _MIPS_SIM 1 -#define _ABIO32 1 -#endif -#ifndef _MIPS_ISA -#define _MIPS_ISA 2 -#define _MIPS_ISA_MIPS2 2 -#endif - #if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32) #define NARGSAVE 4 @@ -151,7 +139,7 @@ #define CF_RA_OFFS 20 /* Call ra save offset */ #endif -#if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4) +#if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4 || _MIPS_ISA == _MIPS_ISA_MIPS64) #define REGSZ 8 /* 64 bit mode register size */ #define LOGREGSZ 3 /* log rsize */ #define REG_S sd @@ -190,28 +178,6 @@ #endif /* - * Define -pg profile entry code. - */ -#if defined(XGPROF) || defined(XPROF) -#define MCOUNT \ - PTR_SUBU sp, sp, 32; \ - SAVE_GP(16); \ - sw ra, 28(sp); \ - sw gp, 24(sp); \ - .set noat; \ - .set noreorder; \ - move AT, ra; \ - jal _mcount; \ - PTR_SUBU sp, sp, 8; \ - lw ra, 28(sp); \ - PTR_ADDU sp, sp, 32; \ - .set reorder; \ - .set at; -#else -#define MCOUNT -#endif - -/* * LEAF(x, fsize) * * Declare a leaf routine. @@ -221,26 +187,9 @@ .globl x; \ .ent x, 0; \ x: ; \ + .cfi_startproc; \ .frame sp, fsize, ra; \ SETUP_GP \ - MCOUNT - -#define ALEAF(x) \ - .globl x; \ -x: - -/* - * NLEAF(x) - * - * Declare a non-profiled leaf routine. - */ -#define NLEAF(x, fsize) \ - .align 3; \ - .globl x; \ - .ent x, 0; \ -x: ; \ - .frame sp, fsize, ra; \ - SETUP_GP /* * NON_LEAF(x) @@ -252,54 +201,8 @@ x: ; \ .globl x; \ .ent x, 0; \ x: ; \ + .cfi_startproc; \ .frame sp, fsize, retpc; \ SETUP_GP \ - MCOUNT - -/* - * NNON_LEAF(x) - * - * Declare a non-profiled non-leaf routine - * (a routine that makes other C calls). - */ -#define NNON_LEAF(x, fsize, retpc) \ - .align 3; \ - .globl x; \ - .ent x, 0; \ -x: ; \ - .frame sp, fsize, retpc \ - SETUP_GP - -/* - * END(x) - * - * Mark end of a procedure. - */ -#define END(x) \ - .end x - -/* - * Macros to panic and printf from assembly language. - */ -#define PANIC(msg) \ - LA a0, 9f; \ - jal panic; \ - nop ; \ - MSG(msg) - -#define PRINTF(msg) \ - la a0, 9f; \ - jal printf; \ - nop ; \ - MSG(msg) - -#define MSG(msg) \ - .rdata; \ -9: .asciiz msg; \ - .text - -#define ASMSTR(str) \ - .asciiz str; \ - .align 3 #endif /* !_MIPS_ASM_H */ diff --git a/libc/arch-mips/include/machine/signal.h b/libc/arch-mips/include/machine/signal.h index f02ec0d22..b31715cce 100644 --- a/libc/arch-mips/include/machine/signal.h +++ b/libc/arch-mips/include/machine/signal.h @@ -37,8 +37,6 @@ #ifndef _MIPS_SIGNAL_H_ #define _MIPS_SIGNAL_H_ -#include - #define SC_REGMASK (0*REGSZ) #define SC_STATUS (1*REGSZ) #define SC_PC (2*REGSZ) diff --git a/libc/arch-mips/string/memcpy.S b/libc/arch-mips/string/memcpy.S index aabdfcfdc..dc91096bd 100644 --- a/libc/arch-mips/string/memcpy.S +++ b/libc/arch-mips/string/memcpy.S @@ -39,13 +39,13 @@ * Include files ************************************************************************/ -#include "machine/asm.h" +#include -/* +/* * This routine could be optimized for MIPS64. The current code only * uses MIPS32 instructions. - */ + */ #if defined(__MIPSEB__) # define LWHI lwl /* high part is left in big-endian */ # define SWHI swl /* high part is left in big-endian */ diff --git a/libc/arch-mips/string/memset.S b/libc/arch-mips/string/memset.S index a1c5055c4..3e630caf8 100644 --- a/libc/arch-mips/string/memset.S +++ b/libc/arch-mips/string/memset.S @@ -39,12 +39,12 @@ * Include files ************************************************************************/ -#include "machine/asm.h" +#include -/* +/* * This routine could be optimized for MIPS64. The current code only * uses MIPS32 instructions. - */ + */ #if defined(__MIPSEB__) # define SWHI swl /* high part is left in big-endian */ @@ -220,7 +220,7 @@ LEAF(memset,0) sw a1,-36(a0) nop nop # the extra nop instructions help to balance - nop # cycles needed for "store" + "fill" + "evict" + nop # cycles needed for "store" + "fill" + "evict" nop # For 64byte store there are needed 8 fill nop # and 8 evict cycles, i.e. at least 32 instr. nop @@ -320,4 +320,3 @@ END(memset) /************************************************************************ * Implementation : Static functions ************************************************************************/ - diff --git a/libc/arch-mips64/bionic/__bionic_clone.S b/libc/arch-mips64/bionic/__bionic_clone.S index 2a9a2b084..e1ade30be 100644 --- a/libc/arch-mips64/bionic/__bionic_clone.S +++ b/libc/arch-mips64/bionic/__bionic_clone.S @@ -26,8 +26,7 @@ * SUCH DAMAGE. */ -#include -#include +#include #include #include @@ -43,8 +42,7 @@ FRAME_FN = FRAMESZ-3*REGSZ #endif // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg); - .text -LEAF(__bionic_clone,FRAMESZ) +LEAF(__bionic_clone, FRAMESZ) PTR_SUBU sp, FRAMESZ # allocate stack frame SETUP_GP64(FRAME_GP,__bionic_clone) SAVE_GP(FRAME_GP) diff --git a/libc/arch-mips64/bionic/__get_sp.S b/libc/arch-mips64/bionic/__get_sp.S index 834c89d82..8488102b6 100644 --- a/libc/arch-mips64/bionic/__get_sp.S +++ b/libc/arch-mips64/bionic/__get_sp.S @@ -25,15 +25,10 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - .text -/* void *__get_sp(void) */ +#include - .type __get_sp, @function - .global __get_sp - .align 4 - .ent __get_sp -__get_sp: - move $v0, $sp - j $ra - .end __get_sp +ENTRY(__get_sp) + move v0, sp + j ra +END(__get_sp) diff --git a/libc/arch-mips64/bionic/_exit_with_stack_teardown.S b/libc/arch-mips64/bionic/_exit_with_stack_teardown.S index 8f624c324..3b537eb21 100644 --- a/libc/arch-mips64/bionic/_exit_with_stack_teardown.S +++ b/libc/arch-mips64/bionic/_exit_with_stack_teardown.S @@ -26,23 +26,16 @@ * SUCH DAMAGE. */ -#include - - .text +#include // void _exit_with_stack_teardown(void* stackBase, size_t stackSize) +ENTRY(_exit_with_stack_teardown) + li v0, __NR_munmap + syscall + // If munmap failed, we ignore the failure and exit anyway. - .type _exit_with_stack_teardown, @function - .global _exit_with_stack_teardown - .align 4 - .ent _exit_with_stack_teardown -_exit_with_stack_teardown: - li $v0, __NR_munmap - syscall - // If munmap failed, we ignore the failure and exit anyway. - - li $a0, 0 - li $v0, __NR_exit - syscall - // The exit syscall does not return. - .end _exit_with_stack_teardown + li a0, 0 + li v0, __NR_exit + syscall + // The exit syscall does not return. +END(_exit_with_stack_teardown) diff --git a/libc/arch-mips64/bionic/_setjmp.S b/libc/arch-mips64/bionic/_setjmp.S index e7083ae29..4465cd20e 100644 --- a/libc/arch-mips64/bionic/_setjmp.S +++ b/libc/arch-mips64/bionic/_setjmp.S @@ -2,7 +2,7 @@ /* * Copyright (c) 2002 Opsycon AB (www.opsycon.se / www.opsycon.com) - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -29,7 +29,7 @@ * */ -#include +#include #include #include @@ -48,13 +48,13 @@ GPOFF= FRAMESZ-2*REGSZ swc1 FPR, OFF(BASE) ; \ mfhc1 t0, FPR ; \ sw t0, OFF+4(BASE) ; - + #define FPREG64_L(FPR, OFF, BASE) \ lw t0, OFF+4(BASE) ; \ lw t1, OFF(BASE) ; \ mtc1 t1, FPR ; \ mthc1 t0, FPR ; \ - + LEAF(_setjmp, FRAMESZ) PTR_SUBU sp, FRAMESZ SETUP_GP64(GPOFF, _setjmp) @@ -185,4 +185,3 @@ botch: RESTORE_GP64 PTR_ADDU sp, FRAMESZ END(_longjmp) - diff --git a/libc/arch-mips64/bionic/bzero.S b/libc/arch-mips64/bionic/bzero.S index d0b5c847c..76c6bc278 100644 --- a/libc/arch-mips64/bionic/bzero.S +++ b/libc/arch-mips64/bionic/bzero.S @@ -25,9 +25,8 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - .text -#include +#include /* * void bzero(void *s, size_t n); @@ -40,4 +39,3 @@ LEAF(bzero,0) RESTORE_GP64 j t9 END(bzero) - diff --git a/libc/arch-mips64/bionic/memcmp16.S b/libc/arch-mips64/bionic/memcmp16.S index b70c078e7..1c58c1b49 100644 --- a/libc/arch-mips64/bionic/memcmp16.S +++ b/libc/arch-mips64/bionic/memcmp16.S @@ -27,7 +27,7 @@ */ .text -#include +#include /* * u4 __memcmp16(const u2* s0, const u2* s1, size_t count); diff --git a/libc/arch-mips64/bionic/setjmp.S b/libc/arch-mips64/bionic/setjmp.S index 7c21195b6..2af1fbdce 100644 --- a/libc/arch-mips64/bionic/setjmp.S +++ b/libc/arch-mips64/bionic/setjmp.S @@ -29,7 +29,7 @@ * */ -#include +#include #include #include @@ -49,13 +49,13 @@ RAOFF= FRAMESZ-1*REGSZ swc1 FPR, OFF(BASE) ; \ mfhc1 t0, FPR ; \ sw t0, OFF+4(BASE) ; - + #define FPREG64_L(FPR, OFF, BASE) \ lw t0, OFF+4(BASE) ; \ lw t1, OFF(BASE) ; \ mtc1 t1, FPR ; \ mthc1 t0, FPR ; \ - + NON_LEAF(setjmp, FRAMESZ, ra) .mask 0x80000000, RAOFF PTR_SUBU sp, FRAMESZ # allocate stack frame @@ -154,7 +154,7 @@ LEAF(longjmp, FRAMESZ) lw a0, A0OFF(sp) lw a1, A1OFF(sp) - .set noreorder + .set noreorder REG_L v0, SC_REGS+ZERO*REGSZ(a0) bne v0, 0xACEDBADE, botch # jump if error REG_L ra, SC_PC(a0) @@ -169,9 +169,9 @@ LEAF(longjmp, FRAMESZ) REG_L s8, SC_REGS+S8*REGSZ(a0) REG_L gp, SC_REGS+GP*REGSZ(a0) REG_L sp, SC_REGS+SP*REGSZ(a0) - + #if !defined(SOFTFLOAT) - REG_L v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0) + REG_L v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0) ctc1 v0, $31 #if _MIPS_FPSET == 32 FPREG64_L($f20, SC_FPREGS+((F20-F0)*REGSZ_FP), a0) diff --git a/libc/arch-mips64/bionic/sigsetjmp.S b/libc/arch-mips64/bionic/sigsetjmp.S index b05454c28..9d2e5ea87 100644 --- a/libc/arch-mips64/bionic/sigsetjmp.S +++ b/libc/arch-mips64/bionic/sigsetjmp.S @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include +#include #include #include diff --git a/libc/arch-mips64/bionic/syscall.S b/libc/arch-mips64/bionic/syscall.S index 08aa7051a..c4fd00995 100644 --- a/libc/arch-mips64/bionic/syscall.S +++ b/libc/arch-mips64/bionic/syscall.S @@ -26,8 +26,7 @@ * SUCH DAMAGE. */ -#include -#include +#include #if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32) FRAMESZ = MKFSIZ(6,0) diff --git a/libc/arch-mips64/bionic/vfork.S b/libc/arch-mips64/bionic/vfork.S index c93694586..911a264f2 100644 --- a/libc/arch-mips64/bionic/vfork.S +++ b/libc/arch-mips64/bionic/vfork.S @@ -26,8 +26,7 @@ * SUCH DAMAGE. */ -#include -#include +#include #include // TODO: mips' uapi signal.h is missing #ifndef __ASSEMBLY__. @@ -46,7 +45,7 @@ LEAF(vfork,FRAMESZ) #if FRAMESZ!=0 PTR_SUBU sp, FRAMESZ #endif - SETUP_GP64(a5,vfork) + SETUP_GP64(a5, vfork) LI a0, (CLONE_VM | CLONE_VFORK | SIGCHLD) move a1, $0 move a2, $0 diff --git a/libc/arch-mips64/include/machine/asm.h b/libc/arch-mips64/include/machine/asm.h index eabb1bf4c..5eacde3df 100644 --- a/libc/arch-mips64/include/machine/asm.h +++ b/libc/arch-mips64/include/machine/asm.h @@ -28,25 +28,24 @@ #ifndef _MIPS64_ASM_H #define _MIPS64_ASM_H -#include - -#ifdef NEED_OLD_RM7KFIX -#define ITLBNOPFIX nop;nop;nop;nop;nop;nop;nop;nop;nop;nop; -#else -#define ITLBNOPFIX nop;nop;nop;nop +#ifndef _ALIGN_TEXT +# define _ALIGN_TEXT .align 4 #endif +#undef __bionic_asm_custom_entry +#undef __bionic_asm_custom_end +#define __bionic_asm_custom_entry(f) .ent f +#define __bionic_asm_custom_end(f) .end f + +#include + #define _MIPS_ISA_MIPS1 1 /* R2000/R3000 */ #define _MIPS_ISA_MIPS2 2 /* R4000/R6000 */ #define _MIPS_ISA_MIPS3 3 /* R4000 */ #define _MIPS_ISA_MIPS4 4 /* TFP (R1x000) */ -#ifdef __linux__ #define _MIPS_ISA_MIPS5 5 #define _MIPS_ISA_MIPS32 6 #define _MIPS_ISA_MIPS64 7 -#else -#define _MIPS_ISA_MIPS32 32 /* MIPS32 */ -#endif #if !defined(ABICALLS) && !defined(_NO_ABICALLS) #define ABICALLS .abicalls @@ -56,8 +55,6 @@ ABICALLS #endif -#define _C_LABEL(x) x /* XXX Obsolete but keep for a while */ - #if !defined(__MIPSEL__) && !defined(__MIPSEB__) #error "__MIPSEL__ or __MIPSEB__ must be defined" #endif @@ -90,15 +87,6 @@ */ #if defined(ABICALLS) && !defined(_KERNEL) && !defined(_STANDALONE) -#ifndef _MIPS_SIM -#define _MIPS_SIM 1 -#define _ABIO32 1 -#endif -#ifndef _MIPS_ISA -#define _MIPS_ISA 2 -#define _MIPS_ISA_MIPS2 2 -#endif - #if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32) #define NARGSAVE 4 @@ -190,28 +178,6 @@ #endif /* - * Define -pg profile entry code. - */ -#if defined(XGPROF) || defined(XPROF) -#define MCOUNT \ - PTR_SUBU sp, sp, 64; \ - SAVE_GP(16); \ - sd ra, 56(sp); \ - sd gp, 48(sp); \ - .set noat; \ - .set noreorder; \ - move AT, ra; \ - jal _mcount; \ - PTR_SUBU sp, sp, 16; \ - ld ra, 56(sp); \ - PTR_ADDU sp, sp, 64; \ - .set reorder; \ - .set at; -#else -#define MCOUNT -#endif - -/* * LEAF(x, fsize) * * Declare a leaf routine. @@ -221,26 +187,9 @@ .globl x; \ .ent x, 0; \ x: ; \ + .cfi_startproc; \ .frame sp, fsize, ra; \ SETUP_GP \ - MCOUNT - -#define ALEAF(x) \ - .globl x; \ -x: - -/* - * NLEAF(x) - * - * Declare a non-profiled leaf routine. - */ -#define NLEAF(x, fsize) \ - .align 3; \ - .globl x; \ - .ent x, 0; \ -x: ; \ - .frame sp, fsize, ra; \ - SETUP_GP /* * NON_LEAF(x) @@ -252,54 +201,8 @@ x: ; \ .globl x; \ .ent x, 0; \ x: ; \ + .cfi_startproc; \ .frame sp, fsize, retpc; \ SETUP_GP \ - MCOUNT - -/* - * NNON_LEAF(x) - * - * Declare a non-profiled non-leaf routine - * (a routine that makes other C calls). - */ -#define NNON_LEAF(x, fsize, retpc) \ - .align 3; \ - .globl x; \ - .ent x, 0; \ -x: ; \ - .frame sp, fsize, retpc \ - SETUP_GP - -/* - * END(x) - * - * Mark end of a procedure. - */ -#define END(x) \ - .end x - -/* - * Macros to panic and printf from assembly language. - */ -#define PANIC(msg) \ - LA a0, 9f; \ - jal panic; \ - nop ; \ - MSG(msg) - -#define PRINTF(msg) \ - LA a0, 9f; \ - jal printf; \ - nop ; \ - MSG(msg) - -#define MSG(msg) \ - .rdata; \ -9: .asciiz msg; \ - .text - -#define ASMSTR(str) \ - .asciiz str; \ - .align 3 #endif /* !_MIPS_ASM_H */ diff --git a/libc/arch-mips64/include/machine/signal.h b/libc/arch-mips64/include/machine/signal.h index f02ec0d22..b31715cce 100644 --- a/libc/arch-mips64/include/machine/signal.h +++ b/libc/arch-mips64/include/machine/signal.h @@ -37,8 +37,6 @@ #ifndef _MIPS_SIGNAL_H_ #define _MIPS_SIGNAL_H_ -#include - #define SC_REGMASK (0*REGSZ) #define SC_STATUS (1*REGSZ) #define SC_PC (2*REGSZ) diff --git a/libc/arch-mips64/string/memcpy.S b/libc/arch-mips64/string/memcpy.S index aabdfcfdc..dc91096bd 100644 --- a/libc/arch-mips64/string/memcpy.S +++ b/libc/arch-mips64/string/memcpy.S @@ -39,13 +39,13 @@ * Include files ************************************************************************/ -#include "machine/asm.h" +#include -/* +/* * This routine could be optimized for MIPS64. The current code only * uses MIPS32 instructions. - */ + */ #if defined(__MIPSEB__) # define LWHI lwl /* high part is left in big-endian */ # define SWHI swl /* high part is left in big-endian */ diff --git a/libc/arch-mips64/string/memset.S b/libc/arch-mips64/string/memset.S index a1c5055c4..3e630caf8 100644 --- a/libc/arch-mips64/string/memset.S +++ b/libc/arch-mips64/string/memset.S @@ -39,12 +39,12 @@ * Include files ************************************************************************/ -#include "machine/asm.h" +#include -/* +/* * This routine could be optimized for MIPS64. The current code only * uses MIPS32 instructions. - */ + */ #if defined(__MIPSEB__) # define SWHI swl /* high part is left in big-endian */ @@ -220,7 +220,7 @@ LEAF(memset,0) sw a1,-36(a0) nop nop # the extra nop instructions help to balance - nop # cycles needed for "store" + "fill" + "evict" + nop # cycles needed for "store" + "fill" + "evict" nop # For 64byte store there are needed 8 fill nop # and 8 evict cycles, i.e. at least 32 instr. nop @@ -320,4 +320,3 @@ END(memset) /************************************************************************ * Implementation : Static functions ************************************************************************/ - diff --git a/libc/arch-x86/bionic/__bionic_clone.S b/libc/arch-x86/bionic/__bionic_clone.S index 3823ecc17..e6ddaaad4 100644 --- a/libc/arch-x86/bionic/__bionic_clone.S +++ b/libc/arch-x86/bionic/__bionic_clone.S @@ -1,5 +1,4 @@ -#include -#include +#include // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg); ENTRY(__bionic_clone) diff --git a/libc/arch-x86/bionic/__get_sp.S b/libc/arch-x86/bionic/__get_sp.S index 0739d7983..31ec6bc34 100644 --- a/libc/arch-x86/bionic/__get_sp.S +++ b/libc/arch-x86/bionic/__get_sp.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include ENTRY(__get_sp) mov %esp, %eax diff --git a/libc/arch-x86/bionic/_setjmp.S b/libc/arch-x86/bionic/_setjmp.S index 9221138b8..0b256a2ad 100644 --- a/libc/arch-x86/bionic/_setjmp.S +++ b/libc/arch-x86/bionic/_setjmp.S @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include +#include /* * C library -- _setjmp, _longjmp diff --git a/libc/arch-x86/bionic/setjmp.S b/libc/arch-x86/bionic/setjmp.S index e149d425b..5b943118c 100644 --- a/libc/arch-x86/bionic/setjmp.S +++ b/libc/arch-x86/bionic/setjmp.S @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include +#include /* * C library -- setjmp, longjmp diff --git a/libc/arch-x86/bionic/sigsetjmp.S b/libc/arch-x86/bionic/sigsetjmp.S index 69494b413..7ef732ef2 100644 --- a/libc/arch-x86/bionic/sigsetjmp.S +++ b/libc/arch-x86/bionic/sigsetjmp.S @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include +#include ENTRY(sigsetjmp) movl 4(%esp),%ecx diff --git a/libc/arch-x86/include/machine/asm.h b/libc/arch-x86/include/machine/asm.h index 5ccf78f13..913e6c840 100644 --- a/libc/arch-x86/include/machine/asm.h +++ b/libc/arch-x86/include/machine/asm.h @@ -37,10 +37,6 @@ #ifndef _I386_ASM_H_ #define _I386_ASM_H_ -#ifdef _KERNEL_OPT -#include "opt_multiprocessor.h" -#endif - #ifdef PIC #define PIC_PROLOGUE \ pushl %ebx; \ @@ -61,27 +57,6 @@ #define PIC_GOTOFF(x) x #endif -#ifdef __ELF__ -# define _C_LABEL(x) x -#else -# ifdef __STDC__ -# define _C_LABEL(x) _ ## x -# else -# define _C_LABEL(x) _/**/x -# endif -#endif -#define _ASM_LABEL(x) x - -#define CVAROFF(x, y) _C_LABEL(x) + y - -#ifdef __STDC__ -# define __CONCAT(x,y) x ## y -# define __STRING(x) #x -#else -# define __CONCAT(x,y) x/**/y -# define __STRING(x) "x" -#endif - /* let kernels and others override entrypoint alignment */ #if !defined(_ALIGN_TEXT) && !defined(_KERNEL) # ifdef _STANDALONE @@ -93,126 +68,4 @@ # endif #endif -#define _ENTRY(x) \ - .text; _ALIGN_TEXT; .globl x; .type x,@function; x: .cfi_startproc; -#define _LABEL(x) \ - .globl x; x: - -#ifdef _KERNEL - -#define CPUVAR(off) %fs:__CONCAT(CPU_INFO_,off) - -/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */ -#ifdef __ELF__ -#ifdef __STDC__ -#define IDTVEC(name) \ - ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name: -#define IDTVEC_END(name) \ - .size X ## name, . - X ## name -#else -#define IDTVEC(name) \ - ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name: -#define IDTVEC_END(name) \ - .size X/**/name, . - X/**/name -#endif /* __STDC__ */ -#else -#ifdef __STDC__ -#define IDTVEC(name) \ - ALIGN_TEXT; .globl _X ## name; .type _X ## name,@function; _X ## name: -#define IDTVEC_END(name) \ - .size _X ## name, . - _X ## name -#else -#define IDTVEC(name) \ - ALIGN_TEXT; .globl _X/**/name; .type _X/**/name,@function; _X/**/name: -#define IDTVEC_END(name) \ - .size _X/**/name, . - _X/**/name -#endif /* __STDC__ */ -#endif /* __ELF__ */ - -#ifdef _STANDALONE -#define ALIGN_DATA .align 4 -#define ALIGN_TEXT .align 4 /* 4-byte boundaries */ -#define SUPERALIGN_TEXT .align 16 /* 15-byte boundaries */ -#elif defined __ELF__ -#define ALIGN_DATA .align 4 -#define ALIGN_TEXT .align 16 /* 16-byte boundaries */ -#define SUPERALIGN_TEXT .align 16 /* 16-byte boundaries */ -#else -#define ALIGN_DATA .align 2 -#define ALIGN_TEXT .align 4 /* 16-byte boundaries */ -#define SUPERALIGN_TEXT .align 4 /* 16-byte boundaries */ -#endif /* __ELF__ */ - -#define _ALIGN_TEXT ALIGN_TEXT - -#ifdef GPROF -#ifdef __ELF__ -#define MCOUNT_ASM call _C_LABEL(__mcount) -#else /* __ELF__ */ -#define MCOUNT_ASM call _C_LABEL(mcount) -#endif /* __ELF__ */ -#else /* GPROF */ -#define MCOUNT_ASM /* nothing */ -#endif /* GPROF */ - -#endif /* _KERNEL */ - - - -#ifdef GPROF -# ifdef __ELF__ -# define _PROF_PROLOGUE \ - pushl %ebp; movl %esp,%ebp; call PIC_PLT(__mcount); popl %ebp -# else -# define _PROF_PROLOGUE \ - pushl %ebp; movl %esp,%ebp; call PIC_PLT(mcount); popl %ebp -# endif -#else -# define _PROF_PROLOGUE -#endif - -#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE -#define NENTRY(y) _ENTRY(_C_LABEL(y)) -#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE -#define LABEL(y) _LABEL(_C_LABEL(y)) -#define END(y) .cfi_endproc; .size y, . - y - -#define ASMSTR .asciz - -#ifdef __ELF__ -#define RCSID(x) .pushsection ".ident"; .asciz x; .popsection -#else -#define RCSID(x) .text; .asciz x -#endif - -#ifdef NO_KERNEL_RCSIDS -#define __KERNEL_RCSID(_n, _s) /* nothing */ -#else -#define __KERNEL_RCSID(_n, _s) RCSID(_s) -#endif - -#ifdef __ELF__ -#define WEAK_ALIAS(alias,sym) \ - .weak alias; \ - alias = sym -#endif -/* - * STRONG_ALIAS: create a strong alias. - */ -#define STRONG_ALIAS(alias,sym) \ - .globl alias; \ - alias = sym - -#ifdef __STDC__ -#define WARN_REFERENCES(sym,msg) \ - .pushsection .gnu.warning. ## sym; \ - .ascii msg; \ - .popsection -#else -#define WARN_REFERENCES(sym,msg) \ - .pushsection .gnu.warning./**/sym; \ - .ascii msg; \ - .popsection -#endif /* __STDC__ */ - #endif /* !_I386_ASM_H_ */ diff --git a/libc/arch-x86/string/bcopy.S b/libc/arch-x86/string/bcopy.S index 40df1d026..f425c589e 100644 --- a/libc/arch-x86/string/bcopy.S +++ b/libc/arch-x86/string/bcopy.S @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include +#include /* * (ov)bcopy (src,dst,cnt) diff --git a/libc/arch-x86/string/memcmp.S b/libc/arch-x86/string/memcmp.S index 3b5053024..ef36b4f29 100644 --- a/libc/arch-x86/string/memcmp.S +++ b/libc/arch-x86/string/memcmp.S @@ -4,7 +4,7 @@ * Public domain. */ -#include +#include ENTRY(memcmp) pushl %edi diff --git a/libc/arch-x86/string/strcat.S b/libc/arch-x86/string/strcat.S index c75f38a54..49e8eeedd 100644 --- a/libc/arch-x86/string/strcat.S +++ b/libc/arch-x86/string/strcat.S @@ -4,7 +4,7 @@ * Public domain. */ -#include +#include #if defined(APIWARN) #APP diff --git a/libc/arch-x86/string/strcmp.S b/libc/arch-x86/string/strcmp.S index 5d3f4fc26..580f4d5a6 100644 --- a/libc/arch-x86/string/strcmp.S +++ b/libc/arch-x86/string/strcmp.S @@ -4,7 +4,7 @@ * Public domain. */ -#include +#include /* * NOTE: I've unrolled the loop eight times: large enough to make a diff --git a/libc/arch-x86/string/strncmp.S b/libc/arch-x86/string/strncmp.S index 664947328..9ba83a13b 100644 --- a/libc/arch-x86/string/strncmp.S +++ b/libc/arch-x86/string/strncmp.S @@ -4,7 +4,7 @@ * Public domain. */ -#include +#include /* * NOTE: I've unrolled the loop eight times: large enough to make a diff --git a/libc/arch-x86/string/swab.S b/libc/arch-x86/string/swab.S index 2f6cfb2a2..b44d13413 100644 --- a/libc/arch-x86/string/swab.S +++ b/libc/arch-x86/string/swab.S @@ -4,7 +4,7 @@ * Public domain. */ -#include +#include /* * On the i486, this code is negligibly faster than the code generated diff --git a/libc/arch-x86_64/bionic/__bionic_clone.S b/libc/arch-x86_64/bionic/__bionic_clone.S index 769201343..cf98d7661 100644 --- a/libc/arch-x86_64/bionic/__bionic_clone.S +++ b/libc/arch-x86_64/bionic/__bionic_clone.S @@ -26,8 +26,7 @@ * SUCH DAMAGE. */ -#include -#include +#include // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg); ENTRY(__bionic_clone) diff --git a/libc/arch-x86_64/bionic/__get_sp.S b/libc/arch-x86_64/bionic/__get_sp.S index 0c693b3ed..9cc18a962 100644 --- a/libc/arch-x86_64/bionic/__get_sp.S +++ b/libc/arch-x86_64/bionic/__get_sp.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include ENTRY(__get_sp) mov %rsp, %rax diff --git a/libc/arch-x86_64/bionic/__rt_sigreturn.S b/libc/arch-x86_64/bionic/__rt_sigreturn.S index e03bb88d3..eddceb15b 100644 --- a/libc/arch-x86_64/bionic/__rt_sigreturn.S +++ b/libc/arch-x86_64/bionic/__rt_sigreturn.S @@ -26,11 +26,9 @@ * SUCH DAMAGE. */ -#include -#include +#include -ENTRY(__rt_sigreturn) - .hidden _C_LABEL(__rt_sigreturn) // TODO: add an ENTRY_PRIVATE macro for x86_64. +ENTRY_PRIVATE(__rt_sigreturn) movl $__NR_rt_sigreturn, %eax syscall END(__rt_sigreturn) diff --git a/libc/arch-x86_64/bionic/_setjmp.S b/libc/arch-x86_64/bionic/_setjmp.S index e9b8dbbd5..c61703061 100644 --- a/libc/arch-x86_64/bionic/_setjmp.S +++ b/libc/arch-x86_64/bionic/_setjmp.S @@ -36,8 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ - -#include +#include #include /* diff --git a/libc/arch-x86_64/bionic/setjmp.S b/libc/arch-x86_64/bionic/setjmp.S index 3f4a43204..c81b5734c 100644 --- a/libc/arch-x86_64/bionic/setjmp.S +++ b/libc/arch-x86_64/bionic/setjmp.S @@ -36,8 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ - -#include +#include #include /* diff --git a/libc/arch-x86_64/bionic/sigsetjmp.S b/libc/arch-x86_64/bionic/sigsetjmp.S index 174222f38..718743f94 100644 --- a/libc/arch-x86_64/bionic/sigsetjmp.S +++ b/libc/arch-x86_64/bionic/sigsetjmp.S @@ -37,7 +37,7 @@ */ -#include +#include #include /* diff --git a/libc/arch-x86_64/include/machine/asm.h b/libc/arch-x86_64/include/machine/asm.h index 310b23000..0af6dae46 100644 --- a/libc/arch-x86_64/include/machine/asm.h +++ b/libc/arch-x86_64/include/machine/asm.h @@ -37,8 +37,6 @@ #ifndef _AMD64_ASM_H_ #define _AMD64_ASM_H_ -#ifdef __x86_64__ - #ifdef __PIC__ #define PIC_PLT(x) x@PLT #define PIC_GOT(x) x@GOTPCREL(%rip) @@ -47,19 +45,6 @@ #define PIC_GOT(x) x #endif -# define _C_LABEL(x) x -#define _ASM_LABEL(x) x - -#define CVAROFF(x,y) (_C_LABEL(x)+y)(%rip) - -#ifdef __STDC__ -# define __CONCAT(x,y) x ## y -# define __STRING(x) #x -#else -# define __CONCAT(x,y) x/**/y -# define __STRING(x) "x" -#endif - /* let kernels and others override entrypoint alignment */ #ifndef _ALIGN_TEXT # ifdef _STANDALONE @@ -69,78 +54,4 @@ # endif #endif -#define _ENTRY(x) \ - .text; _ALIGN_TEXT; .globl x; .type x,@function; x: .cfi_startproc; -#define _LABEL(x) \ - .globl x; x: - -#ifdef _KERNEL -/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */ -#ifdef __STDC__ -#define IDTVEC(name) \ - ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name: -#define IDTVEC_END(name) \ - .size X ## name, . - X ## name -#else -#define IDTVEC(name) \ - ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name: -#define IDTVEC_END(name) \ - .size X/**/name, . - X/**/name -#endif /* __STDC__ */ -#endif /* _KERNEL */ - -#ifdef __STDC__ -#define CPUVAR(off) %gs:CPU_INFO_ ## off -#else -#define CPUVAR(off) %gs:CPU_INFO_/**/off -#endif - - -#ifdef GPROF -# define _PROF_PROLOGUE \ - pushq %rbp; leaq (%rsp),%rbp; call PIC_PLT(__mcount); popq %rbp -#else -# define _PROF_PROLOGUE -#endif - -#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE -#define NENTRY(y) _ENTRY(_C_LABEL(y)) -#define ALTENTRY(x) NENTRY(x) -#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE -#define LABEL(y) _LABEL(_C_LABEL(y)) -#define END(y) .cfi_endproc; .size y, . - y - -#define ASMSTR .asciz - -#define RCSID(x) .pushsection ".ident"; .asciz x; .popsection - -#define WEAK_ALIAS(alias,sym) \ - .weak alias; \ - alias = sym - -/* - * STRONG_ALIAS: create a strong alias. - */ -#define STRONG_ALIAS(alias,sym) \ - .globl alias; \ - alias = sym - -#ifdef __STDC__ -#define WARN_REFERENCES(sym,msg) \ - .pushsection .gnu.warning. ## sym; \ - .ascii msg; \ - .popsection -#else -#define WARN_REFERENCES(sym,msg) \ - .pushsection .gnu.warning./**/sym; \ - .ascii msg; \ - .popsection -#endif /* __STDC__ */ - -#else /* __x86_64__ */ - -#include - -#endif /* __x86_64__ */ - #endif /* !_AMD64_ASM_H_ */ diff --git a/libc/private/bionic_asm.h b/libc/private/bionic_asm.h index be22b75d0..7c2686f38 100644 --- a/libc/private/bionic_asm.h +++ b/libc/private/bionic_asm.h @@ -29,20 +29,32 @@ #ifndef _PRIVATE_BIONIC_ASM_H_ #define _PRIVATE_BIONIC_ASM_H_ -#include - #include /* For system call numbers. */ #define MAX_ERRNO 4095 /* For recognizing system call error returns. */ -#if __mips__ -/* mips/mips64 don't have ENTRY like the others. */ -#define ENTRY(f) .text; .globl f; .align 4; .type f, @function; .ent f; f: .cfi_startproc -/* mips/mips64 do have END, but we want a better one, more like the others. */ -#undef END -#define END(f) .cfi_endproc; .size f, .-f; .end f -#endif +#define __bionic_asm_custom_entry(f) +#define __bionic_asm_custom_end(f) +#define __bionic_asm_function_type @function + +#include + +#define ENTRY(f) \ + .text; \ + .globl f; \ + _ALIGN_TEXT; \ + .type f, __bionic_asm_function_type; \ + f: \ + __bionic_asm_custom_entry(f); \ + .cfi_startproc \ + +#define END(f) \ + .cfi_endproc; \ + .size f, .-f; \ + __bionic_asm_custom_end(f) \ -/* TODO: add ENTRY_PRIVATE. */ -/* TODO: add ASM_ALIAS macro. */ +/* Like ENTRY, but with hidden visibility. */ +#define ENTRY_PRIVATE(f) \ + ENTRY(f); \ + .hidden f \ #endif /* _PRIVATE_BIONIC_ASM_H_ */ diff --git a/linker/arch/arm64/begin.S b/linker/arch/arm64/begin.S index 55618b7f3..c96ede787 100644 --- a/linker/arch/arm64/begin.S +++ b/linker/arch/arm64/begin.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include ENTRY(_start) mov x0, sp diff --git a/linker/arch/mips64/begin.S b/linker/arch/mips64/begin.S index 9a85925cf..9e741c022 100644 --- a/linker/arch/mips64/begin.S +++ b/linker/arch/mips64/begin.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include #if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32) #define ELF_DYNSZ 8 diff --git a/linker/arch/x86_64/begin.S b/linker/arch/x86_64/begin.S index 9ecad1aee..aff46600d 100644 --- a/linker/arch/x86_64/begin.S +++ b/linker/arch/x86_64/begin.S @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include +#include ENTRY(_start) /* Pass elfdata to __linker_init. */ -- 2.11.0