From 8699e7b1daa5d250b8bc69e1ecffae80170277e5 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 21 Oct 2000 06:02:49 +0000 Subject: Update. * elf/dl-close.c: Decrement opencount for all dependencies which can be removed even if the object is not yet unloaded. * elf/dl-deps.c (_dl_map_object_deps): If dependency is already in the list decrement opencount of all dependencies. * elf/dl-load.c (_dl_map_object_from_fd): Increment object of object and all dependencies. (_dl_map_object): Likewise. * elf/dl-lookup.c (add_dependency): Likewise. * elf/loadtest.c: Add debug when with more output. --- elf/dl-load.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'elf/dl-load.c') diff --git a/elf/dl-load.c b/elf/dl-load.c index b2f5ad7a1c..55725c3cb3 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -777,6 +777,8 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, for (l = _dl_loaded; l; l = l->l_next) if (l->l_ino == st.st_ino && l->l_dev == st.st_dev) { + unsigned int i; + /* The object is already loaded. Just bump its reference count and return it. */ __close (fd); @@ -785,6 +787,10 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname, it. */ free (realname); add_name_to_object (l, name); + + if (l->l_initfini != NULL) + for (i = 1; l->l_initfini[i] != NULL; ++i) + ++l->l_initfini[i]->l_opencount; ++l->l_opencount; return l; } @@ -1396,6 +1402,8 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, /* Look for this name among those already loaded. */ for (l = _dl_loaded; l; l = l->l_next) { + unsigned int i; + /* If the requested name matches the soname of a loaded object, use that object. Elide this check for names that have not yet been opened. */ @@ -1408,8 +1416,8 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, if (l->l_info[DT_SONAME] == NULL) continue; - soname = (const void *) (D_PTR (l, l_info[DT_STRTAB]) - + l->l_info[DT_SONAME]->d_un.d_val); + soname = ((const char *) D_PTR (l, l_info[DT_STRTAB]) + + l->l_info[DT_SONAME]->d_un.d_val); if (strcmp (name, soname) != 0) continue; @@ -1418,6 +1426,9 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, } /* We have a match -- bump the reference count and return it. */ + if (l->l_initfini != NULL) + for (i = 1; l->l_initfini[i] != NULL; ++i) + ++l->l_initfini[i]->l_opencount; ++l->l_opencount; return l; } -- cgit v1.2.3