PR 12739
[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
30ctor1007 ()
31{
32 if (count != 1005)
33 abort ();
34 count = 1007;
35}
36void (*const ctors1007[]) ()
37 __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *))))
38 = { ctor1007 };
39static void
40dtor1007 ()
41{
42 if (count != 1007)
43 abort ();
44 count = 1005;
45}
46void (*const dtors1007[]) ()
47 __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *))))
48 = { dtor1007 };
49
50static void
51init65530 ()
52{
53 if (count != 1007)
54 abort ();
55 count = 65530;
56}
57void (*const init_array65530[]) ()
58 __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *))))
59 = { init65530 };
60static void
61fini65530 ()
62{
63 if (count != 65530)
64 abort ();
65 count = 1007;
66}
67void (*const fini_array65530[]) ()
68 __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *))))
69 = { fini65530 };
70
71static void
72ctor65535 ()
73{
74 if (count != 65530)
75 abort ();
76 count = 65535;
77}
78void (*const ctors65535[]) ()
79 __attribute__ ((section (".ctors"), aligned (sizeof (void *))))
80 = { ctor65535 };
81static void
82dtor65535 ()
83{
84 if (count != 65535)
85 abort ();
86 count = 65530;
87}
88void (*const dtors65535[]) ()
89 __attribute__ ((section (".dtors"), aligned (sizeof (void *))))
90 = { dtor65535 };
91#endif
92
93int
94main ()
95{
96 printf ("OK\n");
97 return 0;
98}
This page took 0.041317 seconds and 4 git commands to generate.