summaryrefslogtreecommitdiff
path: root/lib/csu/mips64
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2013-12-23 18:16:40 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2013-12-23 18:16:40 +0000
commit1a06f4cebaf6172b66466510fd15f0dd2177cb5c (patch)
tree14ff9a4deeec341fc46b5eca593f60e248b15327 /lib/csu/mips64
parent0c5de94ca6548a0f863c4e0084679da410c4f160 (diff)
Add assembly code to set up the arguments for the common C startup code. This
means we no longer rely on how the C compiler sets up the initial stack frame and allows us to get rid of MD_NO_CLEANUP. ok deraadt@, guenther@
Diffstat (limited to 'lib/csu/mips64')
-rw-r--r--lib/csu/mips64/md_init.h48
1 files changed, 19 insertions, 29 deletions
diff --git a/lib/csu/mips64/md_init.h b/lib/csu/mips64/md_init.h
index 464c4bafef7..66c7c7fa7dc 100644
--- a/lib/csu/mips64/md_init.h
+++ b/lib/csu/mips64/md_init.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: md_init.h,v 1.4 2013/12/04 00:20:31 deraadt Exp $ */
+/* $OpenBSD: md_init.h,v 1.5 2013/12/23 18:16:39 kettenis Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -87,6 +87,23 @@
" jal " #func " \n" \
".previous")
+#define MD_CRT0_START \
+ __asm( \
+ ".text \n" \
+ " .align 3 \n" \
+ " .globl __start \n" \
+ " .ent __start \n" \
+ " .type __start, @function \n" \
+ "__start: \n" \
+ " lui $gp, %hi(%neg(%gp_rel(__start))) \n" \
+ " addiu $gp, $gp, %lo(%neg(%gp_rel(__start))) \n" \
+ " daddu $gp, $gp, $t9 \n" \
+ " move $a0, $sp \n" \
+ " move $a1, $v0 \n" \
+ " dla $t9, ___start \n" \
+ " jr $t9 \n" \
+ " .end __start \n" \
+ " .previous")
struct kframe {
long kargc;
@@ -95,38 +112,11 @@ struct kframe {
char kenvstr[1]; /* size varies */
};
-#define MD_START __start
-#define MD_START_ARGS void
-
-/*
- * XXX no cleanup() callback passed to __start yet. Need to pull
- * it from v0 in ASM?
- */
-#define MD_NO_CLEANUP
-
-
-/*
- * Do GP register setup and find the kframe struct. Differs depending
- * on shared lib stuff or not.
- * XXX just above the saved frame pointer?
- * kfp = (struct kframe *) (&param-1);
- */
-#if defined(_NO_ABICALLS)
-#define SETUP_KFP(kfp) \
- asm(" dla $28,_gp \n" \
- " daddiu %0,$29,32" : "=r" (kfp))
-#else
-#define SETUP_KFP(kfp) \
- asm(" daddiu %0,$29,48" : "=r" (kfp))
-#endif
-
-
+#define MD_START_ARGS struct kframe *kfp, void (*cleanup)(void)
#define MD_START_SETUP \
- struct kframe *kfp; \
char **argv, **envp; \
int argc; \
\
- SETUP_KFP(kfp); \
argc = kfp->kargc; \
argv = &kfp->kargv[0]; \
environ = envp = argv + argc + 1;