summaryrefslogtreecommitdiff
path: root/lib/csu/mips64
diff options
context:
space:
mode:
authorPer Fogelstrom <pefo@cvs.openbsd.org>2004-09-09 17:45:27 +0000
committerPer Fogelstrom <pefo@cvs.openbsd.org>2004-09-09 17:45:27 +0000
commit1118b9d82eb306cb001d4e43cdb991c4b60339bd (patch)
tree7a7bd508f7725db6f556696bd8f6281c4609a721 /lib/csu/mips64
parente91cc6723df7f95e8a014cdea13b5d2f3629e82d (diff)
Shared libs now works. Changes here for ABI64.
Diffstat (limited to 'lib/csu/mips64')
-rw-r--r--lib/csu/mips64/crt0.c12
-rw-r--r--lib/csu/mips64/md_init.h77
2 files changed, 59 insertions, 30 deletions
diff --git a/lib/csu/mips64/crt0.c b/lib/csu/mips64/crt0.c
index e9aff93e4e2..8e40d40676f 100644
--- a/lib/csu/mips64/crt0.c
+++ b/lib/csu/mips64/crt0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crt0.c,v 1.2 2004/08/23 18:58:37 pvalchev Exp $ */
+/* $OpenBSD: crt0.c,v 1.3 2004/09/09 17:45:26 pefo Exp $ */
/* $NetBSD: crt0.c,v 1.7 1995/06/03 13:16:15 pk Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: crt0.c,v 1.2 2004/08/23 18:58:37 pvalchev Exp $";
+static char rcsid[] = "$OpenBSD: crt0.c,v 1.3 2004/09/09 17:45:26 pefo Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -71,7 +71,7 @@ void
__start()
{
struct kframe {
- int kargc;
+ long kargc;
char *kargv[1]; /* size depends on kargc */
char kargstr[1]; /* size varies */
char kenvstr[1]; /* size varies */
@@ -87,7 +87,11 @@ __start()
asm(" la $28,_gp");
asm(" addiu %0,$29,32" : "=r" (kfp));
#else
- asm(" addiu %0,$29,48" : "=r" (kfp));
+#ifdef __LP64__
+ asm(" addiu %0,$29,80" : "=r" (kfp));
+#else
+ asm(" addiu %0,$29,56" : "=r" (kfp));
+#endif
#endif
/* just above the saved frame pointer
kfp = (struct kframe *) (&param-1);*/
diff --git a/lib/csu/mips64/md_init.h b/lib/csu/mips64/md_init.h
index 274da327711..3270bbd6932 100644
--- a/lib/csu/mips64/md_init.h
+++ b/lib/csu/mips64/md_init.h
@@ -1,7 +1,8 @@
-/* $OpenBSD: md_init.h,v 1.1 2004/08/06 22:21:16 pefo Exp $ */
+/* $OpenBSD: md_init.h,v 1.2 2004/09/09 17:45:26 pefo Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
+ * Copyright (c) 2001 Simon Burge
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,32 +34,56 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if 0
-#define MD_SECT_CALL_FUNC(section, func) \
- __asm (".section "#section", \"ax\"\n" \
- " bl " #func "\n" \
- " .previous")
+#define ra "$31"
-#define MD_SECTION_PROLOGUE(sect, entry_pt) \
- __asm ( \
- ".section "#sect",\"ax\",@progbits \n" \
- " .globl " #entry_pt " \n" \
- " .type " #entry_pt ",@function \n" \
- " .align 4 \n" \
- #entry_pt": \n" \
- " stwu %r1,-16(%r1) \n" \
- " mflr %r0 \n" \
- " stw %r0,12(%r1) \n" \
- " /* fall thru */ \n" \
- " .previous")
+/*
+ * Allocate 32 bytes for the stack frame. Store GP at SP+16 (since
+ * this is where code generated by the compiler for fallthru processing
+ * expects it to be), and the RA at SP+24.
+ */
+/* this is gross... */
-#define MD_SECTION_EPILOGUE(sect) \
- __asm ( \
- ".section "#sect",\"ax\",@progbits \n" \
- " lwz %r0,12(%r1) \n" \
- " mtlr %r0 \n" \
- " addi %r1,%r1,16 \n" \
- " blr \n" \
- " .previous")
+#ifdef __ABICALLS__
+#define MD_FUNCTION_PROLOGUE(entry_pt) \
+ " .frame $sp,32,$31 \n" \
+ " .set reorder \n" \
+ " dsubu $sp,$sp,32 \n" \
+ " .cpsetup $25, 16, "#entry_pt" \n" \
+ " sd "ra",24($sp) \n"
+#else
+#define MD_FUNCTION_PROLOGUE(entry_pt) \
+ " dsubu $sp,$sp,32 \n" \
+ " sd "ra",24($sp) \n"
#endif
+
+
+#define MD_SECTION_PROLOGUE(sect, entry_pt) \
+ __asm ( \
+ ".section "#sect",\"ax\",@progbits \n" \
+ ".align 2 \n" \
+ ".globl "#entry_pt" \n" \
+ ".type "#entry_pt"@function \n" \
+ ".ent "#entry_pt" \n" \
+ #entry_pt": \n" \
+ MD_FUNCTION_PROLOGUE(entry_pt) \
+ " /* fall thru */ \n" \
+ ".previous")
+
+#define MD_SECTION_EPILOGUE(sect) \
+ __asm ( \
+ ".section "#sect",\"ax\",@progbits \n" \
+ " ld "ra",24($sp) \n" \
+ " # next should have been a .cpreturn \n" \
+ " ld $gp,16($sp) \n" \
+ " .set noreorder \n" \
+ " j "ra" \n" \
+ " daddu $sp,$sp,32 \n" \
+ " .set reorder \n" \
+ ".previous")
+
+#define MD_SECT_CALL_FUNC(section, func) \
+ __asm (".section "#section", \"ax\" \n" \
+ " jal " #func " \n" \
+ ".previous")
+