1 /* General Solaris system support.
2 Copyright (C) 2004, 2005 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 2, or (at your option)
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 COPYING. If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
24 #include "coretypes.h"
32 tree solaris_pending_aligns
, solaris_pending_inits
, solaris_pending_finis
;
34 /* Attach any pending attributes for DECL to the list in *ATTRIBUTES.
35 Pending attributes come from #pragma or _Pragma, so this code is
36 only useful in the C family front ends, but it is included in
37 all languages to avoid changing the target machine initializer
38 depending on the language. */
41 solaris_insert_attributes (tree decl
, tree
*attributes
)
45 if (solaris_pending_aligns
!= NULL
&& TREE_CODE (decl
) == VAR_DECL
)
46 for (x
= &solaris_pending_aligns
; *x
; x
= &TREE_CHAIN (*x
))
48 tree name
= TREE_PURPOSE (*x
);
49 tree value
= TREE_VALUE (*x
);
50 if (DECL_NAME (decl
) == name
)
52 if (lookup_attribute ("aligned", DECL_ATTRIBUTES (decl
))
53 || lookup_attribute ("aligned", *attributes
))
54 warning (0, "ignoring %<#pragma align%> for explicitly "
55 "aligned %q+D", decl
);
57 *attributes
= tree_cons (get_identifier ("aligned"), value
,
59 next
= TREE_CHAIN (*x
);
66 if (solaris_pending_inits
!= NULL
&& TREE_CODE (decl
) == FUNCTION_DECL
)
67 for (x
= &solaris_pending_inits
; *x
; x
= &TREE_CHAIN (*x
))
69 tree name
= TREE_PURPOSE (*x
);
70 if (DECL_NAME (decl
) == name
)
72 *attributes
= tree_cons (get_identifier ("init"), NULL
,
74 *attributes
= tree_cons (get_identifier ("used"), NULL
,
76 next
= TREE_CHAIN (*x
);
83 if (solaris_pending_finis
!= NULL
&& TREE_CODE (decl
) == FUNCTION_DECL
)
84 for (x
= &solaris_pending_finis
; *x
; x
= &TREE_CHAIN (*x
))
86 tree name
= TREE_PURPOSE (*x
);
87 if (DECL_NAME (decl
) == name
)
89 *attributes
= tree_cons (get_identifier ("fini"), NULL
,
91 *attributes
= tree_cons (get_identifier ("used"), NULL
,
93 next
= TREE_CHAIN (*x
);
101 /* Output initializer or finalizer entries for DECL to FILE. */
104 solaris_output_init_fini (FILE *file
, tree decl
)
106 if (lookup_attribute ("init", DECL_ATTRIBUTES (decl
)))
108 fprintf (file
, "\t.pushsection\t\".init\"\n");
109 ASM_OUTPUT_CALL (file
, decl
);
110 fprintf (file
, "\t.popsection\n");
113 if (lookup_attribute ("fini", DECL_ATTRIBUTES (decl
)))
115 fprintf (file
, "\t.pushsection\t\".fini\"\n");
116 ASM_OUTPUT_CALL (file
, decl
);
117 fprintf (file
, "\t.popsection\n");