This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] dlclose testcase


Hi!

The following testcase fails ATM. It is just slightly modified
reldep8, with the library causing the relocation dependency being
-z nodelete. It fails because nodel2mod1.so doesn't have itself in
its scope at the time its fini is called.

2003-01-09  Jakub Jelinek  <jakub@redhat.com>

	* elf/Makefile: Add rules to build and run nodelete2 test.
	* elf/nodelete2.c: New file.
	* elf/nodel2mod1.c: New file.
	* elf/nodel2mod2.c: New file.
	* elf/nodel2mod3.c: New file.

--- libc/elf/nodel2mod1.c.jj	2003-01-09 12:02:52.000000000 +0100
+++ libc/elf/nodel2mod1.c	2002-12-30 21:23:02.000000000 +0100
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+void
+foo (void)
+{
+  exit (0);
+}
+
+void
+__attribute__((destructor))
+bar (void)
+{
+  static int i;
+  foo ();
+  ++i;
+}
+void
+baz (void)
+{
+}
--- libc/elf/nodel2mod2.c.jj	2003-01-09 12:02:55.000000000 +0100
+++ libc/elf/nodel2mod2.c	2002-12-30 21:23:02.000000000 +0100
@@ -0,0 +1,7 @@
+void
+__attribute__((constructor))
+xxx (void)
+{
+  extern void baz (void);
+  baz ();
+}
--- libc/elf/nodel2mod3.c.jj	2003-01-09 12:02:59.000000000 +0100
+++ libc/elf/nodel2mod3.c	2002-12-30 21:23:02.000000000 +0100
@@ -0,0 +1 @@
+int x;
--- libc/elf/nodelete2.c.jj	2003-01-09 12:02:48.000000000 +0100
+++ libc/elf/nodelete2.c	2003-01-09 12:32:31.000000000 +0100
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+int
+main (void)
+{
+  void *handle = dlopen ("nodel2mod3.so", RTLD_LAZY);
+  if (handle == NULL)
+    {
+      printf ("%s\n", dlerror ());
+      exit (1);
+    }
+  dlclose (handle);
+  exit (1);
+}
--- libc/elf/Makefile.jj	2002-12-31 00:11:15.000000000 +0100
+++ libc/elf/Makefile	2003-01-09 12:07:58.000000000 +0100
@@ -73,7 +73,8 @@ distribute	:= rtld-Rules \
 		   circlemod1.c circlemod1a.c circlemod2.c circlemod2a.c \
 		   circlemod3.c circlemod3a.c nodlopenmod2.c \
 		   tls-macros.h \
-		   reldep8mod1.c reldep8mod2.c reldep8mod3.c
+		   reldep8mod1.c reldep8mod2.c reldep8mod3.c \
+		   nodel2mod1.c nodel2mod2.c nodel2mod3.c
 
 include ../Makeconfig
 
@@ -140,7 +141,7 @@ tests += loadtest restest1 preloadtest l
 	 circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8
 test-srcs = tst-pathopt
 tests-vis-yes = vismain
-tests-nodelete-yes = nodelete
+tests-nodelete-yes = nodelete nodelete2
 tests-nodlopen-yes = nodlopen nodlopen2
 endif
 modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
@@ -165,7 +166,8 @@ ifeq (yes,$(have-initfini-array))
 modules-names += tst-array2dep
 endif
 modules-vis-yes = vismod1 vismod2 vismod3
-modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
+modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4 \
+		       nodel2mod1 nodel2mod2 nodel2mod3
 modules-nodlopen-yes = nodlopenmod nodlopenmod2
 extra-objs += $(addsuffix .os,$(strip $(modules-names)))
 # We need this variable to be sure the test modules get the right CPPFLAGS.
@@ -364,6 +366,7 @@ $(objpfx)reldep6mod3.so: $(objpfx)reldep
 $(objpfx)reldep6mod4.so: $(objpfx)reldep6mod1.so
 $(objpfx)tst-tlsmod3.so: $(objpfx)tst-tlsmod2.so
 $(objpfx)reldep8mod3.so: $(objpfx)reldep8mod1.so $(objpfx)reldep8mod2.so
+$(objpfx)nodel2mod3.so: $(objpfx)nodel2mod1.so $(objpfx)nodel2mod2.so
 
 LDFLAGS-tst-tlsmod5.so = -nostdlib
 LDFLAGS-tst-tlsmod6.so = -nostdlib
@@ -531,6 +534,10 @@ $(objpfx)reldep7.out: $(objpfx)reldep7mo
 $(objpfx)reldep8: $(libdl)
 $(objpfx)reldep8.out: $(objpfx)reldep8mod3.so
 
+LDFLAGS-nodel2mod2.so = -Wl,--enable-new-dtags,-z,nodelete
+$(objpfx)nodelete2: $(libdl)
+$(objpfx)nodelete2.out: $(objpfx)nodel2mod3.so
+
 $(objpfx)tst-tls3: $(objpfx)tst-tlsmod1.so
 
 $(objpfx)tst-tls4: $(libdl)

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]