]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/soinit.c
Merge branch release/2.28/master into ibm/2.28/master
[thirdparty/glibc.git] / elf / soinit.c
CommitLineData
0324daa0
RM
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
4a531bb0 6#ifndef NO_CTORS_DTORS_SECTIONS
8bdf4e6e 7# include <stdlib.h>
66539a73 8
0324daa0 9static void (*const __CTOR_LIST__[1]) (void)
78a7eee7
RM
10 __attribute__ ((used, section (".ctors")))
11 = { (void (*) (void)) -1 };
0324daa0 12static void (*const __DTOR_LIST__[1]) (void)
78a7eee7
RM
13 __attribute__ ((used, section (".dtors")))
14 = { (void (*) (void)) -1 };
0324daa0
RM
15
16static inline void
17run_hooks (void (*const list[]) (void))
18{
19 while (*++list)
20 (**list) ();
21}
22
0324daa0
RM
23/* This function will be called from _init in init-first.c. */
24void
25__libc_global_ctors (void)
26{
27 /* Call constructor functions. */
28 run_hooks (__CTOR_LIST__);
29}
30
31
32/* This function becomes the DT_FINI termination function
33 for the C library. */
6def43e6
UD
34void
35__libc_fini (void)
0324daa0
RM
36{
37 /* Call destructor functions. */
38 run_hooks (__DTOR_LIST__);
39}
ce33ee7c 40
6def43e6
UD
41void (*_fini_ptr) (void) __attribute__ ((section (".fini_array")))
42 = &__libc_fini;
4a531bb0 43#endif