about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dep1.c24
-rw-r--r--elf/dep2.c24
-rw-r--r--elf/dep3.c21
-rw-r--r--elf/dep4.c23
-rw-r--r--elf/dl-init.c2
-rw-r--r--elf/order.c23
6 files changed, 116 insertions, 1 deletions
diff --git a/elf/dep1.c b/elf/dep1.c
new file mode 100644
index 0000000000..49dc2a22d9
--- /dev/null
+++ b/elf/dep1.c
@@ -0,0 +1,24 @@
+#include <unistd.h>
+
+extern int dep2 (void);
+extern int dep4 (void);
+
+static void
+__attribute__ ((constructor))
+init (void)
+{
+  write (1, "3", 1);
+}
+
+static void
+__attribute__ ((destructor))
+fini (void)
+{
+  write (1, "6", 1);
+}
+
+int
+dep1 (void)
+{
+  return dep4 () - dep2 ();
+}
diff --git a/elf/dep2.c b/elf/dep2.c
new file mode 100644
index 0000000000..9dc5cfcf55
--- /dev/null
+++ b/elf/dep2.c
@@ -0,0 +1,24 @@
+#include <unistd.h>
+
+extern int dep3 (void);
+extern int dep4 (void);
+
+static void
+__attribute__ ((constructor))
+init (void)
+{
+  write (1, "2", 1);
+}
+
+static void
+__attribute__ ((destructor))
+fini (void)
+{
+  write (1, "7", 1);
+}
+
+int
+dep2 (void)
+{
+  return dep3 () - dep4 ();
+}
diff --git a/elf/dep3.c b/elf/dep3.c
new file mode 100644
index 0000000000..ec7c7d36d7
--- /dev/null
+++ b/elf/dep3.c
@@ -0,0 +1,21 @@
+#include <unistd.h>
+
+static void
+__attribute__ ((constructor))
+init (void)
+{
+  write (1, "0", 1);
+}
+
+static void
+__attribute__ ((destructor))
+fini (void)
+{
+  write (1, "9\n", 2);
+}
+
+int
+dep3 (void)
+{
+  return 42;
+}
diff --git a/elf/dep4.c b/elf/dep4.c
new file mode 100644
index 0000000000..9aad67d659
--- /dev/null
+++ b/elf/dep4.c
@@ -0,0 +1,23 @@
+#include <unistd.h>
+
+extern int dep3 (void);
+
+static void
+__attribute__ ((constructor))
+init (void)
+{
+  write (1, "1", 1);
+}
+
+static void
+__attribute__ ((destructor))
+fini (void)
+{
+  write (1, "8", 1);
+}
+
+int
+dep4 (void)
+{
+  return dep3 ();
+}
diff --git a/elf/dl-init.c b/elf/dl-init.c
index 911e089912..b455f5dc64 100644
--- a/elf/dl-init.c
+++ b/elf/dl-init.c
@@ -111,7 +111,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
 	  init (argc, argv, env);
 	}
 
-      /* Next see whether there is an array with initialiazation functions.  */
+      /* Next see whether there is an array with initialization functions.  */
       if (l->l_info[DT_INIT_ARRAY] != NULL)
 	{
 	  unsigned int j;
diff --git a/elf/order.c b/elf/order.c
new file mode 100644
index 0000000000..4544591c50
--- /dev/null
+++ b/elf/order.c
@@ -0,0 +1,23 @@
+#include <unistd.h>
+
+void
+__attribute__ ((constructor))
+init (void)
+{
+  write (1, "4", 1);
+}
+
+void
+__attribute__ ((destructor))
+fini (void)
+{
+  write (1, "5", 1);
+}
+
+extern int dep1 (void);
+
+int
+main (void)
+{
+  return dep1 () != 42;
+}