summaryrefslogtreecommitdiff
path: root/libc/sysdeps
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2006-11-04 19:53:15 +0000
committerEric Andersen <andersen@codepoet.org>2006-11-04 19:53:15 +0000
commitc4ae8409ba034fcd7092d891381c3711e62d5b25 (patch)
tree633ad72138b00f5a0a0337bfb6320d4c7a7c1777 /libc/sysdeps
parentcb12600bc59ec9211ecb5be3083e66f7c6c6d9ef (diff)
mips64 patch from Atsushi Nemoto:
miscellaneous asm routines
Diffstat (limited to 'libc/sysdeps')
-rw-r--r--libc/sysdeps/linux/mips/clone.S32
-rw-r--r--libc/sysdeps/linux/mips/crt1.S26
-rw-r--r--libc/sysdeps/linux/mips/crti.S108
-rw-r--r--libc/sysdeps/linux/mips/crtn.S100
4 files changed, 255 insertions, 11 deletions
diff --git a/libc/sysdeps/linux/mips/clone.S b/libc/sysdeps/linux/mips/clone.S
index 7e3838a35..716cd993f 100644
--- a/libc/sysdeps/linux/mips/clone.S
+++ b/libc/sysdeps/linux/mips/clone.S
@@ -38,11 +38,16 @@
clone:
.frame sp, 4*SZREG, sp
#ifdef __PIC__
+#if _MIPS_SIM == _MIPS_SIM_ABI32
.set noreorder
.cpload $25
.set reorder
subu sp,32
.cprestore 16
+#else /* N32 */
+ PTR_SUBU sp,32 /* fn, arg, gp, pad */
+ .cpsetup $25, 16, clone
+#endif /* N32 */
#else
subu sp,32
#endif
@@ -53,9 +58,12 @@ clone:
beqz a0,error /* No NULL function pointers. */
beqz a1,error /* No NULL stack pointers. */
- subu a1,32 /* Reserve argument save space. */
- sw a0,0(a1) /* Save function pointer. */
- sw a3,4(a1) /* Save argument pointer. */
+#if _MIPS_SIM != _MIPS_SIM_ABI32
+ and a1,~(16-1) /* force alignment */
+#endif
+ PTR_SUBU a1,32 /* Reserve argument save space. */
+ PTR_S a0,0(a1) /* Save function pointer. */
+ PTR_S a3,PTRSIZE(a1) /* Save argument pointer. */
/* Do the system call */
@@ -67,19 +75,25 @@ clone:
beqz v0,__thread_start
/* Successful return from the parent */
- addiu sp,32
+#if _MIPS_SIM != _MIPS_SIM_ABI32
+ .cpreturn
+#endif
+ PTR_ADDU sp,32
j $31 ; nop
/* Something bad happened -- no child created */
error:
- addiu sp,32
+#if _MIPS_SIM != _MIPS_SIM_ABI32
+ .cpreturn
+#endif
+ PTR_ADDU sp,32
/* uClibc change -- start */
move a0,v0 /* Pass return val to C function. */
/* uClibc change -- stop */
#ifdef __PIC__
- la t9,__syscall_error
+ PTR_LA t9,__syscall_error
jr t9
#else
j __syscall_error
@@ -95,12 +109,14 @@ error:
.ent __thread_start, 0;
__thread_start:
+#if _MIPS_SIM == _MIPS_SIM_ABI32
/* cp is already loaded. */
.cprestore 16
+#endif
/* The stackframe has been created on entry of clone(). */
/* Restore the arg for user's function. */
- lw t9,0(sp) /* Function pointer. */
- lw a0,4(sp) /* Argument pointer. */
+ PTR_L t9,0(sp) /* Function pointer. */
+ PTR_L a0,PTRSIZE(sp) /* Argument pointer. */
/* Call the user's function. */
jal t9
diff --git a/libc/sysdeps/linux/mips/crt1.S b/libc/sysdeps/linux/mips/crt1.S
index 35dc8c42e..2e38cf07c 100644
--- a/libc/sysdeps/linux/mips/crt1.S
+++ b/libc/sysdeps/linux/mips/crt1.S
@@ -37,6 +37,7 @@
#include <sys/regdef.h>
+#include <sys/asm.h>
#include <features.h>
@@ -83,6 +84,7 @@
__start:
#ifdef __PIC__
+#if _MIPS_SIM == _MIPS_SIM_ABI32
.set noreorder
move $0, $31 /* Save old ra. */
bal 10f /* Find addr of cpload. */
@@ -92,18 +94,29 @@ __start:
move $31, $0
.set reorder
#else
+ move $0, $31; /* Save old ra. */
+ .set noreorder
+ bal 10f /* Find addr of .cpsetup. */
+ nop
+10:
+ .set reorder
+ .cpsetup $31, $25, 10b
+ move $31, $0
+#endif
+#else
la $28, _gp /* Setup GP correctly if we're non-PIC. */
move $31, $0
#endif
- la $4, main /* main */
- lw $5, 0($29) /* argc */
- addiu $6, $29, 4 /* argv */
+ PTR_LA $4, main /* main */
+ PTR_L $5, 0($29) /* argc */
+ PTR_ADDIU $6, $29, PTRSIZE /* argv */
/* Allocate space on the stack for seven arguments and
* make sure the stack is aligned to double words (8 bytes) */
+#if _MIPS_SIM == _MIPS_SIM_ABI32
and $29, -2 * 4
subu $29, 32
la $7, _init /* init */
@@ -111,6 +124,13 @@ __start:
sw $8, 16($29) /* fini */
sw $2, 20($29) /* rtld_fini */
sw $29, 24($29) /* stack_end */
+#else
+ and $29, -2 * PTRSIZE
+ PTR_LA $7, _init /* init */
+ PTR_LA $8, _fini /* fini */
+ move $9, $2 /* rtld_fini */
+ move $10, $29 /* stack_end */
+#endif
jal __uClibc_main
hlt:
/* Crash if somehow `__uClibc_main' returns anyway. */
diff --git a/libc/sysdeps/linux/mips/crti.S b/libc/sysdeps/linux/mips/crti.S
index b0d523b2f..9311a735f 100644
--- a/libc/sysdeps/linux/mips/crti.S
+++ b/libc/sysdeps/linux/mips/crti.S
@@ -1,3 +1,5 @@
+#include "sgidefs.h"
+#if _MIPS_SIM == _MIPS_SIM_ABI32
.file 1 "initfini.c"
.section .mdebug.abi32
.previous
@@ -48,3 +50,109 @@ _fini:
.end _fini
.ident "GCC: (GNU) 3.3.2"
+#elif _MIPS_SIM == _MIPS_SIM_NABI32
+ .file 1 "initfini.c"
+ .section .mdebug.abiN32
+ .previous
+ .abicalls
+#APP
+
+ .section .init
+#NO_APP
+ .align 2
+ .align 3
+ .globl _init
+ .ent _init
+ .type _init, @function
+_init:
+ .frame $sp,16,$31 # vars= 0, regs= 2/0, args= 0, gp= 0
+ .mask 0x90000000,-8
+ .fmask 0x00000000,0
+ addiu $sp,$sp,-16
+ sd $28,0($sp)
+ lui $28,%hi(%neg(%gp_rel(_init)))
+ addu $28,$28,$25
+ addiu $28,$28,%lo(%neg(%gp_rel(_init)))
+ sd $31,8($sp)
+#APP
+
+ .align 3
+ .end _init
+
+ .section .fini
+#NO_APP
+ .align 2
+ .align 3
+ .globl _fini
+ .ent _fini
+ .type _fini, @function
+_fini:
+ .frame $sp,16,$31 # vars= 0, regs= 2/0, args= 0, gp= 0
+ .mask 0x90000000,-8
+ .fmask 0x00000000,0
+ addiu $sp,$sp,-16
+ sd $28,0($sp)
+ lui $28,%hi(%neg(%gp_rel(_fini)))
+ addu $28,$28,$25
+ addiu $28,$28,%lo(%neg(%gp_rel(_fini)))
+ sd $31,8($sp)
+#APP
+ .align 3
+ .end _fini
+
+ .ident "GCC: (GNU) 3.4.3"
+#else /* N64 */
+ .file 1 "initfini.c"
+ .section .mdebug.abi64
+ .previous
+ .abicalls
+#APP
+
+
+ .section .init
+#NO_APP
+ .align 2
+ .globl _init
+ .ent _init
+ .type _init, @function
+_init:
+ .frame $sp,32,$31 # vars= 0, regs= 2/0, args= 0, extra= 16
+ .mask 0x90000000,-8
+ .fmask 0x00000000,0
+ dsubu $sp,$sp,32
+ sd $31,24($sp)
+ sd $28,16($sp)
+ .set noat
+ lui $1,%hi(%neg(%gp_rel(_init)))
+ addiu $1,$1,%lo(%neg(%gp_rel(_init)))
+ daddu $gp,$1,$25
+ .set at
+#APP
+
+ .align 2
+ .end _init
+
+ .section .fini
+#NO_APP
+ .align 2
+ .globl _fini
+ .ent _fini
+ .type _fini, @function
+_fini:
+ .frame $sp,32,$31 # vars= 0, regs= 2/0, args= 0, extra= 16
+ .mask 0x90000000,-8
+ .fmask 0x00000000,0
+ dsubu $sp,$sp,32
+ sd $31,24($sp)
+ sd $28,16($sp)
+ .set noat
+ lui $1,%hi(%neg(%gp_rel(_fini)))
+ addiu $1,$1,%lo(%neg(%gp_rel(_fini)))
+ daddu $gp,$1,$25
+ .set at
+#APP
+ .align 2
+ .end _fini
+
+ .ident "GCC: (GNU) 3.3.2"
+#endif /* N64 */
diff --git a/libc/sysdeps/linux/mips/crtn.S b/libc/sysdeps/linux/mips/crtn.S
index 7a5e4db6e..cedd593f0 100644
--- a/libc/sysdeps/linux/mips/crtn.S
+++ b/libc/sysdeps/linux/mips/crtn.S
@@ -1,3 +1,5 @@
+#include "sgidefs.h"
+#if _MIPS_SIM == _MIPS_SIM_ABI32
.file 1 "initfini.c"
.section .mdebug.abi32
.previous
@@ -43,3 +45,101 @@
#APP
.ident "GCC: (GNU) 3.3.2"
+#elif _MIPS_SIM == _MIPS_SIM_NABI32
+ .file 1 "initfini.c"
+ .section .mdebug.abiN32
+ .previous
+ .abicalls
+#APP
+
+ .section .init
+#NO_APP
+ .align 2
+ .align 3
+ .globl _init
+ .ent _init
+ .type _init, @function
+#NO_APP
+ ld $31,8($sp)
+ ld $28,0($sp)
+ .set noreorder
+ .set nomacro
+ j $31
+ addiu $sp,$sp,16
+ .set macro
+ .set reorder
+
+ .end _init
+#APP
+
+ .section .fini
+#NO_APP
+ .align 2
+ .align 3
+ .globl _fini
+ .ent _fini
+ .type _fini, @function
+#NO_APP
+ ld $31,8($sp)
+ ld $28,0($sp)
+ .set noreorder
+ .set nomacro
+ j $31
+ addiu $sp,$sp,16
+ .set macro
+ .set reorder
+
+ .end _fini
+#APP
+
+ .ident "GCC: (GNU) 3.4.3"
+#else /* N64 */
+ .file 1 "initfini.c"
+ .section .mdebug.abi64
+ .previous
+ .abicalls
+#APP
+
+
+ .section .init
+#NO_APP
+ .align 2
+ .globl _init
+ .ent _init
+ .type _init, @function
+#NO_APP
+ ld $31,24($sp)
+ ld $28,16($sp)
+ #nop
+ .set noreorder
+ .set nomacro
+ j $31
+ daddu $sp,$sp,32
+ .set macro
+ .set reorder
+
+ .end _init
+#APP
+
+ .section .fini
+#NO_APP
+ .align 2
+ .globl _fini
+ .ent _fini
+ .type _fini, @function
+#NO_APP
+ ld $31,24($sp)
+ ld $28,16($sp)
+ #nop
+ .set noreorder
+ .set nomacro
+ j $31
+ daddu $sp,$sp,32
+ .set macro
+ .set reorder
+
+ .end _fini
+#APP
+
+ .ident "GCC: (GNU) 3.3.2"
+#endif /* N64 */