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