manual: Document getcontext uc_stack value on Linux [BZ #759]
[glibc.git] / elf / soinit.c
blobfe9935732b2dcc3d71b5c0f2e52c32efc642d160
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 #ifndef NO_CTORS_DTORS_SECTIONS
7 # include <stdlib.h>
9 static void (*const __CTOR_LIST__[1]) (void)
10 __attribute__ ((used, section (".ctors")))
11 = { (void (*) (void)) -1 };
12 static void (*const __DTOR_LIST__[1]) (void)
13 __attribute__ ((used, section (".dtors")))
14 = { (void (*) (void)) -1 };
16 static inline void
17 run_hooks (void (*const list[]) (void))
19 while (*++list)
20 (**list) ();
23 /* This function will be called from _init in init-first.c. */
24 void
25 __libc_global_ctors (void)
27 /* Call constructor functions. */
28 run_hooks (__CTOR_LIST__);
32 /* This function becomes the DT_FINI termination function
33 for the C library. */
34 void
35 __libc_fini (void)
37 /* Call destructor functions. */
38 run_hooks (__DTOR_LIST__);
41 void (*_fini_ptr) (void) __attribute__ ((section (".fini_array")))
42 = &__libc_fini;
43 #endif