Add SORT_BY_INIT_PRIORITY.
[binutils.git] / ld / testsuite / ld-elf / init-mixed.c
blob1d0c72716a2ac14208497a6aec3aadeb5a60e5e1
1 #include <stdio.h>
2 #include <stdlib.h>
4 #include "config.h"
6 #ifdef HAVE_INITFINI_ARRAY
7 static int count;
9 static void
10 init1005 ()
12 if (count != 0)
13 abort ();
14 count = 1005;
16 void (*const init_array1005[]) ()
17 __attribute__ ((section (".init_array.01005"), aligned (sizeof (void *))))
18 = { init1005 };
19 static void
20 fini1005 ()
22 if (count != 1005)
23 abort ();
25 void (*const fini_array1005[]) ()
26 __attribute__ ((section (".fini_array.01005"), aligned (sizeof (void *))))
27 = { fini1005 };
29 static void
30 ctor1007 ()
32 if (count != 1005)
33 abort ();
34 count = 1007;
36 void (*const ctors1007[]) ()
37 __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *))))
38 = { ctor1007 };
39 static void
40 dtor1007 ()
42 if (count != 1007)
43 abort ();
44 count = 1005;
46 void (*const dtors1007[]) ()
47 __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *))))
48 = { dtor1007 };
50 static void
51 init65530 ()
53 if (count != 1007)
54 abort ();
55 count = 65530;
57 void (*const init_array65530[]) ()
58 __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *))))
59 = { init65530 };
60 static void
61 fini65530 ()
63 if (count != 65530)
64 abort ();
65 count = 1007;
67 void (*const fini_array65530[]) ()
68 __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *))))
69 = { fini65530 };
71 static void
72 ctor65535 ()
74 if (count != 65530)
75 abort ();
76 count = 65535;
78 void (*const ctors65535[]) ()
79 __attribute__ ((section (".ctors"), aligned (sizeof (void *))))
80 = { ctor65535 };
81 static void
82 dtor65535 ()
84 if (count != 65535)
85 abort ();
86 count = 65530;
88 void (*const dtors65535[]) ()
89 __attribute__ ((section (".dtors"), aligned (sizeof (void *))))
90 = { dtor65535 };
91 #endif
93 int
94 main ()
96 printf ("OK\n");
97 return 0;