1 /*
2  * Copyright (C) 2004 CodeSourcery, LLC
3  *
4  * Permission to use, copy, modify, and distribute this file
5  * for any purpose is hereby granted without fee, provided that
6  * the above copyright notice and this notice appears in all
7  * copies.
8  *
9  * This file is distributed WITHOUT ANY WARRANTY; without even the implied
10  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  */
12 
13 /* Handle ELF .{pre_init,init,fini}_array sections.  */
14 #include <sys/types.h>
15 #include <sys/_initfini.h>
16 
17 #ifdef _HAVE_INITFINI_ARRAY
18 
19 /* Iterate over all the init routines.  */
20 void
__libc_init_array(void)21 __libc_init_array (void)
22 {
23   size_t count;
24   size_t i;
25 
26   count = __preinit_array_end - __preinit_array_start;
27   for (i = 0; i < count; i++)
28     __preinit_array_start[i] ();
29 
30 #ifdef _HAVE_INIT_FINI
31   if (_init)
32     _init ();
33 #endif
34 
35   count = __init_array_end - __init_array_start;
36   for (i = 0; i < count; i++)
37     __init_array_start[i] ();
38 }
39 #endif
40