Re-do previous (always make available preinit/initarray/finiarray), with

less disruption.
This commit is contained in:
christos 2018-12-28 20:12:35 +00:00
parent 032c1d01a1
commit 7a3b8449d8
1 changed files with 10 additions and 10 deletions

View File

@ -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 @@ __RCSID("$NetBSD: crt0-common.c,v 1.22 2018/12/28 18:17:11 christos Exp $");
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 @@ do { \
_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 @@ _preinit(void)
}
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 @@ _init(void)
}
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 @@ ___start(void (*cleanup)(void), /* from shared loader */
#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));
}