aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-11-07 22:28:16 +0000
committerRoland McGrath <roland@gnu.org>2002-11-07 22:28:16 +0000
commitdfe4c900cb1d03533702c453c3a9abe6d41e545d (patch)
tree3abdeee7d6276ec401eed3b7ed19772baaa8b8a0 /elf
parent1d8a0fd965535f5c48cfb1e0b9d4fb8596190cd6 (diff)
downloadglibc-dfe4c900cb1d03533702c453c3a9abe6d41e545d.zip
glibc-dfe4c900cb1d03533702c453c3a9abe6d41e545d.tar.gz
glibc-dfe4c900cb1d03533702c453c3a9abe6d41e545d.tar.bz2
* sysdeps/ia64/elf/initfini.c [HAVE_INITFINI_ARRAY]
(gmon_initializer): New function. (.init prologue): If HAVE_INITFINI_ARRAY is true, don't call __gmon_start__ here. Call it from gmon_initializer() instead. 2002-03-12 H.J. Lu <hjl@gnu.org> * elf/Makefile [$(have-initfini-array) = yes] (tests): Add tst-array1, tst-array2, and tst-array3. [$(have-initfini-array) = yes] (tests-static): Add tst-array3. [$(have-initfini-array) = yes] (modules-names): Add tst-array2dep. ($(objpfx)tst-array1.out): New target. ($(objpfx)tst-array2): Likewise. ($(objpfx)tst-array2.out): Likewise. ($(objpfx)tst-array3.out): Likewise. * elf/tst-array1.c: New file. * elf/tst-array1.exp: Likewise. * elf/tst-array2.c: Likewise. * elf/tst-array2dep.c: Likewise. * elf/tst-array2.exp: Likewise. * elf/tst-array3.c: Likewise.
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile25
-rw-r--r--elf/tst-array1.c99
-rw-r--r--elf/tst-array1.exp11
-rw-r--r--elf/tst-array2.c1
-rw-r--r--elf/tst-array2.exp19
-rw-r--r--elf/tst-array2dep.c67
-rw-r--r--elf/tst-array3.c1
7 files changed, 223 insertions, 0 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 0153522..a6d96c6 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -117,6 +117,9 @@ endif
endif
tests = tst-tls1 tst-tls2 tst-tls9
+ifeq (yes,$(have-initfini-array))
+tests += tst-array1 tst-array2 tst-array3
+endif
ifeq (yes,$(build-static))
tests-static = tst-tls1-static tst-tls2-static
ifeq (yesyesyes,$(build-static)$(build-shared)$(elf))
@@ -156,6 +159,9 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
tst-tlsmod5 tst-tlsmod6 \
circlemod1 circlemod1a circlemod2 circlemod2a \
circlemod3 circlemod3a
+ifeq (yes,$(have-initfini-array))
+modules-names += tst-array2dep
+endif
modules-vis-yes = vismod1 vismod2 vismod3
modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
modules-nodlopen-yes = nodlopenmod nodlopenmod2
@@ -543,3 +549,22 @@ ifdef libdl
$(objpfx)tst-tls9-static: $(common-objpfx)dlfcn/libdl.a
$(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
endif
+
+$(objpfx)tst-array1.out: $(objpfx)tst-array1
+ $(elf-objpfx)$(rtld-installed-name) \
+ --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+ $(objpfx)tst-array1 > $@
+ cmp $@ tst-array1.exp > /dev/null
+
+$(objpfx)tst-array2: $(objpfx)tst-array2dep.so
+$(objpfx)tst-array2.out: $(objpfx)tst-array2
+ $(elf-objpfx)$(rtld-installed-name) \
+ --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+ $(objpfx)tst-array2 > $@
+ cmp $@ tst-array2.exp > /dev/null
+
+$(objpfx)tst-array3.out: $(objpfx)tst-array3
+ $(elf-objpfx)$(rtld-installed-name) \
+ --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
+ $(objpfx)tst-array3 > $@
+ cmp $@ tst-array1.exp > /dev/null
diff --git a/elf/tst-array1.c b/elf/tst-array1.c
new file mode 100644
index 0000000..86ed4a1
--- /dev/null
+++ b/elf/tst-array1.c
@@ -0,0 +1,99 @@
+#include <unistd.h>
+
+static void init (void) __attribute__ ((constructor));
+
+static void
+init (void)
+{
+ write (STDOUT_FILENO, "init\n", 5);
+}
+
+static void fini (void) __attribute__ ((destructor));
+
+static void
+fini (void)
+{
+ write (STDOUT_FILENO, "fini\n", 5);
+}
+
+static void
+preinit_0 (void)
+{
+ write (STDOUT_FILENO, "preinit array 0\n", 16);
+}
+
+static void
+preinit_1 (void)
+{
+ write (STDOUT_FILENO, "preinit array 1\n", 16);
+}
+
+static void
+preinit_2 (void)
+{
+ write (STDOUT_FILENO, "preinit array 2\n", 16);
+}
+
+void (*const preinit_array []) (void)
+ __attribute__ ((section (".preinit_array"))) =
+{
+ &preinit_0,
+ &preinit_1,
+ &preinit_2
+};
+
+static void
+init_0 (void)
+{
+ write (STDOUT_FILENO, "init array 0\n", 13);
+}
+
+static void
+init_1 (void)
+{
+ write (STDOUT_FILENO, "init array 1\n", 13);
+}
+
+static void
+init_2 (void)
+{
+ write (STDOUT_FILENO, "init array 2\n", 13);
+}
+
+void (*const init_array []) (void) __attribute__ ((section (".init_array"))) =
+{
+ &init_0,
+ &init_1,
+ &init_2
+};
+
+static void
+fini_0 (void)
+{
+ write (STDOUT_FILENO, "fini array 0\n", 13);
+}
+
+static void
+fini_1 (void)
+{
+ write (STDOUT_FILENO, "fini array 1\n", 13);
+}
+
+static void
+fini_2 (void)
+{
+ write (STDOUT_FILENO, "fini array 2\n", 13);
+}
+
+void (*const fini_array []) (void) __attribute__ ((section (".fini_array"))) =
+{
+ &fini_0,
+ &fini_1,
+ &fini_2
+};
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/elf/tst-array1.exp b/elf/tst-array1.exp
new file mode 100644
index 0000000..cfcec9d
--- /dev/null
+++ b/elf/tst-array1.exp
@@ -0,0 +1,11 @@
+preinit array 0
+preinit array 1
+preinit array 2
+init
+init array 0
+init array 1
+init array 2
+fini array 2
+fini array 1
+fini array 0
+fini
diff --git a/elf/tst-array2.c b/elf/tst-array2.c
new file mode 100644
index 0000000..21539a4
--- /dev/null
+++ b/elf/tst-array2.c
@@ -0,0 +1 @@
+#include "tst-array1.c"
diff --git a/elf/tst-array2.exp b/elf/tst-array2.exp
new file mode 100644
index 0000000..ed20352
--- /dev/null
+++ b/elf/tst-array2.exp
@@ -0,0 +1,19 @@
+preinit array 0
+preinit array 1
+preinit array 2
+DSO init
+DSO init array 0
+DSO init array 1
+DSO init array 2
+init
+init array 0
+init array 1
+init array 2
+fini array 2
+fini array 1
+fini array 0
+fini
+DSO fini array 2
+DSO fini array 1
+DSO fini array 0
+DSO fini
diff --git a/elf/tst-array2dep.c b/elf/tst-array2dep.c
new file mode 100644
index 0000000..be46dd1
--- /dev/null
+++ b/elf/tst-array2dep.c
@@ -0,0 +1,67 @@
+#include <unistd.h>
+
+static void init (void) __attribute__ ((constructor));
+
+static void
+init (void)
+{
+ write (STDOUT_FILENO, "DSO init\n", 9);
+}
+
+static void fini (void) __attribute__ ((destructor));
+
+static void
+fini (void)
+{
+ write (STDOUT_FILENO, "DSO fini\n", 9);
+}
+
+static void
+init_0 (void)
+{
+ write (STDOUT_FILENO, "DSO init array 0\n", 17);
+}
+
+static void
+init_1 (void)
+{
+ write (STDOUT_FILENO, "DSO init array 1\n", 17);
+}
+
+static void
+init_2 (void)
+{
+ write (STDOUT_FILENO, "DSO init array 2\n", 17);
+}
+
+void (*const init_array []) (void) __attribute__ ((section (".init_array"))) =
+{
+ &init_0,
+ &init_1,
+ &init_2
+};
+
+static void
+fini_0 (void)
+{
+ write (STDOUT_FILENO, "DSO fini array 0\n", 17);
+}
+
+static void
+fini_1 (void)
+{
+ write (STDOUT_FILENO, "DSO fini array 1\n", 17);
+}
+
+static void
+fini_2 (void)
+{
+ write (STDOUT_FILENO, "DSO fini array 2\n", 17);
+}
+
+void (*const fini_array []) (void) __attribute__ ((section (".fini_array"))) =
+{
+ &fini_0,
+ &fini_1,
+ &fini_2
+};
diff --git a/elf/tst-array3.c b/elf/tst-array3.c
new file mode 100644
index 0000000..21539a4
--- /dev/null
+++ b/elf/tst-array3.c
@@ -0,0 +1 @@
+#include "tst-array1.c"