]> sourceware.org Git - glibc.git/blame - elf/dl-init.c
Thu Jun 13 00:02:25 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / elf / dl-init.c
CommitLineData
d66e34cd 1/* Return the next shared object initializer function not yet run.
f68b86cc 2Copyright (C) 1995, 1996 Free Software Foundation, Inc.
d66e34cd
RM
3This file is part of the GNU C Library.
4
5The GNU C Library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Library General Public License as
7published by the Free Software Foundation; either version 2 of the
8License, or (at your option) any later version.
9
10The GNU C Library is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Library General Public License for more details.
14
15You should have received a copy of the GNU Library General Public
16License along with the GNU C Library; see the file COPYING.LIB. If
17not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18Cambridge, MA 02139, USA. */
19
20#include <stddef.h>
21#include <link.h>
22
23
f68b86cc
RM
24/* Run initializers for MAP and its dependencies, in inverse dependency
25 order (that is, leaf nodes first). */
26
266180eb 27ElfW(Addr)
f68b86cc 28_dl_init_next (struct link_map *map)
d66e34cd 29{
f68b86cc
RM
30 unsigned int i;
31
32 /* The search list for symbol lookup is a flat list in top-down
33 dependency order, so processing that list from back to front gets us
34 breadth-first leaf-to-root order. */
d66e34cd 35
f68b86cc
RM
36 i = map->l_nsearchlist;
37 while (i-- > 0)
d66e34cd 38 {
f68b86cc
RM
39 struct link_map *l = map->l_searchlist[i];
40
d66e34cd
RM
41 if (l->l_init_called)
42 /* This object is all done. */
f68b86cc
RM
43 continue;
44
d66e34cd
RM
45 if (l->l_init_running)
46 {
47 /* This object's initializer was just running.
48 Now mark it as having run, so this object
49 will be skipped in the future. */
d66e34cd 50 l->l_init_running = 0;
f68b86cc
RM
51 l->l_init_called = 1;
52 continue;
d66e34cd
RM
53 }
54
65bf5fa3
RM
55 if (l->l_info[DT_INIT] &&
56 !(l->l_name[0] == '\0' && l->l_type == lt_executable))
d66e34cd
RM
57 {
58 /* Run this object's initializer. */
59 l->l_init_running = 1;
60 return l->l_addr + l->l_info[DT_INIT]->d_un.d_ptr;
61 }
62
63 /* No initializer for this object.
64 Mark it so we will skip it in the future. */
65 l->l_init_called = 1;
d66e34cd 66 }
d66e34cd 67
4d6acc61
RM
68
69 /* Notify the debugger all new objects are now ready to go. */
70 _r_debug.r_state = RT_CONSISTENT;
71 _dl_debug_state ();
72
f68b86cc 73 return 0;
d66e34cd 74}
This page took 0.046836 seconds and 5 git commands to generate.