Module Name:    src
Committed By:   matt
Date:           Thu Jun 27 21:24:39 UTC 2013

Modified Files:
        src/lib/csu/arch/arm: Makefile.inc
        src/lib/csu/arch/earm: Makefile.inc
        src/lib/csu/arch/powerpc: Makefile.inc crtend.S
        src/lib/csu/common: Makefile.inc crtbegin.c
Added Files:
        src/lib/csu/arch/arm: crtbegin.h
        src/lib/csu/arch/earm: crtbegin.h
        src/lib/csu/arch/powerpc: crtbegin.h
        src/lib/csu/arch/vax: crtbegin.h
Removed Files:
        src/lib/csu/arch/arm: crtbegin.S
        src/lib/csu/arch/earm: crtbegin.S
        src/lib/csu/arch/powerpc: crtbegin.S

Log Message:
Switch arm, earm, powerpc to use crtbegin.c
Use -fpie for crtbegin.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/csu/arch/arm/Makefile.inc
cvs rdiff -u -r1.6 -r0 src/lib/csu/arch/arm/crtbegin.S
cvs rdiff -u -r0 -r1.1 src/lib/csu/arch/arm/crtbegin.h
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/earm/Makefile.inc
cvs rdiff -u -r1.4 -r0 src/lib/csu/arch/earm/crtbegin.S
cvs rdiff -u -r0 -r1.1 src/lib/csu/arch/earm/crtbegin.h
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/powerpc/Makefile.inc \
    src/lib/csu/arch/powerpc/crtend.S
cvs rdiff -u -r1.2 -r0 src/lib/csu/arch/powerpc/crtbegin.S
cvs rdiff -u -r0 -r1.1 src/lib/csu/arch/powerpc/crtbegin.h
cvs rdiff -u -r0 -r1.1 src/lib/csu/arch/vax/crtbegin.h
cvs rdiff -u -r1.11 -r1.12 src/lib/csu/common/Makefile.inc
cvs rdiff -u -r1.2 -r1.3 src/lib/csu/common/crtbegin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/csu/arch/arm/Makefile.inc
diff -u src/lib/csu/arch/arm/Makefile.inc:1.5 src/lib/csu/arch/arm/Makefile.inc:1.6
--- src/lib/csu/arch/arm/Makefile.inc:1.5	Mon Apr 29 07:21:59 2013
+++ src/lib/csu/arch/arm/Makefile.inc	Thu Jun 27 21:24:39 2013
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile.inc,v 1.5 2013/04/29 07:21:59 skrll Exp $
+# $NetBSD: Makefile.inc,v 1.6 2013/06/27 21:24:39 matt Exp $
 
-CPPFLAGS+=	-DELFSIZE=32
+CPPFLAGS+=	-I${ARCHDIR}
 .if (!empty(CPUFLAGS) && ${CPUFLAGS:M-mabi=aapcs*} != "")
 CPPFLAGS+=      -DHAVE_INITFINI_ARRAY
 .endif

Index: src/lib/csu/arch/earm/Makefile.inc
diff -u src/lib/csu/arch/earm/Makefile.inc:1.1 src/lib/csu/arch/earm/Makefile.inc:1.2
--- src/lib/csu/arch/earm/Makefile.inc:1.1	Mon Aug 13 02:49:04 2012
+++ src/lib/csu/arch/earm/Makefile.inc	Thu Jun 27 21:24:39 2013
@@ -1,5 +1,5 @@
-# $NetBSD: Makefile.inc,v 1.1 2012/08/13 02:49:04 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2013/06/27 21:24:39 matt Exp $
 
-CPPFLAGS+=	-DELFSIZE=32
+CPPFLAGS+=	-I${ARCHDIR}
 CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 

Index: src/lib/csu/arch/powerpc/Makefile.inc
diff -u src/lib/csu/arch/powerpc/Makefile.inc:1.1 src/lib/csu/arch/powerpc/Makefile.inc:1.2
--- src/lib/csu/arch/powerpc/Makefile.inc:1.1	Tue Feb  8 02:02:25 2011
+++ src/lib/csu/arch/powerpc/Makefile.inc	Thu Jun 27 21:24:39 2013
@@ -1,5 +1,3 @@
-# $NetBSD: Makefile.inc,v 1.1 2011/02/08 02:02:25 matt Exp $
-
-CPPFLAGS+=	-DELFSIZE=32
-
+# $NetBSD: Makefile.inc,v 1.2 2013/06/27 21:24:39 matt Exp $
 
+CPPFLAGS+=	-I${ARCHDIR}
Index: src/lib/csu/arch/powerpc/crtend.S
diff -u src/lib/csu/arch/powerpc/crtend.S:1.1 src/lib/csu/arch/powerpc/crtend.S:1.2
--- src/lib/csu/arch/powerpc/crtend.S:1.1	Tue Feb  8 02:02:25 2011
+++ src/lib/csu/arch/powerpc/crtend.S	Thu Jun 27 21:24:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: crtend.S,v 1.1 2011/02/08 02:02:25 matt Exp $	*/
+/*	$NetBSD: crtend.S,v 1.2 2013/06/27 21:24:39 matt Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -30,7 +30,7 @@
 
 #include <powerpc/asm.h>
 
-RCSID("$NetBSD: crtend.S,v 1.1 2011/02/08 02:02:25 matt Exp $")
+RCSID("$NetBSD: crtend.S,v 1.2 2013/06/27 21:24:39 matt Exp $")
 
 	.section	.ctors, "aw", @progbits
 	.p2align 2
@@ -41,6 +41,9 @@ __CTOR_LIST_END__:
 
 	.section	.dtors, "aw", @progbits
 	.p2align 2
+	.global		__DTOR_LIST_END__
+	.hidden 	__DTOR_LIST_END__
+__DTOR_LIST_END__:
 	.long 0
 
 	.section	.eh_frame, "a", @progbits

Index: src/lib/csu/common/Makefile.inc
diff -u src/lib/csu/common/Makefile.inc:1.11 src/lib/csu/common/Makefile.inc:1.12
--- src/lib/csu/common/Makefile.inc:1.11	Thu Jun 27 03:37:21 2013
+++ src/lib/csu/common/Makefile.inc	Thu Jun 27 21:24:39 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.11 2013/06/27 03:37:21 matt Exp $
+#	$NetBSD: Makefile.inc,v 1.12 2013/06/27 21:24:39 matt Exp $
 
 .include <bsd.own.mk>
 
@@ -19,7 +19,7 @@ crtbegin.o: crtbegin.S
 .else
 crtbegin.o: crtbegin.c crtbegin.h
 	${_MKTARGET_COMPILE}
-	${COMPILE.c} ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
+	${COMPILE.c} -fpie ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
 .endif
 	${LD} -x -r -o ${.TARGET} ${.TARGET}.o
 	rm -f ${.TARGET}.o

Index: src/lib/csu/common/crtbegin.c
diff -u src/lib/csu/common/crtbegin.c:1.2 src/lib/csu/common/crtbegin.c:1.3
--- src/lib/csu/common/crtbegin.c:1.2	Mon Jun 24 14:49:13 2013
+++ src/lib/csu/common/crtbegin.c	Thu Jun 27 21:24:39 2013
@@ -27,79 +27,105 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: crtbegin.c,v 1.2 2013/06/24 14:49:13 matt Exp $");
+__RCSID("$NetBSD: crtbegin.c,v 1.3 2013/06/27 21:24:39 matt Exp $");
 
 typedef void (*fptr_t)(void);
 
 __dso_hidden const fptr_t __JCR_LIST__[0] __section(".jcr");
-__dso_hidden const long __EH_FRAME_LIST__[0] __section(".eh_frame");
+
+__weakref_visible void Jv_RegisterClasses(const fptr_t *)
+	__weak_reference(_Jv_RegisterClasses);
+
+#if !defined(HAVE_INITFINI_ARRAY)
 __dso_hidden const fptr_t __CTOR_LIST__[] __section(".ctors") = {
 	(fptr_t) -1,
 };
 __dso_hidden extern const fptr_t __CTOR_LIST_END__[];
-__dso_hidden const fptr_t __DTOR_LIST__[] __section(".dtors") = {
-	(fptr_t) -1,
-};
-__dso_hidden extern const fptr_t __DTOR_LIST_END__[];
+#endif
 
 #ifdef SHARED
 __dso_hidden void *__dso_handle = &__dso_handle;
+
+__weakref_visible void cxa_finalize(void *)
+	__weak_reference(__cxa_finalize);
 #else
 __dso_hidden void *__dso_handle;
 #endif
 
-__weakref_visible void cxa_finalize(void *)
-	__weak_reference(__cxa_finalize);
-__weakref_visible void Jv_RegisterClasses(const fptr_t *)
-	__weak_reference(_Jv_RegisterClasses);
+#if !defined(__ARM_EABI__)
+__dso_hidden const long __EH_FRAME_LIST__[0] __section(".eh_frame");
+
 __weakref_visible void register_frame_info(const void *, const void *)
 	__weak_reference(__register_frame_info);
 __weakref_visible void deregister_frame_info(const void *)
 	__weak_reference(__deregister_frame_info);
 
 static long dwarf_eh_object[8];
-static unsigned char __initialized;
-static unsigned char __finished;
+#endif
 
 static void __do_global_ctors_aux(void) __used;
-static void __do_global_dtors_aux(void) __used;
 
 static void
 __do_global_ctors_aux(void)
 {
+	static unsigned char __initialized;
+
 	if (__initialized)
 		return;
 
 	__initialized = 1;
 
+#if !defined(__ARM_EABI__)
 	if (register_frame_info)
 		register_frame_info(__EH_FRAME_LIST__, &dwarf_eh_object);
+#endif
 
 	if (Jv_RegisterClasses && __JCR_LIST__[0] != 0)
 		Jv_RegisterClasses(__JCR_LIST__);
 
+#if !defined(HAVE_INITFINI_ARRAY)
 	for (const fptr_t *p = __CTOR_LIST_END__; p > __CTOR_LIST__ + 1; ) {
 		(*(*--p))();
 	}
+#endif
 }
 
+#if !defined(__ARM_EABI__) || defined(SHARED)
+#if !defined(HAVE_INITFINI_ARRAY)
+__dso_hidden const fptr_t __DTOR_LIST__[] __section(".dtors") = {
+	(fptr_t) -1,
+};
+__dso_hidden extern const fptr_t __DTOR_LIST_END__[];
+#endif
+
+static void __do_global_dtors_aux(void) __used;
+
 static void
 __do_global_dtors_aux(void)
 {
+	static unsigned char __finished;
+
 	if (__finished)
 		return;
 
 	__finished = 1;
 
+#ifdef SHARED
 	if (cxa_finalize)
-		cxa_finalize(__dso_handle);
-	
+		(*cxa_finalize)(__dso_handle);
+#endif
+
+#if !defined(HAVE_INITFINI_ARRAY)
 	for (const fptr_t *p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__; ) {
 		(*(*p++))();
 	}
+#endif
 
+#if !defined(__ARM_EABI__)
 	if (deregister_frame_info)
 		deregister_frame_info(__EH_FRAME_LIST__);
+#endif
 }
+#endif /* !__ARM_EABI__ || SHARED */
 
 #include "crtbegin.h"

Added files:

Index: src/lib/csu/arch/arm/crtbegin.h
diff -u /dev/null src/lib/csu/arch/arm/crtbegin.h:1.1
--- /dev/null	Thu Jun 27 21:24:39 2013
+++ src/lib/csu/arch/arm/crtbegin.h	Thu Jun 27 21:24:39 2013
@@ -0,0 +1,38 @@
+/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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.
+ *
+ * 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.
+ */
+__asm(
+	".pushsection	.init, \"ax\", %progbits"
+"\n\t"	"bl	__do_global_ctors_aux"
+"\n\t"	".popsection");
+
+__asm(
+	".pushsection	.fini, \"ax\", %progbits"
+"\n\t"	"bl	__do_global_dtors_aux"
+"\n\t"	".popsection");

Index: src/lib/csu/arch/earm/crtbegin.h
diff -u /dev/null src/lib/csu/arch/earm/crtbegin.h:1.1
--- /dev/null	Thu Jun 27 21:24:39 2013
+++ src/lib/csu/arch/earm/crtbegin.h	Thu Jun 27 21:24:39 2013
@@ -0,0 +1,50 @@
+/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+static void __do_global_ctors_aux(void) __attribute__((__constructor__)) __used;
+#ifdef SHARED
+static void __do_global_dtors_aux(void) __attribute__((__destructor__)) __used;
+#endif
+
+#ifndef SHARED
+static const void *find_exidx(void *, int *) __used;
+
+static const void *
+find_exidx(void * pc, int * pcount)
+{
+	extern __dso_hidden const char __exidx_start[];
+	extern __dso_hidden const char __exidx_end[];
+
+	*pcount = (__exidx_end - __exidx_start) / 8;
+	return __exidx_start;
+}
+
+__weak_alias(__gnu_Uwind_find_exidx,find_exidx)
+#endif /* !SHARED */

Index: src/lib/csu/arch/powerpc/crtbegin.h
diff -u /dev/null src/lib/csu/arch/powerpc/crtbegin.h:1.1
--- /dev/null	Thu Jun 27 21:24:39 2013
+++ src/lib/csu/arch/powerpc/crtbegin.h	Thu Jun 27 21:24:39 2013
@@ -0,0 +1,36 @@
+/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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.
+ *
+ * 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.
+ */
+__asm( ".pushsection	.init, \"ax\", @progbits"
+"\n\t"	"bl	__do_global_ctors_aux"
+"\n\t"	".popsection");
+
+__asm( ".pushsection	.fini, \"ax\", @progbits"
+"\n\t"	"bl	__do_global_dtors_aux"
+"\n\t"	".popsection");

Index: src/lib/csu/arch/vax/crtbegin.h
diff -u /dev/null src/lib/csu/arch/vax/crtbegin.h:1.1
--- /dev/null	Thu Jun 27 21:24:39 2013
+++ src/lib/csu/arch/vax/crtbegin.h	Thu Jun 27 21:24:39 2013
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+__asm(	".pushsection	.init, \"ax\", @progbits"	"\n\t"
+	"calls	$0, __do_global_ctors_aux"		"\n\t"
+	".popsection"					"\n\t"
+	".pushsection	.fini, \"ax\", @progbits"	"\n\t"
+	"calls	$0, __do_global_dtors_aux"		"\n\t"
+	".popsection"
+	);

Reply via email to