about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile9
-rw-r--r--elf/dl-close.c4
-rw-r--r--elf/reldep4.c40
-rw-r--r--elf/reldep4mod1.c7
-rw-r--r--elf/reldep4mod2.c6
-rw-r--r--elf/reldep4mod3.c7
-rw-r--r--elf/reldep4mod4.c6
7 files changed, 76 insertions, 3 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 39253e3709..e45d89d62f 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -53,6 +53,7 @@ distribute	:= $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
 		   nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \
 		   nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h \
 		   reldepmod1.c reldepmod2.c reldepmod3.c reldepmod4.c \
+		   reldep4mod1.c reldep4mod2.c reldep4mod3.c reldep4mod4.c \
 		   nextmod1.c nextmod2.c pathoptobj.c tst-pathopt.sh \
 		   neededobj1.c neededobj2.c neededobj3.c neededobj4.c \
 		   neededobj5.c neededobj6.c firstobj.c \
@@ -99,7 +100,7 @@ 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 next $(tests-nodelete-$(have-z-nodelete)) \
+	reldep reldep2 reldep3 reldep4 next $(tests-nodelete-$(have-z-nodelete)) \
 	$(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
 	neededtest3 neededtest4 unload2 lateglobal initfirst global \
 	restest2
@@ -114,6 +115,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
 		$(modules-nodelete-$(have-z-nodelete)) \
 		$(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \
 		reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
+		reldep4mod1 reldep4mod2 reldep4mod3 reldep4mod4 \
 		neededobj1 neededobj2 neededobj3 neededobj4 \
 		neededobj5 neededobj6 firstobj globalmod1 \
 		unload2mod unload2dep ltglobmod1 ltglobmod2 pathoptobj
@@ -275,6 +277,8 @@ $(objpfx)unload2mod.so: $(objpfx)unload2dep.so
 $(objpfx)ltglobmod2.so: $(libdl)
 $(objpfx)firstobj.so: $(shared-thread-library)
 $(objpfx)globalmod1.so: $(libdl)
+$(objpfx)reldep4mod1.so: $(objpfx)reldep4mod3.so
+$(objpfx)reldep4mod2.so: $(objpfx)reldep4mod4.so
 
 # filtmod1.so has a special rule
 $(filter-out $(objpfx)filtmod1.so, $(test-modules)): $(objpfx)%.so: $(objpfx)%.os
@@ -386,6 +390,9 @@ $(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so
 $(objpfx)reldep3: $(libdl)
 $(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
 
+$(objpfx)reldep4: $(libdl)
+$(objpfx)reldep4.out: $(objpfx)reldep4mod1.so $(objpfx)reldep4mod2.so
+
 $(objpfx)next: $(objpfx)nextmod1.so $(objpfx)nextmod2.so $(libdl)
 
 $(objpfx)unload2: $(libdl)
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 7dce7d0f48..10a906d12e 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -224,8 +224,8 @@ _dl_close (void *_map)
 	      struct reldep_list *newrel;
 
 	      newrel = (struct reldep_list *) alloca (sizeof (*reldeps));
-	      newrel->rellist = map->l_reldeps;
-	      newrel->nrellist = map->l_reldepsact;
+	      newrel->rellist = imap->l_reldeps;
+	      newrel->nrellist = imap->l_reldepsact;
 	      newrel->next = reldeps;
 
 	      reldeps = newrel;
diff --git a/elf/reldep4.c b/elf/reldep4.c
new file mode 100644
index 0000000000..e8ab6d23de
--- /dev/null
+++ b/elf/reldep4.c
@@ -0,0 +1,40 @@
+#include <dlfcn.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main()
+{
+  int i;
+  void *h1, *h2;
+
+  mtrace ();
+
+  for (i = 0; i < 3; i++)
+    {
+      h1 = dlopen ("reldep4mod1.so", RTLD_NOW | RTLD_GLOBAL);
+      if (h1 == NULL)
+	{
+	  printf ("cannot open reldep4mod1.so: %s\n", dlerror ());
+	  exit (1);
+	}
+      h2 = dlopen ("reldep4mod2.so", RTLD_NOW | RTLD_GLOBAL);
+      if (h2 == NULL)
+	{
+	  printf ("cannot open reldep4mod2.so: %s\n", dlerror ());
+	  exit (1);
+	}
+      if (dlclose (h1) != 0)
+	{
+	  printf ("closing h1 failed: %s\n", dlerror ());
+	  exit (1);
+	}
+      if (dlclose (h2) != 0)
+	{
+	  printf ("closing h2 failed: %s\n", dlerror ());
+	  exit (1);
+	}
+    }
+  return 0;
+}
diff --git a/elf/reldep4mod1.c b/elf/reldep4mod1.c
new file mode 100644
index 0000000000..934a68096e
--- /dev/null
+++ b/elf/reldep4mod1.c
@@ -0,0 +1,7 @@
+int foo (void);
+
+int foo (void)
+{
+  return 0;
+}
+
diff --git a/elf/reldep4mod2.c b/elf/reldep4mod2.c
new file mode 100644
index 0000000000..bb7bd7cfc0
--- /dev/null
+++ b/elf/reldep4mod2.c
@@ -0,0 +1,6 @@
+extern int foo();
+
+int bar ()
+{
+  foo();
+}
diff --git a/elf/reldep4mod3.c b/elf/reldep4mod3.c
new file mode 100644
index 0000000000..934a68096e
--- /dev/null
+++ b/elf/reldep4mod3.c
@@ -0,0 +1,7 @@
+int foo (void);
+
+int foo (void)
+{
+  return 0;
+}
+
diff --git a/elf/reldep4mod4.c b/elf/reldep4mod4.c
new file mode 100644
index 0000000000..bb7bd7cfc0
--- /dev/null
+++ b/elf/reldep4mod4.c
@@ -0,0 +1,6 @@
+extern int foo();
+
+int bar ()
+{
+  foo();
+}