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