Fix misapplied patch.
[binutils.git] / gold / testsuite / initpri2.c
blob525661f5859d6db6fd8727f6b6aa1799d0217a39
1 /* initpri2.c -- test mixing init_array and ctor priorities.
3 Copyright 2011 Free Software Foundation, Inc.
4 Copied from the gcc configury, where the test was contributed by
5 H.J. Lu <hongjiu.lu@intel.com>.
7 This file is part of gold.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
24 /* This tests that the linker correctly combines .ctor and .init_array
25 sections when both have priorities. */
27 #include <stdlib.h>
29 static int count;
31 static void
32 init1005 (void)
34 if (count != 0)
35 abort ();
36 count = 1005;
38 void (*const init_array1005[]) (void)
39 __attribute__ ((section (".init_array.01005"), aligned (sizeof (void *))))
40 = { init1005 };
41 static void
42 fini1005 (void)
44 if (count != 1005)
45 abort ();
47 void (*const fini_array1005[]) (void)
48 __attribute__ ((section (".fini_array.01005"), aligned (sizeof (void *))))
49 = { fini1005 };
51 static void
52 ctor1007 (void)
54 if (count != 1005)
55 abort ();
56 count = 1007;
58 void (*const ctors1007[]) (void)
59 __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *))))
60 = { ctor1007 };
61 static void
62 dtor1007 (void)
64 if (count != 1007)
65 abort ();
66 count = 1005;
68 void (*const dtors1007[]) (void)
69 __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *))))
70 = { dtor1007 };
72 static void
73 init65530 (void)
75 if (count != 1007)
76 abort ();
77 count = 65530;
79 void (*const init_array65530[]) (void)
80 __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *))))
81 = { init65530 };
82 static void
83 fini65530 (void)
85 if (count != 65530)
86 abort ();
87 count = 1007;
89 void (*const fini_array65530[]) (void)
90 __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *))))
91 = { fini65530 };
93 static void
94 ctor65535 (void)
96 if (count != 65530)
97 abort ();
98 count = 65535;
100 void (*const ctors65535[]) (void)
101 __attribute__ ((section (".ctors"), aligned (sizeof (void *))))
102 = { ctor65535 };
103 static void
104 dtor65535 (void)
106 if (count != 65535)
107 abort ();
108 count = 65530;
110 void (*const dtors65535[]) (void)
111 __attribute__ ((section (".dtors"), aligned (sizeof (void *))))
112 = { dtor65535 };
115 main (void)
117 return 0;