aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-03-19 08:04:37 +0000
committerUlrich Drepper <drepper@redhat.com>2005-03-19 08:04:37 +0000
commit3d786f1969b1000f8dd7aa96e712f0b9134b3349 (patch)
treede795ef531805f71b8a49a5e374d20d077f8d2e0 /elf
parenta2f7570bdda3e64ce32d74d7df943d306683ab8e (diff)
downloadglibc-3d786f1969b1000f8dd7aa96e712f0b9134b3349.zip
glibc-3d786f1969b1000f8dd7aa96e712f0b9134b3349.tar.gz
glibc-3d786f1969b1000f8dd7aa96e712f0b9134b3349.tar.bz2
* elf/Makefile: Add rules to build and run order2.
* elf/order2.c: New file. * elf/order2mod1.c: New file. * elf/order2mod2.c: New file. * elf/order2mod3.c: New file. * elf/order2mod4.c: New file.
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile20
-rw-r--r--elf/order2.c46
-rw-r--r--elf/order2mod1.c8
-rw-r--r--elf/order2mod2.c18
-rw-r--r--elf/order2mod3.c14
-rw-r--r--elf/order2mod4.c16
6 files changed, 119 insertions, 3 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 210b206..80a3f6c 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -86,7 +86,8 @@ distribute := rtld-Rules \
tst-deep1mod1.c tst-deep1mod2.c tst-deep1mod3.c \
unload3mod1.c unload3mod2.c unload3mod3.c unload3mod4.c \
unload4mod1.c unload4mod2.c unload4mod3.c unload4mod4.c \
- tst-auditmod1.c
+ tst-auditmod1.c \
+ order2mod1.c order2mod2.c order2mod3.c order2mod4.c
CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
@@ -161,7 +162,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-align \
tst-align2 $(tests-execstack-$(have-z-execstack)) tst-dlmodcount \
tst-dlopenrpath tst-deep1 tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
- unload3 unload4 unload5 tst-audit1 tst-global1
+ unload3 unload4 unload5 tst-audit1 tst-global1 order2
# reldep9
test-srcs = tst-pathopt
tests-vis-yes = vismain
@@ -198,7 +199,8 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
tst-dlopenrpathmod tst-deep1mod1 tst-deep1mod2 tst-deep1mod3 \
tst-dlmopen1mod tst-auditmod1 \
unload3mod1 unload3mod2 unload3mod3 unload3mod4 \
- unload4mod1 unload4mod2 unload4mod3 unload4mod4
+ unload4mod1 unload4mod2 unload4mod3 unload4mod4 \
+ order2mod1 order2mod2 order2mod3 order2mod4
ifeq (yes,$(have-initfini-array))
modules-names += tst-array2dep
endif
@@ -816,3 +818,15 @@ tst-audit1-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
$(objpfx)tst-global1: $(libdl)
$(objpfx)tst-global1.out: $(objpfx)testobj6.so $(objpfx)testobj2.so
+
+$(objpfx)order2: $(libdl)
+$(objpfx)order2.out: $(objpfx)order2 $(objpfx)order2mod1.so \
+ $(objpfx)order2mod2.so
+ $(elf-objpfx)$(rtld-installed-name) \
+ --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+ $(objpfx)order2 > $@
+ (echo "12345" | cmp $@ -) > /dev/null
+$(objpfx)order2mod1.so: $(objpfx)order2mod4.so
+$(objpfx)order2mod4.so: $(objpfx)order2mod3.so
+$(objpfx)order2mod2.so: $(objpfx)order2mod3.so
+order2mod2.so-no-z-defs = yes
diff --git a/elf/order2.c b/elf/order2.c
new file mode 100644
index 0000000..3dbfdd1
--- /dev/null
+++ b/elf/order2.c
@@ -0,0 +1,46 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+
+int call_puts;
+
+static int
+do_test (void)
+{
+ call_puts = 1;
+
+ void *h1 = dlopen ("$ORIGIN/order2mod1.so", RTLD_LAZY | RTLD_GLOBAL);
+ if (h1 == NULL)
+ {
+ puts ("cannot load order2mod1");
+ return 1;
+ }
+ void *h2 = dlopen ("$ORIGIN/order2mod2.so", RTLD_LAZY);
+ if (h2 == NULL)
+ {
+ puts ("cannot load order2mod2");
+ return 1;
+ }
+ if (dlclose (h1) != 0)
+ {
+ puts ("dlclose order2mod1 failed");
+ return 1;
+ }
+ if (dlclose (h2) != 0)
+ {
+ puts ("dlclose order2mod2 failed");
+ return 1;
+ }
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
+
+static void
+__attribute__ ((destructor))
+fini (void)
+{
+ if (call_puts)
+ puts ("5");
+}
diff --git a/elf/order2mod1.c b/elf/order2mod1.c
new file mode 100644
index 0000000..b695db2
--- /dev/null
+++ b/elf/order2mod1.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+static void
+__attribute__ ((destructor))
+fini (void)
+{
+ putchar ('1');
+}
diff --git a/elf/order2mod2.c b/elf/order2mod2.c
new file mode 100644
index 0000000..b03fb60
--- /dev/null
+++ b/elf/order2mod2.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+extern int foo (void);
+extern int bar (void);
+
+void
+__attribute__ ((constructor))
+init (void)
+{
+ foo () - bar ();
+}
+
+static void
+__attribute__ ((destructor))
+fini (void)
+{
+ putchar ('2');
+}
diff --git a/elf/order2mod3.c b/elf/order2mod3.c
new file mode 100644
index 0000000..7913a79
--- /dev/null
+++ b/elf/order2mod3.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+int
+bar (void)
+{
+ return 1;
+}
+
+static void
+__attribute__ ((destructor))
+fini (void)
+{
+ putchar ('4');
+}
diff --git a/elf/order2mod4.c b/elf/order2mod4.c
new file mode 100644
index 0000000..4f2026f
--- /dev/null
+++ b/elf/order2mod4.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+extern int bar (void);
+
+int
+foo (void)
+{
+ return 42 + bar ();
+}
+
+static void
+__attribute__ ((destructor))
+fini (void)
+{
+ putchar ('3');
+}