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 #include <libc-internal.h>
9 #ifdef HAVE_DWARF2_UNWIND_INFO_STATIC
10 # include <gccframe.h>
13 static void (*const __CTOR_LIST__
[1]) (void)
14 __attribute__ ((section (".ctors")))
15 = { (void (*) (void)) -1 };
16 static void (*const __DTOR_LIST__
[1]) (void)
17 __attribute__ ((section (".dtors")))
18 = { (void (*) (void)) -1 };
21 run_hooks (void (*const list
[]) (void))
27 #ifdef HAVE_DWARF2_UNWIND_INFO
28 static char __EH_FRAME_BEGIN__
[]
29 __attribute__ ((section (".eh_frame")))
31 # ifdef HAVE_DWARF2_UNWIND_INFO_STATIC
32 extern void __register_frame_info (const void *, struct object
*);
33 extern void __register_frame_info_bases (const void *, struct object
*,
35 extern void __deregister_frame_info (const void *);
36 extern void __deregister_frame_info_bases (const void *);
38 extern void __register_frame (const void *);
39 extern void __deregister_frame (const void *);
43 /* This function will be called from _init in init-first.c. */
45 __libc_global_ctors (void)
47 /* Call constructor functions. */
48 run_hooks (__CTOR_LIST__
);
50 #ifdef HAVE_DWARF2_UNWIND_INFO
51 # ifdef HAVE_DWARF2_UNWIND_INFO_STATIC
53 static struct object ob
;
54 # if defined CRT_GET_RFIB_TEXT || defined CRT_GET_RFIB_DATA
57 # ifdef CRT_GET_RFIB_TEXT
58 CRT_GET_RFIB_TEXT (tbase
);
62 # ifdef CRT_GET_RFIB_DATA
63 CRT_GET_RFIB_DATA (dbase
);
67 __register_frame_info_bases (__EH_FRAME_BEGIN__
, &ob
, tbase
, dbase
);
69 __register_frame_info (__EH_FRAME_BEGIN__
, &ob
);
73 __register_frame (__EH_FRAME_BEGIN__
);
79 /* This function becomes the DT_FINI termination function
81 #ifndef HAVE_INITFINI_ARRAY
82 void _fini (void) __attribute__ ((section (".fini"))); /* Just for kicks. */
90 /* Call destructor functions. */
91 run_hooks (__DTOR_LIST__
);
92 #ifdef HAVE_DWARF2_UNWIND_INFO
93 # ifdef HAVE_DWARF2_UNWIND_INFO_STATIC
94 # if defined CRT_GET_RFIB_TEXT || defined CRT_GET_RFIB_DATA
95 __deregister_frame_info_bases (__EH_FRAME_BEGIN__
);
97 __deregister_frame_info (__EH_FRAME_BEGIN__
);
100 __deregister_frame (__EH_FRAME_BEGIN__
);
104 #ifdef HAVE_INITFINI_ARRAY
105 void (*_fini_ptr
) (void) __attribute__ ((section (".fini_array")))