1 |
/* Support for opening `typed' stores |
/* Support for opening `typed' stores |
2 |
|
|
3 |
Copyright (C) 1997,98,2001,02,03 Free Software Foundation, Inc. |
Copyright (C) 1997,1998,2001,2002,2003 Free Software Foundation, Inc. |
4 |
Written by Miles Bader <miles@gnu.org> |
Written by Miles Bader <miles@gnu.org> |
5 |
|
|
6 |
This file is part of the GNU Hurd. |
This file is part of the GNU Hurd. |
64 |
and examine each one's "store_std_classes" section. */ |
and examine each one's "store_std_classes" section. */ |
65 |
# pragma weak _r_debug |
# pragma weak _r_debug |
66 |
# pragma weak dlsym |
# pragma weak dlsym |
67 |
|
# pragma weak dlopen |
68 |
|
# pragma weak dlclose |
69 |
# pragma weak dlerror |
# pragma weak dlerror |
70 |
if (dlsym) |
if (dlsym) |
71 |
{ |
{ |
72 |
struct link_map *map; |
struct link_map *map; |
73 |
for (map = _r_debug.r_map; map != 0; map = map->l_next) |
for (map = _r_debug.r_map; map != 0; map = map->l_next) |
74 |
{ |
{ |
75 |
const struct store_class *const *start; |
const struct store_class *const *start, *const *stop; |
76 |
const struct store_class *const *stop; |
|
77 |
start = dlsym (map, "__start_store_std_classes"); |
/* We cannot just use MAP directly because it may not have been |
78 |
if (start == 0) |
opened by dlopen such that its data structures are fully set |
79 |
|
up for dlsym. */ |
80 |
|
void *module = dlopen (map->l_name, RTLD_NOLOAD); |
81 |
|
if (module == 0) |
82 |
{ |
{ |
83 |
(void) dlerror (); /* Required to avoid a leak! */ |
(void) dlerror (); /* Required to avoid a leak! */ |
84 |
continue; |
continue; |
85 |
} |
} |
86 |
if (start == __start_store_std_classes) |
|
87 |
continue; |
start = dlsym (map, "__start_store_std_classes"); |
88 |
stop = dlsym (map, "__stop_store_std_classes"); |
if (start == 0) |
89 |
if (stop == 0) |
(void) dlerror (); /* Required to avoid a leak! */ |
90 |
|
else if (start != __start_store_std_classes) /* */ |
91 |
{ |
{ |
92 |
(void) dlerror (); /* Required to avoid a leak! */ |
stop = dlsym (map, "__stop_store_std_classes"); |
93 |
continue; |
if (stop == 0) |
94 |
|
(void) dlerror (); /* Required to avoid a leak! */ |
95 |
|
else |
96 |
|
for (cl = start; cl < stop; ++cl) |
97 |
|
if (strlen ((*cl)->name) == (clname_end - name) |
98 |
|
&& strncmp (name, (*cl)->name, (clname_end - name)) == 0) |
99 |
|
{ |
100 |
|
dlclose (module); |
101 |
|
return *cl; |
102 |
|
} |
103 |
} |
} |
104 |
for (cl = start; cl < stop; ++cl) |
dlclose (module); |
|
if (strlen ((*cl)->name) == (clname_end - name) |
|
|
&& strncmp (name, (*cl)->name, (clname_end - name)) == 0) |
|
|
return *cl; |
|
105 |
} |
} |
106 |
} |
} |
107 |
|
|