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