* symtab.cc (Symbol_table::add_from_object): If we don't use the
[deliverable/binutils-gdb.git] / gold / testsuite / initpri1.c
CommitLineData
2fd32231
ILT
1/* initpri1.c -- test constructor priorities.
2
3 Copyright 2007, 2008 Free Software Foundation, Inc.
4 Copied from the gcc testsuite, where the test was contributed by
5 Mark Mitchell <mark@codesourcery.com>.
6
7 This file is part of gold.
8
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.
13
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.
18
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.
23
24 This is a test of a common symbol in the main program and a
25 versioned symbol in a shared library. The common symbol in the
26 main program should override the shared library symbol. */
27
28#include <stdlib.h>
29
30int i;
31int j;
32
33void c1() __attribute__((constructor (500)));
34void c2() __attribute__((constructor (700)));
35void c3() __attribute__((constructor (600)));
36
37void c1() {
38 if (i++ != 0)
39 abort ();
40}
41
42void c2() {
43 if (i++ != 2)
44 abort ();
45}
46
47void c3() {
48 if (i++ != 1)
49 abort ();
50}
51
52void d1() __attribute__((destructor (500)));
53void d2() __attribute__((destructor (700)));
54void d3() __attribute__((destructor (600)));
55
56void d1() {
57 if (--i != 0)
58 abort ();
59}
60
61void d2() {
62 if (--i != 2)
63 abort ();
64}
65
66void d3() {
67 if (j != 2)
68 abort ();
69 if (--i != 1)
70 abort ();
71}
72
73void cd4() __attribute__((constructor (800), destructor (800)));
74
75void cd4() {
76 if (i != 3)
77 abort ();
78 ++j;
79}
80
81int main () {
82 if (i != 3)
83 return 1;
84 if (j != 1)
85 abort ();
86 return 0;
87}
This page took 0.025715 seconds and 4 git commands to generate.