about summary refs log tree commit diff
path: root/elf/nodelete.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-07-21 04:42:21 +0000
committerUlrich Drepper <drepper@redhat.com>2000-07-21 04:42:21 +0000
commit2cb8cefbd42def9331fde5d8101b3f208440b60c (patch)
treee385f396a415ad549dc5f425a42b439ef079c71c /elf/nodelete.c
parent2f54c82dacba646139a773ab43fc2cdb47ee1f5b (diff)
downloadglibc-2cb8cefbd42def9331fde5d8101b3f208440b60c.tar.gz
glibc-2cb8cefbd42def9331fde5d8101b3f208440b60c.tar.xz
glibc-2cb8cefbd42def9331fde5d8101b3f208440b60c.zip
Update.
	* 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/nodlopen.c: New file.
	* elf/nodlopenmod.c: New file.
Diffstat (limited to 'elf/nodelete.c')
-rw-r--r--elf/nodelete.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/elf/nodelete.c b/elf/nodelete.c
index 317a2a03e1..0a87e02480 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;
 }