aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-01-21 14:17:43 +0000
committerUlrich Drepper <drepper@redhat.com>1999-01-21 14:17:43 +0000
commit50b65db1ee9a87be6ead950e7cffa4c223e689fd (patch)
tree28ecfe4141d27f096b12cd3174bbbd5c0b9c3d79 /elf
parent1d28e93cabf235de32a594d7b770551a34be0e75 (diff)
downloadglibc-50b65db1ee9a87be6ead950e7cffa4c223e689fd.tar
glibc-50b65db1ee9a87be6ead950e7cffa4c223e689fd.tar.gz
glibc-50b65db1ee9a87be6ead950e7cffa4c223e689fd.tar.bz2
glibc-50b65db1ee9a87be6ead950e7cffa4c223e689fd.zip
Update.
1999-01-21 Ulrich Drepper <drepper@cygnus.com> * elf/dl-close.c: Rewrite the way adding to the global scope works to handle error cases better than the last change. The l_global flag is now only set when the object is actually counted in the global scope list. * elf/dl-deps.c: Likewise. * elf/dl-open.c: Likewise.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-close.c35
-rw-r--r--elf/dl-deps.c9
-rw-r--r--elf/dl-open.c6
3 files changed, 13 insertions, 37 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index a56c14400c..d7a61c4535 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -106,36 +106,15 @@ _dl_close (struct link_map *map)
int cnt = _dl_main_searchlist->r_nlist;
do
- if (--cnt < 0)
- break;
+ --cnt;
while (_dl_main_searchlist->r_list[cnt] != imap);
- if (cnt >= 0)
- {
- /* The object was already correctly registered. */
- while (++cnt < _dl_main_searchlist->r_nlist)
- _dl_main_searchlist->r_list[cnt - 1]
- = _dl_main_searchlist->r_list[cnt];
-
- --_dl_main_searchlist->r_nlist;
- }
- else
- {
- /* This can happen if loading was interrupted by something
- like a missing symbol in the newly loaded objects. In
- this case the object is already marked as global but
- `r_nlist' does not count it in. The pointer is in the
- `r_list' array so we keep searching in the other
- direction. */
- cnt = _dl_main_searchlist->r_nlist;
- while (_dl_main_searchlist->r_list[cnt] != imap)
- {
- ++cnt;
- /* Note that if _dl_global_scope_alloc is zero we
- should never come here in the first place. */
- assert (cnt < _dl_global_scope_alloc);
- }
- }
+ /* The object was already correctly registered. */
+ while (++cnt < _dl_main_searchlist->r_nlist)
+ _dl_main_searchlist->r_list[cnt - 1]
+ = _dl_main_searchlist->r_list[cnt];
+
+ --_dl_main_searchlist->r_nlist;
}
/* We can unmap all the maps at once. We determined the
diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index 04c4010b65..355618ad1c 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -1,5 +1,5 @@
/* Load the dependencies of a mapped object.
- Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -93,6 +93,7 @@ _dl_map_object_deps (struct link_map *map,
struct list known[1 + npreloads + 1];
struct list *runp, *utail, *dtail;
unsigned int nlist, nduplist, i;
+ unsigned int to_add = 0;
inline void preload (struct link_map *map)
{
@@ -416,7 +417,6 @@ _dl_map_object_deps (struct link_map *map,
if (global_scope)
{
unsigned int cnt;
- unsigned int to_add = 0;
struct link_map **new_global;
/* Count the objects we have to put in the global scope. */
@@ -479,16 +479,13 @@ _dl_map_object_deps (struct link_map *map,
for (cnt = 0; cnt < nlist; ++cnt)
if (map->l_searchlist.r_list[cnt]->l_global == 0)
{
- map->l_searchlist.r_list[cnt]->l_global = 1;
_dl_main_searchlist->r_list[_dl_main_searchlist->r_nlist + to_add]
= map->l_searchlist.r_list[cnt];
++to_add;
}
/* XXX Do we have to add something to r_dupsearchlist??? --drepper */
-
- return to_add;
}
- return 0;
+ return to_add;
}
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 3db2b0e9f7..2b3352b674 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -144,9 +144,9 @@ dl_open_worker (void *a)
(*(void (*) (int, char **, char **)) init) (__libc_argc, __libc_argv,
__environ);
- if (new->l_global)
- /* Now we can make the new map available in the global scope. */
- _dl_main_searchlist->r_nlist += global_add;
+ /* Now we can make the new map available in the global scope. */
+ while (global_add-- > 0)
+ _dl_main_searchlist->r_list[_dl_main_searchlist->r_nlist++]->l_global = 1;
if (_dl_sysdep_start == NULL)
/* We must be the static _dl_open in libc.a. A static program that