about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile10
-rw-r--r--elf/reldep7.c58
-rw-r--r--elf/reldep7mod1.c12
-rw-r--r--elf/reldep7mod2.c12
4 files changed, 89 insertions, 3 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 8819c188c0..380dc80d95 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -65,7 +65,7 @@ distribute	:= $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
 		   testobj.h vismod.h globalmod1.c \
 		   dblloadmod1.c dblloadmod2.c dblloadmod3.c \
 		   reldep6mod4.c reldep6mod3.c reldep6mod2.c reldep6mod1.c \
-		   reldep6mod0.c \
+		   reldep6mod0.c reldep7mod1.c reldep7mod2.c \
 		   unwind-dw2.c unwind-dw2-fde.c unwind.h unwind-pe.h \
 		   unwind-dw2-fde.h dwarf2.h dl-procinfo.c tls.h dl-tls.h \
 		   tls-macros.h
@@ -118,8 +118,8 @@ tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
 	reldep reldep2 reldep3 reldep4 $(tests-nodelete-$(have-z-nodelete)) \
 	$(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
 	neededtest3 neededtest4 unload2 lateglobal initfirst global \
-	restest2 next dblload dblunload reldep5 reldep6 tst-tls1 tst-tls2 \
-	tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8
+	restest2 next dblload dblunload reldep5 reldep6 reldep7 tst-tls1 \
+	tst-tls2 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8
 test-srcs = tst-pathopt
 tests-vis-yes = vismain
 tests-nodelete-yes = nodelete
@@ -137,6 +137,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
 		unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj \
 		dblloadmod1 dblloadmod2 dblloadmod3 reldepmod5 reldepmod6 \
 	        reldep6mod0 reldep6mod1 reldep6mod2 reldep6mod3 reldep6mod4 \
+		reldep7mod1 reldep7mod2 \
 		tst-tlsmod1 tst-tlsmod2 tst-tlsmod3 tst-tlsmod4
 modules-vis-yes = vismod1 vismod2 vismod3
 modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
@@ -444,6 +445,9 @@ $(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod5.so
 $(objpfx)reldep6: $(libdl)
 $(objpfx)reldep6.out: $(objpfx)reldep6mod3.so $(objpfx)reldep6mod4.so
 
+$(objpfx)reldep7: $(libdl)
+$(objpfx)reldep7.out: $(objpfx)reldep7mod1.so $(objpfx)reldep7mod2.so
+
 $(objpfx)tst-tls3: $(objpfx)tst-tlsmod1.so
 
 $(objpfx)tst-tls4: $(libdl)
diff --git a/elf/reldep7.c b/elf/reldep7.c
new file mode 100644
index 0000000000..5275a0e8f1
--- /dev/null
+++ b/elf/reldep7.c
@@ -0,0 +1,58 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  void *h1;
+  void *h2;
+  void *mod1_bar, *mod2_bar;
+
+  h1 = dlopen ("reldep7mod1.so", RTLD_GLOBAL | RTLD_LAZY);
+  if (h1 == NULL)
+    {
+      printf ("cannot open reldep7mod1.so: %s\n", dlerror ());
+      exit (1);
+    }
+
+  h2 = dlopen ("reldep7mod2.so", RTLD_GLOBAL | RTLD_LAZY);
+  if (h2 == NULL)
+    {
+      printf ("cannot open reldep7mod1.so: %s\n", dlerror ());
+      exit (1);
+    }
+
+  mod1_bar = dlsym (h1, "mod1_bar");
+  if (mod1_bar == NULL)
+    {
+      printf ("cannot get address of \"mod1_bar\": %s\n", dlerror ());
+      exit (1);
+    }
+
+  mod2_bar = dlsym (h2, "mod2_bar");
+  if (mod2_bar == NULL)
+    {
+      printf ("cannot get address of \"mod2_bar\": %s\n", dlerror ());
+      exit (1);
+    }
+
+  printf ("%d\n", ((int (*) (void)) mod1_bar) ());
+  printf ("%d\n", ((int (*) (void)) mod2_bar) ());
+
+  if (dlclose (h1) != 0)
+    {
+      printf ("closing h1 failed: %s\n", dlerror ());
+      exit (1);
+    }
+
+  printf ("%d\n", ((int (*) (void)) mod2_bar) ());
+
+  if (dlclose (h2) != 0)
+    {
+      printf ("closing h2 failed: %s\n", dlerror ());
+      exit (1);
+    }
+
+  return 0;
+}
diff --git a/elf/reldep7mod1.c b/elf/reldep7mod1.c
new file mode 100644
index 0000000000..de1bb3a6cd
--- /dev/null
+++ b/elf/reldep7mod1.c
@@ -0,0 +1,12 @@
+int foo (void) __attribute__ ((weak));
+int
+foo (void)
+{
+  return 1;
+}
+
+int
+mod1_bar (void)
+{
+  return foo ();
+}
diff --git a/elf/reldep7mod2.c b/elf/reldep7mod2.c
new file mode 100644
index 0000000000..3fa3368792
--- /dev/null
+++ b/elf/reldep7mod2.c
@@ -0,0 +1,12 @@
+int foo (void) __attribute__ ((weak));
+int
+foo (void)
+{
+  return 2;
+}
+
+int
+mod2_bar (void)
+{
+  return foo ();
+}