Run --gc-sections tests only if supported.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / init-mixed.c
CommitLineData
02ecc8e9
L
1#include <stdio.h>
2#include <stdlib.h>
3
4#include "config.h"
5
6#ifdef HAVE_INITFINI_ARRAY
7static int count;
8
9static void
10init1005 ()
11{
12 if (count != 0)
13 abort ();
14 count = 1005;
15}
16void (*const init_array1005[]) ()
17 __attribute__ ((section (".init_array.01005"), aligned (sizeof (void *))))
18 = { init1005 };
19static void
20fini1005 ()
21{
22 if (count != 1005)
23 abort ();
24}
25void (*const fini_array1005[]) ()
26 __attribute__ ((section (".fini_array.01005"), aligned (sizeof (void *))))
27 = { fini1005 };
28
29static void
310fd250 30ctor1007a ()
02ecc8e9
L
31{
32 if (count != 1005)
33 abort ();
310fd250
L
34 count = 1006;
35}
36static void
37ctor1007b ()
38{
39 if (count != 1006)
40 abort ();
02ecc8e9
L
41 count = 1007;
42}
43void (*const ctors1007[]) ()
44 __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *))))
310fd250 45 = { ctor1007b, ctor1007a };
02ecc8e9 46static void
310fd250 47dtor1007a ()
02ecc8e9 48{
310fd250 49 if (count != 1006)
02ecc8e9
L
50 abort ();
51 count = 1005;
52}
310fd250
L
53static void
54dtor1007b ()
55{
56 if (count != 1007)
57 abort ();
58 count = 1006;
59}
02ecc8e9
L
60void (*const dtors1007[]) ()
61 __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *))))
310fd250 62 = { dtor1007b, dtor1007a };
02ecc8e9
L
63
64static void
65init65530 ()
66{
67 if (count != 1007)
68 abort ();
69 count = 65530;
70}
71void (*const init_array65530[]) ()
72 __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *))))
73 = { init65530 };
74static void
75fini65530 ()
76{
77 if (count != 65530)
78 abort ();
79 count = 1007;
80}
81void (*const fini_array65530[]) ()
82 __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *))))
83 = { fini65530 };
84
85static void
310fd250 86ctor65535a ()
02ecc8e9
L
87{
88 if (count != 65530)
89 abort ();
90 count = 65535;
91}
310fd250
L
92static void
93ctor65535b ()
94{
95 if (count != 65535)
96 abort ();
97 count = 65536;
98}
02ecc8e9
L
99void (*const ctors65535[]) ()
100 __attribute__ ((section (".ctors"), aligned (sizeof (void *))))
310fd250
L
101 = { ctor65535b, ctor65535a };
102static void
103dtor65535b ()
104{
105 if (count != 65536)
106 abort ();
107 count = 65535;
108}
02ecc8e9 109static void
310fd250 110dtor65535a ()
02ecc8e9
L
111{
112 if (count != 65535)
113 abort ();
114 count = 65530;
115}
116void (*const dtors65535[]) ()
117 __attribute__ ((section (".dtors"), aligned (sizeof (void *))))
310fd250 118 = { dtor65535b, dtor65535a };
02ecc8e9
L
119#endif
120
121int
122main ()
123{
124 printf ("OK\n");
125 return 0;
126}
This page took 0.057902 seconds and 4 git commands to generate.