2005-01-08 02:04:39 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004 CodeSourcery, LLC
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this file
|
|
|
|
* for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice and this notice appears in all
|
|
|
|
* copies.
|
|
|
|
*
|
|
|
|
* This file is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Handle ELF .{pre_init,init,fini}_array sections. */
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_INITFINI_ARRAY
|
|
|
|
|
|
|
|
/* These magic symbols are provided by the linker. */
|
|
|
|
extern void (*__preinit_array_start []) (void) __attribute__((weak));
|
|
|
|
extern void (*__preinit_array_end []) (void) __attribute__((weak));
|
|
|
|
extern void (*__init_array_start []) (void) __attribute__((weak));
|
|
|
|
extern void (*__init_array_end []) (void) __attribute__((weak));
|
|
|
|
|
2018-07-27 16:11:44 +08:00
|
|
|
#ifdef HAVE_INIT_FINI
|
2005-01-08 02:04:39 +08:00
|
|
|
extern void _init (void);
|
2018-07-27 16:11:44 +08:00
|
|
|
#endif
|
2005-01-08 02:04:39 +08:00
|
|
|
|
|
|
|
/* Iterate over all the init routines. */
|
|
|
|
void
|
|
|
|
__libc_init_array (void)
|
|
|
|
{
|
|
|
|
size_t count;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
count = __preinit_array_end - __preinit_array_start;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
__preinit_array_start[i] ();
|
|
|
|
|
2018-07-27 16:11:44 +08:00
|
|
|
#ifdef HAVE_INIT_FINI
|
2005-01-08 02:04:39 +08:00
|
|
|
_init ();
|
2018-07-27 16:11:44 +08:00
|
|
|
#endif
|
2005-01-08 02:04:39 +08:00
|
|
|
|
|
|
|
count = __init_array_end - __init_array_start;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
__init_array_start[i] ();
|
|
|
|
}
|
|
|
|
#endif
|