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)
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/>. */
23 #include "coretypes.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. */
40 solaris_insert_attributes (tree decl
, tree
*attributes
)
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
);
56 *attributes
= tree_cons (get_identifier ("aligned"), value
,
58 next
= TREE_CHAIN (*x
);
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
,
74 DECL_PRESERVE_P (decl
) = 1;
75 next
= TREE_CHAIN (*x
);
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
,
91 DECL_PRESERVE_P (decl
) = 1;
92 next
= TREE_CHAIN (*x
);
100 /* Output initializer or finalizer entries for DECL to FILE. */
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");