From 5a21d307c518c911f81848b6c0056fcc39e3ddcd Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 7 Sep 2001 07:57:11 +0000 Subject: Update. 2001-09-07 Ulrich Drepper * include/link.h (struct link_map): Add l_scope_mem and l_scope_max elements. Change l_scope to be a pointer only. * elf/dl-object.c (_dl_new_ojbect): Initialize l_scope and l_scope_max. * elf/dl-open.c (dl_open_worker): If dependency wasn't just opened here add searchlist of newly open file to the dependency's scope. * elf/dl-close.c (_dl_close): If dependency is used otherwise remove only searchlist from its scope. Free own scope array if necessary. * elf/Makefile (tests): Add dblload and dblunload now. --- elf/dl-close.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'elf/dl-close.c') diff --git a/elf/dl-close.c b/elf/dl-close.c index e83865f..dfc204d 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -146,6 +146,25 @@ _dl_close (void *_map) (imap, (void *) imap->l_addr + imap->l_info[DT_FINI]->d_un.d_ptr)) (); } + else if (new_opencount[i] != 0 && imap->l_type == lt_loaded) + { + /* The object is still used. But the object we are unloading + right now is responsible for loading it and therefore we + have the search list of the current object in its scope. + Remove it. */ + struct r_scope_elem **runp = imap->l_scope; + + while (*runp != NULL) + if (*runp == &map->l_searchlist) + { + /* Copy all later elements. */ + while ((runp[0] = runp[1]) != NULL) + ++runp; + break; + } + else + ++runp; + } /* Store the new l_opencount value. */ imap->l_opencount = new_opencount[i]; @@ -241,6 +260,10 @@ _dl_close (void *_map) if (imap != map) free (imap->l_initfini); + /* Remove the scope array if we allocated it. */ + if (imap->l_scope != imap->l_scope_mem) + free (imap->l_scope); + if (imap->l_phdr_allocated) free ((void *) imap->l_phdr); -- cgit v1.1