* elf32-spu.c (build_stub): Fix malloc under-allocation.
[binutils.git] / ld / testsuite / ld-elf / init-mixed.c
blob770a4b50e8f832be0edda97a0b8bcea9b387153b
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 ctor1007a ()
32 if (count != 1005)
33 abort ();
34 count = 1006;
36 static void
37 ctor1007b ()
39 if (count != 1006)
40 abort ();
41 count = 1007;
43 void (*const ctors1007[]) ()
44 __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *))))
45 = { ctor1007b, ctor1007a };
46 static void
47 dtor1007a ()
49 if (count != 1006)
50 abort ();
51 count = 1005;
53 static void
54 dtor1007b ()
56 if (count != 1007)
57 abort ();
58 count = 1006;
60 void (*const dtors1007[]) ()
61 __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *))))
62 = { dtor1007b, dtor1007a };
64 static void
65 init65530 ()
67 if (count != 1007)
68 abort ();
69 count = 65530;
71 void (*const init_array65530[]) ()
72 __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *))))
73 = { init65530 };
74 static void
75 fini65530 ()
77 if (count != 65530)
78 abort ();
79 count = 1007;
81 void (*const fini_array65530[]) ()
82 __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *))))
83 = { fini65530 };
85 static void
86 ctor65535a ()
88 if (count != 65530)
89 abort ();
90 count = 65535;
92 static void
93 ctor65535b ()
95 if (count != 65535)
96 abort ();
97 count = 65536;
99 void (*const ctors65535[]) ()
100 __attribute__ ((section (".ctors"), aligned (sizeof (void *))))
101 = { ctor65535b, ctor65535a };
102 static void
103 dtor65535b ()
105 if (count != 65536)
106 abort ();
107 count = 65535;
109 static void
110 dtor65535a ()
112 if (count != 65535)
113 abort ();
114 count = 65530;
116 void (*const dtors65535[]) ()
117 __attribute__ ((section (".dtors"), aligned (sizeof (void *))))
118 = { dtor65535b, dtor65535a };
119 #endif
122 main ()
124 printf ("OK\n");
125 return 0;