Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/csu/common Add support for PREINIT_ARRAY



details:   https://anonhg.NetBSD.org/src/rev/ffcfe9c6c5d2
branches:  trunk
changeset: 784549:ffcfe9c6c5d2
user:      matt <matt%NetBSD.org@localhost>
date:      Thu Jan 31 22:24:25 2013 +0000

description:
Add support for PREINIT_ARRAY

diffstat:

 lib/csu/common/crt0-common.c |  20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diffs (55 lines):

diff -r 06858edac9d4 -r ffcfe9c6c5d2 lib/csu/common/crt0-common.c
--- a/lib/csu/common/crt0-common.c      Thu Jan 31 22:01:49 2013 +0000
+++ b/lib/csu/common/crt0-common.c      Thu Jan 31 22:24:25 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crt0-common.c,v 1.12 2013/01/28 16:56:39 matt Exp $ */
+/* $NetBSD: crt0-common.c,v 1.13 2013/01/31 22:24:25 matt Exp $ */
 
 /*
  * Copyright (c) 1998 Christos Zoulas
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: crt0-common.c,v 1.12 2013/01/28 16:56:39 matt Exp $");
+__RCSID("$NetBSD: crt0-common.c,v 1.13 2013/01/31 22:24:25 matt Exp $");
 
 #include <sys/types.h>
 #include <sys/exec.h>
@@ -95,6 +95,10 @@
  * Since we don't need .init or .fini sections, just code them in C
  * to make life easier.
  */
+__weakref_visible const fptr_t preinit_array_start[1]
+    __weak_reference(__preinit_array_start);
+__weakref_visible const fptr_t preinit_array_end[1]
+    __weak_reference(__preinit_array_end);
 __weakref_visible const fptr_t init_array_start[1]
     __weak_reference(__init_array_start);
 __weakref_visible const fptr_t init_array_end[1]
@@ -105,6 +109,14 @@
     __weak_reference(__fini_array_end);
 
 static inline void
+_preinit(void)
+{
+       for (const fptr_t *f = preinit_array_start; f < preinit_array_end; f++) {
+               (*f)();
+       }
+}
+
+static inline void
 _init(void)
 {
        for (const fptr_t *f = init_array_start; f < init_array_end; f++) {
@@ -156,6 +168,10 @@
 
        _libc_init();
 
+#ifdef HAVE_INITFINI_ARRAY
+       _preinit();
+#endif
+
 #ifdef MCRT0
        atexit(_mcleanup);
        monstartup((u_long)&__eprol, (u_long)&__etext);



Home | Main Index | Thread Index | Old Index