summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--elf/Makefile18
-rw-r--r--elf/dblload.c53
-rw-r--r--elf/dblloadmod1.c7
-rw-r--r--elf/dblloadmod2.c13
-rw-r--r--elf/dblloadmod3.c7
-rw-r--r--elf/dblunload.c53
7 files changed, 157 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b74c1b6420..8b8cdd0bd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-09-05  Ulrich Drepper  <drepper@redhat.com>
+
+	* elf/Makefile: Add rules to build new tests.  Don't run them yet since
+	they both fail.
+	* elf/dblload.c: New file.
+	* elf/dblloadmod1.c: New file.
+	* elf/dblloadmod2.c: New file.
+	* elf/dblloadmod3.c: New file.
+	* elf/dblunload.c: New file.
+
 2001-09-04  Richard Henderson  <rth@redhat.com>
 
 	* elf/elf.h (R_ALPHA_OP_*, R_ALPHA_IMMED_*): Remove.
diff --git a/elf/Makefile b/elf/Makefile
index 1418a8f57f..0831662715 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -60,7 +60,8 @@ distribute	:= $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
 		   neededobj1.c neededobj2.c neededobj3.c neededobj4.c \
 		   neededobj5.c neededobj6.c firstobj.c \
 		   unload2mod.c unload2dep.c ltglobmod1.c ltglobmod2.c \
-		   testobj.h vismod.h globalmod1.c
+		   testobj.h vismod.h globalmod1.c \
+		   dblloadmod1.c dblloadmod2.c dblloadmod3.c
 
 include ../Makeconfig
 
@@ -102,10 +103,10 @@ endif
 ifeq (yes,$(build-shared))
 tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
 	constload1 order $(tests-vis-$(have-protected)) noload filter unload \
-	reldep reldep2 reldep3 reldep4 next $(tests-nodelete-$(have-z-nodelete)) \
+	reldep reldep2 reldep3 reldep4 $(tests-nodelete-$(have-z-nodelete)) \
 	$(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
 	neededtest3 neededtest4 unload2 lateglobal initfirst global \
-	restest2
+	restest2 next #dblload dblunload
 test-srcs = tst-pathopt
 tests-vis-yes = vismain
 tests-nodelete-yes = nodelete
@@ -120,7 +121,8 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
 		reldep4mod1 reldep4mod2 reldep4mod3 reldep4mod4 \
 		neededobj1 neededobj2 neededobj3 neededobj4 \
 		neededobj5 neededobj6 firstobj globalmod1 \
-		unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj
+		unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj \
+		dblloadmod1 dblloadmod2 dblloadmod3
 modules-vis-yes = vismod1 vismod2 vismod3
 modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
 modules-nodlopen-yes = nodlopenmod
@@ -281,6 +283,8 @@ $(objpfx)firstobj.so: $(shared-thread-library)
 $(objpfx)globalmod1.so: $(libdl)
 $(objpfx)reldep4mod1.so: $(objpfx)reldep4mod3.so
 $(objpfx)reldep4mod2.so: $(objpfx)reldep4mod4.so
+$(objpfx)dblloadmod1.so: $(objpfx)dblloadmod3.so
+$(objpfx)dblloadmod2.so: $(objpfx)dblloadmod3.so
 
 # filtmod1.so has a special rule
 $(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
@@ -413,3 +417,9 @@ $(objpfx)initfirst.out: $(objpfx)firstobj.so
 
 $(objpfx)global: $(objpfx)globalmod1.so
 $(objpfx)global.out: $(objpfx)reldepmod1.so
+
+$(objpfx)dblload: $(libdl)
+$(objpfx)dblload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
+
+$(objpfx)dblunload: $(libdl)
+$(objpfx)dblunload.out: $(objpfx)dblloadmod1.so $(objpfx)dblloadmod2.so
diff --git a/elf/dblload.c b/elf/dblload.c
new file mode 100644
index 0000000000..52389a60ce
--- /dev/null
+++ b/elf/dblload.c
@@ -0,0 +1,53 @@
+#include <dlfcn.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main (void)
+{
+  void *p1;
+  void *p2;
+  int (*fp) (void);
+  int result;
+
+  mtrace ();
+
+  p1 = dlopen ("dblloadmod1.so", RTLD_LAZY);
+  if (p1 == NULL)
+    {
+      printf ("cannot open dblloadmod1.so: %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  p2 = dlopen ("dblloadmod2.so", RTLD_LAZY);
+  if (p1 == NULL)
+    {
+      printf ("cannot open dblloadmod2.so: %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  fp = dlsym (p1, "foo");
+  if (fp == NULL)
+    {
+      printf ("cannot get function \"foo\": %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  result = fp ();
+
+  if (dlclose (p1) != 0)
+    {
+      printf ("error while closing dblloadmod1.so: %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  if (dlclose (p2) != 0)
+    {
+      printf ("error while closing dblloadmod2.so: %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  return result;
+}
diff --git a/elf/dblloadmod1.c b/elf/dblloadmod1.c
new file mode 100644
index 0000000000..b10f366ee9
--- /dev/null
+++ b/elf/dblloadmod1.c
@@ -0,0 +1,7 @@
+extern int bar (void);
+
+int
+foo (void)
+{
+  return 10 + bar ();
+}
diff --git a/elf/dblloadmod2.c b/elf/dblloadmod2.c
new file mode 100644
index 0000000000..261af2b580
--- /dev/null
+++ b/elf/dblloadmod2.c
@@ -0,0 +1,13 @@
+extern int bar (void);
+
+int
+baz (void)
+{
+  return -42;
+}
+
+int
+xyzzy (void)
+{
+  return 10 + bar ();
+}
diff --git a/elf/dblloadmod3.c b/elf/dblloadmod3.c
new file mode 100644
index 0000000000..22b8a04811
--- /dev/null
+++ b/elf/dblloadmod3.c
@@ -0,0 +1,7 @@
+extern int baz (void);
+
+int
+bar (void)
+{
+  return 32 + baz ();
+}
diff --git a/elf/dblunload.c b/elf/dblunload.c
new file mode 100644
index 0000000000..ab0b2a5e9e
--- /dev/null
+++ b/elf/dblunload.c
@@ -0,0 +1,53 @@
+#include <dlfcn.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main (void)
+{
+  void *p1;
+  void *p2;
+  int (*fp) (void);
+  int result;
+
+  mtrace ();
+
+  p1 = dlopen ("dblloadmod1.so", RTLD_LAZY);
+  if (p1 == NULL)
+    {
+      printf ("cannot load dblloadmod1.so: %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  p2 = dlopen ("dblloadmod2.so", RTLD_LAZY);
+  if (p2 == NULL)
+    {
+      printf ("cannot load dblloadmod2.so: %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  if (dlclose (p1) != 0)
+    {
+      printf ("error while closing dblloadmod1.so: %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  fp = dlsym (p2, "xyzzy");
+  if (fp == NULL)
+    {
+      printf ("cannot get function \"xyzzy\": %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  result = fp ();
+
+  if (dlclose (p2) != 0)
+    {
+      printf ("error while closing dblloadmod2.so: %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  return result;
+}