aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--elf/Makefile7
-rw-r--r--elf/nodelete.c54
-rw-r--r--elf/nodelmod3.c7
-rw-r--r--elf/nodelmod4.c1
-rw-r--r--elf/nodlopen.c15
-rw-r--r--elf/nodlopenmod.c1
7 files changed, 89 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 197b26d..7c13984 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
2000-07-20 Ulrich Drepper <drepper@redhat.com>
+ * elf/Makefile: Add no modules for nodelete test.
+ * elf/nodelmod3.c: New file.
+ * elf/nodelmod4.c: New file.
+ * elf/nodelete.c: Also test case where dependency of dlopen() object
+ is marked nodelete.
+
* elf/Makefile (tests): Add nodlopen. Add rules to generate nodlopen.
+ * elf/nodlopen.c: New file.
+ * elf/nodlopenmod.c: New file.
* include/dlfcn.h: Define __RTLD_DLOPEN.
* elf/dl-load.c (_dl_map_object_from_fd): If DF_1_NOOPEN is set
and this is a dlopen() call, do not load the binary.
diff --git a/elf/Makefile b/elf/Makefile
index b18aafe..2da8aca 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -98,7 +98,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
$(modules-nodelete-$(have-z-nodelete)) \
$(modules-nodlopen-$(have-z-nodlopen))
modules-vis-yes = vismod1 vismod2 vismod3
-modules-nodelete-yes = nodelmod1 nodelmod2
+modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
modules-nodlopen-yes = nodlopenmod
extra-objs += $(addsuffix .os,$(strip $(modules-names)))
@@ -242,6 +242,7 @@ $(objpfx)failobj.so: $(objpfx)testobj6.so
$(objpfx)dep1.so: $(objpfx)dep2.so $(objpfx)dep4.so
$(objpfx)dep2.so: $(objpfx)dep3.so $(objpfx)dep4.so
$(objpfx)dep4.so: $(objpfx)dep3.so
+$(objpfx)nodelmod3.so: $(objpfx)nodelmod4.so
$(test-modules): $(objpfx)%.so: $(objpfx)%.os
$(build-module)
@@ -304,8 +305,10 @@ LDFLAGS-noload = -rdynamic
$(objpfx)noload.out: $(objpfx)testobj5.so
LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
+LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
$(objpfx)nodelete: $(libdl)
-$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so
+$(objpfx)nodelete.out: $(objpfx)nodelmod1.so $(objpfx)nodelmod2.so \
+ $(objpfx)nodelmod3.so
LDFLAGS-nodlopenmod.so = -Wl,--enable-new-dtags,-z,nodlopen
$(objpfx)nodlopen: $(libdl)
diff --git a/elf/nodelete.c b/elf/nodelete.c
index 317a2a0..0a87e02 100644
--- a/elf/nodelete.c
+++ b/elf/nodelete.c
@@ -41,7 +41,7 @@ do_test (void)
p = dlopen ("nodelmod1.so", RTLD_LAZY);
if (p == NULL)
{
- puts ("failed to load \"nodelmod1.so\"");
+ printf ("failed to load \"nodelmod1.so\": %s\n", dlerror ());
result = 1;
}
else
@@ -89,7 +89,7 @@ do_test (void)
p = dlopen ("nodelmod2.so", RTLD_LAZY | RTLD_NODELETE);
if (p == NULL)
{
- puts ("failed to load \"nodelmod2.so\"");
+ printf ("failed to load \"nodelmod2.so\": %s\n", dlerror ());
result = 1;
}
else
@@ -134,6 +134,56 @@ do_test (void)
}
}
+ p = dlopen ("nodelmod3.so", RTLD_LAZY);
+ if (p == NULL)
+ {
+ printf ("failed to load \"nodelmod3.so\": %s\n", dlerror ());
+ result = 1;
+ }
+ else
+ {
+ int *(*fctp) (void);
+
+ puts ("succeeded loading \"nodelmod3.so\"");
+
+ fctp = dlsym (p, "addr");
+ if (fctp == NULL)
+ {
+ puts ("failed to get address of \"addr\" in \"nodelmod3.so\"");
+ result = 1;
+ }
+ else
+ {
+ int *varp = fctp ();
+
+ *varp = -1;
+
+ /* Now close the object. */
+ if (dlclose (p) != 0)
+ {
+ puts ("failed to close \"nodelmod3.so\"");
+ result = 1;
+ }
+ else if (! sigsetjmp (jmpbuf, 1))
+ {
+ /* Access the variable again. */
+ if (*varp != -1)
+ {
+ puts ("\"var_in_mod4\" value not correct");
+ result = 1;
+ }
+ else
+ puts ("-z nodelete in dependency succeeded");
+ }
+ else
+ {
+ /* We caught an segmentation fault. */
+ puts ("\"nodelmod4.so\" got deleted");
+ result = 1;
+ }
+ }
+ }
+
return result;
}
diff --git a/elf/nodelmod3.c b/elf/nodelmod3.c
new file mode 100644
index 0000000..c48a1a6
--- /dev/null
+++ b/elf/nodelmod3.c
@@ -0,0 +1,7 @@
+extern int var_in_mod4;
+
+int *
+addr (void)
+{
+ return &var_in_mod4;
+}
diff --git a/elf/nodelmod4.c b/elf/nodelmod4.c
new file mode 100644
index 0000000..55eb6e6
--- /dev/null
+++ b/elf/nodelmod4.c
@@ -0,0 +1 @@
+int var_in_mod4 = 99;
diff --git a/elf/nodlopen.c b/elf/nodlopen.c
new file mode 100644
index 0000000..642bdb3
--- /dev/null
+++ b/elf/nodlopen.c
@@ -0,0 +1,15 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+ if (dlopen ("nodlopenmod.so", RTLD_LAZY) != NULL)
+ {
+ puts ("opening \"nodlopenmod.so\" succeeded, FAIL");
+ return 1;
+ }
+
+ puts ("opening \"nodlopenmod.so\" failed, OK");
+ return 0;
+}
diff --git a/elf/nodlopenmod.c b/elf/nodlopenmod.c
new file mode 100644
index 0000000..4bcf8c9
--- /dev/null
+++ b/elf/nodlopenmod.c
@@ -0,0 +1 @@
+int a = 42;