Source-Changes-HG archive

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

[src/trunk]: src/lib/csu/common Re-do previous (always make available preinit...



details:   https://anonhg.NetBSD.org/src/rev/588ecce6ce29
branches:  trunk
changeset: 995582:588ecce6ce29
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Dec 28 20:12:35 2018 +0000

description:
Re-do previous (always make available preinit/initarray/finiarray), with
less disruption.

diffstat:

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

diffs (84 lines):

diff -r 326a5cafbb3c -r 588ecce6ce29 lib/csu/common/crt0-common.c
--- a/lib/csu/common/crt0-common.c      Fri Dec 28 19:54:36 2018 +0000
+++ b/lib/csu/common/crt0-common.c      Fri Dec 28 20:12:35 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crt0-common.c,v 1.22 2018/12/28 18:17:11 christos Exp $ */
+/* $NetBSD: crt0-common.c,v 1.23 2018/12/28 20:12:35 christos Exp $ */
 
 /*
  * Copyright (c) 1998 Christos Zoulas
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: crt0-common.c,v 1.22 2018/12/28 18:17:11 christos Exp $");
+__RCSID("$NetBSD: crt0-common.c,v 1.23 2018/12/28 20:12:35 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/exec.h>
@@ -48,9 +48,8 @@
 
 extern int main(int, char **, char **);
 
-#ifdef HAVE_INITFINI_ARRAY
 typedef void (*fptr_t)(void);
-#else
+#ifndef HAVE_INITFINI_ARRAY
 extern void    _init(void);
 extern void    _fini(void);
 #endif
@@ -87,7 +86,6 @@
        _exit(1);                               \
 } while (0)
 
-#ifdef HAVE_INITFINI_ARRAY
 /*
  * If we are using INIT_ARRAY/FINI_ARRAY and we are linked statically,
  * we have to process these instead of relying on RTLD to do it for us.
@@ -111,7 +109,7 @@
 }
 
 static inline void
-_init(void)
+_initarray(void)
 {
        for (const fptr_t *f = __init_array_start; f < __init_array_end; f++) {
                (*f)();
@@ -119,13 +117,12 @@
 }
 
 static void
-_fini(void)
+_finiarray(void)
 {
        for (const fptr_t *f = __fini_array_start; f < __fini_array_end; f++) {
                (*f)();
        }
 }
-#endif /* HAVE_INITFINI_ARRAY */
 
 #if defined(__x86_64__) || defined(__powerpc__) || defined(__sparc__)
 #define HAS_IPLTA
@@ -327,17 +324,20 @@
 #endif
        }
 
-#ifdef HAVE_INITFINI_ARRAY
        _preinit();
-#endif
 
 #ifdef MCRT0
        atexit(_mcleanup);
        monstartup((u_long)&__eprol, (u_long)&__etext);
 #endif
 
+       atexit(_finiarray);
+       _initarray();
+
+#ifndef HAVE_INITFINI_ARRAY
        atexit(_fini);
        _init();
+#endif
 
        exit(main(ps_strings->ps_nargvstr, ps_strings->ps_argvstr, environ));
 }



Home | Main Index | Thread Index | Old Index