]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
2005-03-03 Ulrich Drepper <drepper@redhat.com>
authorRoland McGrath <roland@gnu.org>
Wed, 6 Apr 2005 01:42:52 +0000 (01:42 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 6 Apr 2005 01:42:52 +0000 (01:42 +0000)
[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.

elf/dl-close.c
elf/testobj2.c
elf/tst-global1.c [new file with mode: 0644]

index c823b176427fedae1afc5260ba43a9d9ed468b6a..f40d5b0d89cc175980c602cc13f16ac2c84139a0 100644 (file)
@@ -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];
index 6514c5639390de8435e84593f55a7e263e7f1a93..f00ba9f3e675006cb7d5868832b15dda9692046d 100644 (file)
@@ -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 (file)
index 0000000..1611b51
--- /dev/null
@@ -0,0 +1,36 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+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;
+}