Blame SOURCES/glibc-rh593686.patch

b40826
2010-05-26  Andreas Schwab  <schwab@redhat.com>
b40826
b40826
	* elf/Makefile: Add rules to build and run unload8 test.
b40826
	* elf/unload8.c: New file.
b40826
	* elf/unload8mod1.c: New file.
b40826
	* elf/unload8mod1x.c: New file.
b40826
	* elf/unload8mod2.c: New file.
b40826
	* elf/unload8mod3.c: New file.
b40826
b40826
	* elf/dl-close.c (_dl_close_worker): Reset private search list if
b40826
	it wasn't used.
b40826
b40826
Index: glibc-2.12-2-gc4ccff1/elf/Makefile
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/elf/Makefile
b40826
+++ glibc-2.12-2-gc4ccff1/elf/Makefile
b40826
@@ -89,6 +89,7 @@ distribute	:= rtld-Rules \
b40826
 		   unload4mod1.c unload4mod2.c unload4mod3.c unload4mod4.c \
b40826
 		   unload6mod1.c unload6mod2.c unload6mod3.c \
b40826
 		   unload7mod1.c unload7mod2.c \
b40826
+		   unload8mod1.c unload8mod1x.c unload8mod2.c unload8mod3.c \
b40826
 		   tst-audit1.c tst-audit2.c tst-audit3.c tst-audit4.c \
b40826
 		   tst-auditmod1.c tst-auditmod3a.c tst-auditmod3b.c \
b40826
 		   tst-auditmod4a.c tst-auditmod4b.c \
b40826
@@ -196,7 +197,7 @@ tests += loadtest restest1 preloadtest l
b40826
 	 tst-align tst-align2 $(tests-execstack-$(have-z-execstack)) \
b40826
 	 tst-dlmodcount tst-dlopenrpath tst-deep1 \
b40826
 	 tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
b40826
-	 unload3 unload4 unload5 unload6 unload7 tst-global1 order2 \
b40826
+	 unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
b40826
 	 tst-audit1 tst-audit2 \
b40826
 	 tst-stackguard1 tst-addr1 tst-thrlock \
b40826
 	 tst-unique1 tst-unique2
b40826
@@ -247,6 +248,7 @@ modules-names = testobj1 testobj2 testob
b40826
 		unload4mod1 unload4mod2 unload4mod3 unload4mod4 \
b40826
 		unload6mod1 unload6mod2 unload6mod3 \
b40826
 		unload7mod1 unload7mod2 \
b40826
+		unload8mod1 unload8mod1x unload8mod2 unload8mod3 \
b40826
 		order2mod1 order2mod2 order2mod3 order2mod4 \
b40826
 		tst-unique1mod1 tst-unique1mod2 \
b40826
 		tst-unique2mod1 tst-unique2mod2
b40826
@@ -522,6 +524,9 @@ $(objpfx)unload6mod2.so: $(libdl)
b40826
 $(objpfx)unload6mod3.so: $(libdl)
b40826
 $(objpfx)unload7mod1.so: $(libdl)
b40826
 $(objpfx)unload7mod2.so: $(objpfx)unload7mod1.so
b40826
+$(objpfx)unload8mod1.so: $(objpfx)unload8mod2.so
b40826
+$(objpfx)unload8mod2.so: $(objpfx)unload8mod3.so
b40826
+$(objpfx)unload8mod3.so: $(libdl)
b40826
 
b40826
 LDFLAGS-tst-tlsmod5.so = -nostdlib
b40826
 LDFLAGS-tst-tlsmod6.so = -nostdlib
b40826
@@ -823,6 +828,9 @@ $(objpfx)unload7: $(libdl)
b40826
 $(objpfx)unload7.out: $(objpfx)unload7mod1.so $(objpfx)unload7mod2.so
b40826
 unload7-ENV = MALLOC_PERTURB_=85
b40826
 
b40826
+$(objpfx)unload8: $(libdl)
b40826
+$(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
b40826
+
b40826
 ifdef libdl
b40826
 $(objpfx)tst-tls9-static: $(common-objpfx)dlfcn/libdl.a
b40826
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
b40826
Index: glibc-2.12-2-gc4ccff1/elf/dl-close.c
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/elf/dl-close.c
b40826
+++ glibc-2.12-2-gc4ccff1/elf/dl-close.c
b40826
@@ -421,6 +421,13 @@ _dl_close_worker (struct link_map *map)
b40826
 
b40826
 	      imap->l_scope_max = new_size;
b40826
 	    }
b40826
+	  else if (new_list != NULL)
b40826
+	    {
b40826
+	      /* We didn't change the scope array, so reset the search
b40826
+		 list.  */
b40826
+	      imap->l_searchlist.r_list = NULL;
b40826
+	      imap->l_searchlist.r_nlist = 0;
b40826
+	    }
b40826
 
b40826
 	  /* The loader is gone, so mark the object as not having one.
b40826
 	     Note: l_idx != IDX_STILL_USED -> object will be removed.  */
b40826
Index: glibc-2.12-2-gc4ccff1/elf/unload8.c
b40826
===================================================================
b40826
--- /dev/null
b40826
+++ glibc-2.12-2-gc4ccff1/elf/unload8.c
b40826
@@ -0,0 +1,33 @@
b40826
+#include <dlfcn.h>
b40826
+#include <stdio.h>
b40826
+
b40826
+int
b40826
+main (void)
b40826
+{
b40826
+  void *h = dlopen ("$ORIGIN/unload8mod1.so", RTLD_LAZY);
b40826
+  if (h == NULL)
b40826
+    {
b40826
+      puts ("dlopen unload8mod1.so failed");
b40826
+      return 1;
b40826
+    }
b40826
+
b40826
+  void *h2 = dlopen ("$ORIGIN/unload8mod1x.so", RTLD_LAZY);
b40826
+  if (h2 == NULL)
b40826
+    {
b40826
+      puts ("dlopen unload8mod1x.so failed");
b40826
+      return 1;
b40826
+    }
b40826
+  dlclose (h2);
b40826
+
b40826
+  int (*mod1) (void) = dlsym (h, "mod1");
b40826
+  if (mod1 == NULL)
b40826
+    {
b40826
+      puts ("dlsym failed");
b40826
+      return 1;
b40826
+    }
b40826
+
b40826
+  mod1 ();
b40826
+  dlclose (h);
b40826
+
b40826
+  return 0;
b40826
+}
b40826
Index: glibc-2.12-2-gc4ccff1/elf/unload8mod1.c
b40826
===================================================================
b40826
--- /dev/null
b40826
+++ glibc-2.12-2-gc4ccff1/elf/unload8mod1.c
b40826
@@ -0,0 +1,7 @@
b40826
+extern void mod2 (void);
b40826
+
b40826
+void
b40826
+mod1 (void)
b40826
+{
b40826
+  mod2 ();
b40826
+}
b40826
Index: glibc-2.12-2-gc4ccff1/elf/unload8mod1x.c
b40826
===================================================================
b40826
--- /dev/null
b40826
+++ glibc-2.12-2-gc4ccff1/elf/unload8mod1x.c
b40826
@@ -0,0 +1 @@
b40826
+int mod1x;
b40826
Index: glibc-2.12-2-gc4ccff1/elf/unload8mod2.c
b40826
===================================================================
b40826
--- /dev/null
b40826
+++ glibc-2.12-2-gc4ccff1/elf/unload8mod2.c
b40826
@@ -0,0 +1,7 @@
b40826
+extern void mod3 (void);
b40826
+
b40826
+void
b40826
+mod2 (void)
b40826
+{
b40826
+  mod3 ();
b40826
+}
b40826
Index: glibc-2.12-2-gc4ccff1/elf/unload8mod3.c
b40826
===================================================================
b40826
--- /dev/null
b40826
+++ glibc-2.12-2-gc4ccff1/elf/unload8mod3.c
b40826
@@ -0,0 +1,27 @@
b40826
+#include <dlfcn.h>
b40826
+#include <stdio.h>
b40826
+#include <stdlib.h>
b40826
+
b40826
+void
b40826
+mod3_fini2 (void)
b40826
+{
b40826
+}
b40826
+
b40826
+void
b40826
+mod3_fini (void)
b40826
+{
b40826
+  mod3_fini2 ();
b40826
+}
b40826
+
b40826
+void
b40826
+mod3 (void)
b40826
+{
b40826
+  void *h = dlopen ("$ORIGIN/unload8mod2.so", RTLD_LAZY);
b40826
+  if (h == NULL)
b40826
+    {
b40826
+      puts ("dlopen unload8mod2.so failed");
b40826
+      exit (1);
b40826
+    }
b40826
+
b40826
+  atexit (mod3_fini);
b40826
+}