Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 2003d1abfa0c20ee77815f0da33e2c1c > files > 226

glibc-2.5-49.el5_5.5.src.rpm

2010-05-26  Andreas Schwab  <schwab@redhat.com>

	* elf/Makefile: Add rules to build and run unload8 test.
	* elf/unload8.c: New file.
	* elf/unload8mod1.c: New file.
	* elf/unload8mod1x.c: New file.
	* elf/unload8mod2.c: New file.
	* elf/unload8mod3.c: New file.

	* elf/dl-close.c (_dl_close_worker): Reset private search list if
	it wasn't used.

Index: glibc-2.5-20061008T1257/elf/Makefile
===================================================================
--- glibc-2.5-20061008T1257.orig/elf/Makefile
+++ glibc-2.5-20061008T1257/elf/Makefile
@@ -88,6 +88,7 @@ distribute	:= rtld-Rules \
 		   unload4mod1.c unload4mod2.c unload4mod3.c unload4mod4.c \
 		   unload6mod1.c unload6mod2.c unload6mod3.c \
 		   unload7mod1.c unload7mod2.c \
+		   unload8mod1.c unload8mod1x.c unload8mod2.c unload8mod3.c \
 		   tst-auditmod1.c tst-audit.sh \
 		   order2mod1.c order2mod2.c order2mod3.c order2mod4.c \
 		   tst-stackguard1.c tst-stackguard1-static.c \
@@ -169,7 +170,7 @@ tests += loadtest restest1 preloadtest l
 	 tst-align tst-align2 $(tests-execstack-$(have-z-execstack)) \
 	 tst-dlmodcount tst-dlopenrpath tst-deep1 \
 	 tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
-	 unload3 unload4 unload5 unload6 unload7 tst-global1 order2 \
+	 unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
 	 tst-audit1 tst-audit2 \
 	 tst-stackguard1 tst-addr1 tst-thrlock
 #	 reldep9
@@ -218,6 +219,7 @@ modules-names = testobj1 testobj2 testob
 		unload4mod1 unload4mod2 unload4mod3 unload4mod4 \
 		unload6mod1 unload6mod2 unload6mod3 \
 		unload7mod1 unload7mod2 \
+		unload8mod1 unload8mod1x unload8mod2 unload8mod3 \
 		order2mod1 order2mod2 order2mod3 order2mod4
 ifeq (yes,$(have-initfini-array))
 modules-names += tst-array2dep tst-array5dep
@@ -464,6 +466,9 @@ $(objpfx)unload6mod2.so: $(libdl)
 $(objpfx)unload6mod3.so: $(libdl)
 $(objpfx)unload7mod1.so: $(libdl)
 $(objpfx)unload7mod2.so: $(objpfx)unload7mod1.so
+$(objpfx)unload8mod1.so: $(objpfx)unload8mod2.so
+$(objpfx)unload8mod2.so: $(objpfx)unload8mod3.so
+$(objpfx)unload8mod3.so: $(libdl)
 
 LDFLAGS-tst-tlsmod5.so = -nostdlib
 LDFLAGS-tst-tlsmod6.so = -nostdlib
@@ -756,6 +761,9 @@ $(objpfx)unload7: $(libdl)
 $(objpfx)unload7.out: $(objpfx)unload7mod1.so $(objpfx)unload7mod2.so
 unload7-ENV = MALLOC_PERTURB_=85
 
+$(objpfx)unload8: $(libdl)
+$(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
+
 ifdef libdl
 $(objpfx)tst-tls9-static: $(common-objpfx)dlfcn/libdl.a
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
Index: glibc-2.5-20061008T1257/elf/dl-close.c
===================================================================
--- glibc-2.5-20061008T1257.orig/elf/dl-close.c
+++ glibc-2.5-20061008T1257/elf/dl-close.c
@@ -425,6 +425,13 @@ _dl_close_worker (struct link_map *map)
 
 	      imap->l_scope_max = new_size;
 	    }
+	  else if (new_list != NULL)
+	    {
+	      /* We didn't change the scope array, so reset the search
+		 list.  */
+	      imap->l_searchlist.r_list = NULL;
+	      imap->l_searchlist.r_nlist = 0;
+	    }
 
 	  /* The loader is gone, so mark the object as not having one.
 	     Note: l_idx != IDX_STILL_USED -> object will be removed.  */
Index: glibc-2.5-20061008T1257/elf/unload8.c
===================================================================
--- /dev/null
+++ glibc-2.5-20061008T1257/elf/unload8.c
@@ -0,0 +1,33 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  void *h = dlopen ("$ORIGIN/unload8mod1.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      puts ("dlopen unload8mod1.so failed");
+      return 1;
+    }
+
+  void *h2 = dlopen ("$ORIGIN/unload8mod1x.so", RTLD_LAZY);
+  if (h2 == NULL)
+    {
+      puts ("dlopen unload8mod1x.so failed");
+      return 1;
+    }
+  dlclose (h2);
+
+  int (*mod1) (void) = dlsym (h, "mod1");
+  if (mod1 == NULL)
+    {
+      puts ("dlsym failed");
+      return 1;
+    }
+
+  mod1 ();
+  dlclose (h);
+
+  return 0;
+}
Index: glibc-2.5-20061008T1257/elf/unload8mod1.c
===================================================================
--- /dev/null
+++ glibc-2.5-20061008T1257/elf/unload8mod1.c
@@ -0,0 +1,7 @@
+extern void mod2 (void);
+
+void
+mod1 (void)
+{
+  mod2 ();
+}
Index: glibc-2.5-20061008T1257/elf/unload8mod1x.c
===================================================================
--- /dev/null
+++ glibc-2.5-20061008T1257/elf/unload8mod1x.c
@@ -0,0 +1 @@
+int mod1x;
Index: glibc-2.5-20061008T1257/elf/unload8mod2.c
===================================================================
--- /dev/null
+++ glibc-2.5-20061008T1257/elf/unload8mod2.c
@@ -0,0 +1,7 @@
+extern void mod3 (void);
+
+void
+mod2 (void)
+{
+  mod3 ();
+}
Index: glibc-2.5-20061008T1257/elf/unload8mod3.c
===================================================================
--- /dev/null
+++ glibc-2.5-20061008T1257/elf/unload8mod3.c
@@ -0,0 +1,27 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+mod3_fini2 (void)
+{
+}
+
+void
+mod3_fini (void)
+{
+  mod3_fini2 ();
+}
+
+void
+mod3 (void)
+{
+  void *h = dlopen ("$ORIGIN/unload8mod2.so", RTLD_LAZY);
+  if (h == NULL)
+    {
+      puts ("dlopen unload8mod2.so failed");
+      exit (1);
+    }
+
+  atexit (mod3_fini);
+}