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