1 /* General Solaris system support.
2 Copyright (C) 2004, 2005 , 2007, 2010 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"
29 #include "diagnostic-core.h"
33 tree solaris_pending_aligns
, solaris_pending_inits
, solaris_pending_finis
;
35 /* Attach any pending attributes for DECL to the list in *ATTRIBUTES.
36 Pending attributes come from #pragma or _Pragma, so this code is
37 only useful in the C family front ends, but it is included in
38 all languages to avoid changing the target machine initializer
39 depending on the language. */
42 solaris_insert_attributes (tree decl
, tree
*attributes
)
46 if (solaris_pending_aligns
!= NULL
&& TREE_CODE (decl
) == VAR_DECL
)
47 for (x
= &solaris_pending_aligns
; *x
; x
= &TREE_CHAIN (*x
))
49 tree name
= TREE_PURPOSE (*x
);
50 tree value
= TREE_VALUE (*x
);
51 if (DECL_NAME (decl
) == name
)
53 if (lookup_attribute ("aligned", DECL_ATTRIBUTES (decl
))
54 || lookup_attribute ("aligned", *attributes
))
55 warning (0, "ignoring %<#pragma align%> for explicitly "
56 "aligned %q+D", decl
);
58 *attributes
= tree_cons (get_identifier ("aligned"), value
,
60 next
= TREE_CHAIN (*x
);
67 if (solaris_pending_inits
!= NULL
&& TREE_CODE (decl
) == FUNCTION_DECL
)
68 for (x
= &solaris_pending_inits
; *x
; x
= &TREE_CHAIN (*x
))
70 tree name
= TREE_PURPOSE (*x
);
71 if (DECL_NAME (decl
) == name
)
73 *attributes
= tree_cons (get_identifier ("init"), NULL
,
76 DECL_PRESERVE_P (decl
) = 1;
77 next
= TREE_CHAIN (*x
);
84 if (solaris_pending_finis
!= NULL
&& TREE_CODE (decl
) == FUNCTION_DECL
)
85 for (x
= &solaris_pending_finis
; *x
; x
= &TREE_CHAIN (*x
))
87 tree name
= TREE_PURPOSE (*x
);
88 if (DECL_NAME (decl
) == name
)
90 *attributes
= tree_cons (get_identifier ("fini"), NULL
,
93 DECL_PRESERVE_P (decl
) = 1;
94 next
= TREE_CHAIN (*x
);
102 /* Output initializer or finalizer entries for DECL to FILE. */
105 solaris_output_init_fini (FILE *file
, tree decl
)
107 if (lookup_attribute ("init", DECL_ATTRIBUTES (decl
)))
109 fprintf (file
, PUSHSECTION_FORMAT
, ".init");
110 ASM_OUTPUT_CALL (file
, decl
);
111 fprintf (file
, "\t.popsection\n");
114 if (lookup_attribute ("fini", DECL_ATTRIBUTES (decl
)))
116 fprintf (file
, PUSHSECTION_FORMAT
, ".fini");
117 ASM_OUTPUT_CALL (file
, decl
);
118 fprintf (file
, "\t.popsection\n");
122 /* Emit an assembler directive to set symbol for DECL visibility to
123 the visibility type VIS, which must not be VISIBILITY_DEFAULT. */
126 solaris_assemble_visibility (tree decl ATTRIBUTE_UNUSED
,
127 int vis ATTRIBUTE_UNUSED
)
129 #ifdef HAVE_GAS_HIDDEN
130 /* Sun as uses .symbolic for STV_PROTECTED. STV_INTERNAL is marked as
131 `currently reserved', but the linker treats it like STV_HIDDEN. Sun
132 Studio 12.1 cc emits .hidden instead.
134 There are 3 Sun extensions GCC doesn't yet know about: STV_EXPORTED,
135 STV_SINGLETON, and STV_ELIMINATE.
137 See Linker and Libraries Guide, Ch. 2, Link-Editor, Defining
138 Additional Symbols with a mapfile,
139 http://docs.sun.com/app/docs/doc/819-0690/gdzmc?a=view
140 and Ch. 7, Object-File Format, Symbol Table Section,
141 http://docs.sun.com/app/docs/doc/819-0690/chapter6-79797?a=view */
143 static const char * const visibility_types
[] = {
144 NULL
, "symbolic", "hidden", "hidden"
147 const char *name
, *type
;
149 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
150 type
= visibility_types
[vis
];
152 fprintf (asm_out_file
, "\t.%s\t", type
);
153 assemble_name (asm_out_file
, name
);
154 fprintf (asm_out_file
, "\n");
156 warning (OPT_Wattributes
, "visibility attribute not supported "
157 "in this configuration; ignored");