2008-01-25 Douglas Gregor <doug.gregor@gmail.com>
[official-gcc.git] / gcc / config / sol2.c
blobbf7da834129f01c62fa2f1ce6a74905edac61e95
1 /* General Solaris system support.
2 Copyright (C) 2004, 2005 , 2007 Free Software Foundation, Inc.
3 Contributed by CodeSourcery, LLC.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tree.h"
25 #include "tm.h"
26 #include "rtl.h"
27 #include "tm_p.h"
28 #include "toplev.h"
29 #include "ggc.h"
31 tree solaris_pending_aligns, solaris_pending_inits, solaris_pending_finis;
33 /* Attach any pending attributes for DECL to the list in *ATTRIBUTES.
34 Pending attributes come from #pragma or _Pragma, so this code is
35 only useful in the C family front ends, but it is included in
36 all languages to avoid changing the target machine initializer
37 depending on the language. */
39 void
40 solaris_insert_attributes (tree decl, tree *attributes)
42 tree *x, next;
44 if (solaris_pending_aligns != NULL && TREE_CODE (decl) == VAR_DECL)
45 for (x = &solaris_pending_aligns; *x; x = &TREE_CHAIN (*x))
47 tree name = TREE_PURPOSE (*x);
48 tree value = TREE_VALUE (*x);
49 if (DECL_NAME (decl) == name)
51 if (lookup_attribute ("aligned", DECL_ATTRIBUTES (decl))
52 || lookup_attribute ("aligned", *attributes))
53 warning (0, "ignoring %<#pragma align%> for explicitly "
54 "aligned %q+D", decl);
55 else
56 *attributes = tree_cons (get_identifier ("aligned"), value,
57 *attributes);
58 next = TREE_CHAIN (*x);
59 ggc_free (*x);
60 *x = next;
61 break;
65 if (solaris_pending_inits != NULL && TREE_CODE (decl) == FUNCTION_DECL)
66 for (x = &solaris_pending_inits; *x; x = &TREE_CHAIN (*x))
68 tree name = TREE_PURPOSE (*x);
69 if (DECL_NAME (decl) == name)
71 *attributes = tree_cons (get_identifier ("init"), NULL,
72 *attributes);
73 *attributes = tree_cons (get_identifier ("used"), NULL,
74 *attributes);
75 next = TREE_CHAIN (*x);
76 ggc_free (*x);
77 *x = next;
78 break;
82 if (solaris_pending_finis != NULL && TREE_CODE (decl) == FUNCTION_DECL)
83 for (x = &solaris_pending_finis; *x; x = &TREE_CHAIN (*x))
85 tree name = TREE_PURPOSE (*x);
86 if (DECL_NAME (decl) == name)
88 *attributes = tree_cons (get_identifier ("fini"), NULL,
89 *attributes);
90 *attributes = tree_cons (get_identifier ("used"), NULL,
91 *attributes);
92 next = TREE_CHAIN (*x);
93 ggc_free (*x);
94 *x = next;
95 break;
100 /* Output initializer or finalizer entries for DECL to FILE. */
102 void
103 solaris_output_init_fini (FILE *file, tree decl)
105 if (lookup_attribute ("init", DECL_ATTRIBUTES (decl)))
107 fprintf (file, "\t.pushsection\t\".init\"\n");
108 ASM_OUTPUT_CALL (file, decl);
109 fprintf (file, "\t.popsection\n");
112 if (lookup_attribute ("fini", DECL_ATTRIBUTES (decl)))
114 fprintf (file, "\t.pushsection\t\".fini\"\n");
115 ASM_OUTPUT_CALL (file, decl);
116 fprintf (file, "\t.popsection\n");