From: Roland McGrath Date: Wed, 6 Apr 2005 01:42:52 +0000 (+0000) Subject: 2005-03-03 Ulrich Drepper X-Git-Tag: cvs/glibc-2_3_5~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c5710a6011d86605d856130a6b95419baed3000;p=thirdparty%2Fglibc.git 2005-03-03 Ulrich Drepper [BZ #821] * elf/dl-close.c (_dl_close): Don't try to set up new searchpath if the loader is closed. Fixes unload3. * elf/tst-global1.c: New file. * elf/Makefile (tests): Add tst-global1. * elf/testobj2.c (p): New function. --- diff --git a/elf/dl-close.c b/elf/dl-close.c index c823b176427..f40d5b0d89c 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -327,36 +327,6 @@ _dl_close (void *_map) } assert (found); } - else if (new_opencount[i] != 0 && imap->l_type == lt_loaded - && imap->l_searchlist.r_list == NULL - && imap->l_initfini != NULL) - { - /* The object is still used. But the object we are - unloading right now is responsible for loading it. If - the current object does not have it's own scope yet we - have to create one. This has to be done before running - the finalizers. - - To do this count the number of dependencies. */ - unsigned int cnt; - for (cnt = 1; imap->l_initfini[cnt] != NULL; ++cnt) - if (imap->l_initfini[cnt]->l_idx >= i - && imap->l_initfini[cnt]->l_idx < nopencount) - ++new_opencount[imap->l_initfini[cnt]->l_idx]; - else - ++imap->l_initfini[cnt]->l_opencount; - - /* We simply reuse the l_initfini list. */ - imap->l_searchlist.r_list = &imap->l_initfini[cnt + 1]; - imap->l_searchlist.r_nlist = cnt; - - for (cnt = 0; imap->l_scope[cnt] != NULL; ++cnt) - if (imap->l_scope[cnt] == &map->l_searchlist) - { - imap->l_scope[cnt] = &imap->l_searchlist; - break; - } - } /* Store the new l_opencount value. */ imap->l_opencount = new_opencount[i]; diff --git a/elf/testobj2.c b/elf/testobj2.c index 6514c563939..f00ba9f3e67 100644 --- a/elf/testobj2.c +++ b/elf/testobj2.c @@ -23,3 +23,9 @@ preload (int a) return fp (a) + 10; return 10; } + +void +p (void) +{ + puts ("hello world"); +} diff --git a/elf/tst-global1.c b/elf/tst-global1.c new file mode 100644 index 00000000000..1611b51b67b --- /dev/null +++ b/elf/tst-global1.c @@ -0,0 +1,36 @@ +#include +#include + +int +main (void) +{ + void *h1 = dlopen ("$ORIGIN/testobj6.so", RTLD_GLOBAL|RTLD_LAZY); + if (h1 == NULL) + { + puts ("cannot open testobj6"); + return 1; + } + + void *h2 = dlopen ("$ORIGIN/testobj2.so", + RTLD_GLOBAL|RTLD_DEEPBIND|RTLD_LAZY); + if (h2 == NULL) + { + puts ("cannot open testobj2"); + return 1; + } + + dlclose (h1); + + void (*f) (void) = dlsym (h2, "p"); + if (f == NULL) + { + puts ("cannot find p"); + return 1; + } + + f (); + + dlclose (h2); + + return 0; +}