newlib: internalize HAVE_INITFINI_ARRAY

This define is only used by newlib internally, so stop exporting it
as HAVE_INITFINI_ARRAY since this can conflict with defines packages
use themselves.

We don't really need to add _ to HAVE_INIT_FINI too since it isn't
exported in newlib.h, but might as well be consistent here.

We can't (easily) add this to newlib_cflags like HAVE_INIT_FINI is
because this is based on a compile-time test in the top configure,
not on plain shell code in configure.host.  We'd have to replicate
the test in every subdir in order to have it passed down.
This commit is contained in:
Mike Frysinger 2022-01-17 22:20:20 -05:00
parent 6783cceb0a
commit 437c5c5085
8 changed files with 12 additions and 12 deletions

2
newlib/configure vendored
View File

@ -12817,7 +12817,7 @@ $as_echo "$libc_cv_initfinit_array" >&6; }
if test $libc_cv_initfinit_array = yes; then if test $libc_cv_initfinit_array = yes; then
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define HAVE_INITFINI_ARRAY 1 #define _HAVE_INITFINI_ARRAY 1
_ACEOF _ACEOF
fi fi

View File

@ -648,7 +648,7 @@ fi
rm -f conftest*]) rm -f conftest*])
AC_SUBST(libc_cv_initfinit_array) AC_SUBST(libc_cv_initfinit_array)
if test $libc_cv_initfinit_array = yes; then if test $libc_cv_initfinit_array = yes; then
AC_DEFINE_UNQUOTED(HAVE_INITFINI_ARRAY) AC_DEFINE_UNQUOTED(_HAVE_INITFINI_ARRAY)
fi fi
AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \ AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \

View File

@ -992,7 +992,7 @@ fi
# Have init/finit if not explicitly specified otherwise # Have init/finit if not explicitly specified otherwise
if [ "x${have_init_fini}" != "xno" ]; then if [ "x${have_init_fini}" != "xno" ]; then
newlib_cflags="${newlib_cflags} -DHAVE_INIT_FINI" newlib_cflags="${newlib_cflags} -D_HAVE_INIT_FINI"
fi fi
if test -z "${have_crt0}" && test -n "${sys_dir}"; then if test -z "${have_crt0}" && test -n "${sys_dir}"; then

View File

@ -13,11 +13,11 @@
/* Handle ELF .{pre_init,init,fini}_array sections. */ /* Handle ELF .{pre_init,init,fini}_array sections. */
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_INITFINI_ARRAY #ifdef _HAVE_INITFINI_ARRAY
extern void (*__fini_array_start []) (void) __attribute__((weak)); extern void (*__fini_array_start []) (void) __attribute__((weak));
extern void (*__fini_array_end []) (void) __attribute__((weak)); extern void (*__fini_array_end []) (void) __attribute__((weak));
#ifdef HAVE_INIT_FINI #ifdef _HAVE_INIT_FINI
extern void _fini (void); extern void _fini (void);
#endif #endif
@ -32,7 +32,7 @@ __libc_fini_array (void)
for (i = count; i > 0; i--) for (i = count; i > 0; i--)
__fini_array_start[i-1] (); __fini_array_start[i-1] ();
#ifdef HAVE_INIT_FINI #ifdef _HAVE_INIT_FINI
_fini (); _fini ();
#endif #endif
} }

View File

@ -13,7 +13,7 @@
/* Handle ELF .{pre_init,init,fini}_array sections. */ /* Handle ELF .{pre_init,init,fini}_array sections. */
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_INITFINI_ARRAY #ifdef _HAVE_INITFINI_ARRAY
/* These magic symbols are provided by the linker. */ /* These magic symbols are provided by the linker. */
extern void (*__preinit_array_start []) (void) __attribute__((weak)); extern void (*__preinit_array_start []) (void) __attribute__((weak));
@ -21,7 +21,7 @@ extern void (*__preinit_array_end []) (void) __attribute__((weak));
extern void (*__init_array_start []) (void) __attribute__((weak)); extern void (*__init_array_start []) (void) __attribute__((weak));
extern void (*__init_array_end []) (void) __attribute__((weak)); extern void (*__init_array_end []) (void) __attribute__((weak));
#ifdef HAVE_INIT_FINI #ifdef _HAVE_INIT_FINI
extern void _init (void); extern void _init (void);
#endif #endif
@ -36,7 +36,7 @@ __libc_init_array (void)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
__preinit_array_start[i] (); __preinit_array_start[i] ();
#ifdef HAVE_INIT_FINI #ifdef _HAVE_INIT_FINI
_init (); _init ();
#endif #endif

View File

@ -49,7 +49,7 @@ static void
register_fini(void) register_fini(void)
{ {
if (&__libc_fini) { if (&__libc_fini) {
#ifdef HAVE_INITFINI_ARRAY #ifdef _HAVE_INITFINI_ARRAY
extern void __libc_fini_array (void); extern void __libc_fini_array (void);
atexit (__libc_fini_array); atexit (__libc_fini_array);
#else #else

View File

@ -12,7 +12,7 @@
#error __USER_LABEL_PREFIX is not defined #error __USER_LABEL_PREFIX is not defined
#endif #endif
#ifdef HAVE_INITFINI_ARRAY #ifdef _HAVE_INITFINI_ARRAY
#define _init __libc_init_array #define _init __libc_init_array
#define _fini __libc_fini_array #define _fini __libc_fini_array
#endif #endif

View File

@ -49,7 +49,7 @@
/* Define if the linker supports .preinit_array/.init_array/.fini_array /* Define if the linker supports .preinit_array/.init_array/.fini_array
* sections. */ * sections. */
#undef HAVE_INITFINI_ARRAY #undef _HAVE_INITFINI_ARRAY
/* True if atexit() may dynamically allocate space for cleanup /* True if atexit() may dynamically allocate space for cleanup
functions. */ functions. */