* elf/elf.h (NT_PPC_SPE): New macro.
[platform/upstream/glibc.git] / elf / soinit.c
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.  */
5
6 #include <libc-internal.h>
7 #include <stdlib.h>
8
9 static void (*const __CTOR_LIST__[1]) (void)
10      __attribute__ ((section (".ctors")))
11      = { (void (*) (void)) -1 };
12 static void (*const __DTOR_LIST__[1]) (void)
13      __attribute__ ((section (".dtors")))
14      = { (void (*) (void)) -1 };
15
16 static inline void
17 run_hooks (void (*const list[]) (void))
18 {
19   while (*++list)
20     (**list) ();
21 }
22
23 static const char __EH_FRAME_BEGIN__[]
24   __attribute__ ((used, section (".eh_frame")))
25   = { };
26
27 /* This function will be called from _init in init-first.c.  */
28 void
29 __libc_global_ctors (void)
30 {
31   /* Call constructor functions.  */
32   run_hooks (__CTOR_LIST__);
33 }
34
35
36 /* This function becomes the DT_FINI termination function
37    for the C library.  */
38 void
39 __libc_fini (void)
40 {
41   /* Call destructor functions.  */
42   run_hooks (__DTOR_LIST__);
43 }
44
45 void (*_fini_ptr) (void) __attribute__ ((section (".fini_array")))
46      = &__libc_fini;