Sat Jul 13 03:50:53 1996 Ulrich Drepper <drepper@cygnus.com>
[glibc/history.git] / elf / soinit.c
blob0310b74b93e8b7dc66a850811cf9d3dfc18178ee
1 /* Initializer module for building the ELF shared C library. This file and
2 sofini.c do the work normally done by crtbeginS.o and crtendS.o, to wrap
3 the `.ctors' and `.dtors' sections so the lists are terminated, and
4 calling those lists of functions. */
6 static void (*const __CTOR_LIST__[1]) (void)
7 __attribute__ ((section (".ctors")))
8 = { (void (*) (void)) -1 };
9 static void (*const __DTOR_LIST__[1]) (void)
10 __attribute__ ((section (".dtors")))
11 = { (void (*) (void)) -1 };
13 static inline void
14 run_hooks (void (*const list[]) (void))
16 while (*++list)
17 (**list) ();
21 /* This function will be called from _init in init-first.c. */
22 void
23 __libc_global_ctors (void)
25 /* Call constructor functions. */
26 run_hooks (__CTOR_LIST__);
30 /* This function becomes the DT_FINI termination function
31 for the C library. */
32 void _fini (void) __attribute__ ((section (".fini"))); /* Just for kicks. */
33 void
34 _fini (void)
36 /* Call destructor functions. */
37 run_hooks (__DTOR_LIST__);