summaryrefslogtreecommitdiff
path: root/lib/csu/sparc
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2004-01-08 14:59:16 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2004-01-08 14:59:16 +0000
commit58b037aa2a117fe4c474549ee14e4c6bfbba585d (patch)
treef5d8f4fd6ca0aa5131b9bc178009e1cae0a1bae3 /lib/csu/sparc
parent6e07118b4073b7f92810dfdf7b6a0ea317d3ae5f (diff)
__init/__fini handling on ELF has not been correct. It is supposed to
be a section which code stubs (branches) can be added to initialize/destructor This adds MD stubs to allow this to operate as expected. should fix wine and behave according to ELF specs. ok miod@
Diffstat (limited to 'lib/csu/sparc')
-rw-r--r--lib/csu/sparc/Makefile4
-rw-r--r--lib/csu/sparc/md_init.h59
2 files changed, 61 insertions, 2 deletions
diff --git a/lib/csu/sparc/Makefile b/lib/csu/sparc/Makefile
index 4da9d6b939d..541b3114020 100644
--- a/lib/csu/sparc/Makefile
+++ b/lib/csu/sparc/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.7 2003/05/30 19:03:24 drahn Exp $
+# $OpenBSD: Makefile,v 1.8 2004/01/08 14:59:15 drahn Exp $
# from: @(#)Makefile 5.5 (Berkeley) 5/21/91
CFLAGS+= -DLIBC_SCCS
@@ -7,7 +7,7 @@ SRCS= crt0.c crtbegin.c crtbeginS.c crtend.c crtendS.c
ELFDIR= ${.CURDIR}/../common_elf
.PATH: ${ELFDIR}
-CFLAGS+= -I${ELFDIR}
+CFLAGS+= -I${ELFDIR} -I${.CURDIR}
PICFLAG?=-fPIC
diff --git a/lib/csu/sparc/md_init.h b/lib/csu/sparc/md_init.h
new file mode 100644
index 00000000000..30c0116ede0
--- /dev/null
+++ b/lib/csu/sparc/md_init.h
@@ -0,0 +1,59 @@
+/* $OpenBSD: md_init.h,v 1.1 2004/01/08 14:59:15 drahn Exp $ */
+
+/*-
+ * Copyright (c) 2001 Ross Harvey
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define MD_SECT_CALL_FUNC(section, func) \
+ __asm (".section "#section", \"ax\" \n" \
+ " call " #func ", 0 \n" \
+ " nop \n" \
+ " .previous")
+
+#define MD_SECTION_PROLOGUE(sect, entry_pt) \
+ __asm ( \
+ ".section "#sect",\"ax\",@progbits \n" \
+ " .globl " #entry_pt " \n" \
+ " .type " #entry_pt ",@function \n" \
+ #entry_pt": \n" \
+ " save %sp, -96, %sp \n" \
+ " .align 4 \n" \
+ " /* fall thru */ \n" \
+ " .previous")
+
+
+#define MD_SECTION_EPILOGUE(sect) \
+ __asm ( \
+ ".section "#sect",\"ax\",@progbits \n" \
+ " ret \n" \
+ " restore \n" \
+ " .previous")