]> gcc.gnu.org Git - gcc.git/blob - gcc/config/sol2.h
re PR gcov-profile/48845 (All g++.dg/tree-prof and gcc.dg/{matrix, tree-prof} executi...
[gcc.git] / gcc / config / sol2.h
1 /* Operating system specific defines to be used when targeting GCC for any
2 Solaris 2 system.
3 Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 /* We are compiling for Solaris 2 now. */
23 #define TARGET_SOLARIS 1
24
25 /* We use stabs-in-elf for debugging, because that is what the native
26 toolchain uses. */
27 #undef PREFERRED_DEBUGGING_TYPE
28 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
29
30 /* Solaris 2 (at least as of 2.5.1) uses a 32-bit wchar_t. */
31 #undef WCHAR_TYPE
32 #define WCHAR_TYPE "long int"
33
34 #undef WCHAR_TYPE_SIZE
35 #define WCHAR_TYPE_SIZE BITS_PER_WORD
36
37 /* Solaris 2 uses a wint_t different from the default. This is required
38 by the SCD 2.4.1, p. 6-83, Figure 6-66. */
39 #undef WINT_TYPE
40 #define WINT_TYPE "long int"
41
42 #undef WINT_TYPE_SIZE
43 #define WINT_TYPE_SIZE BITS_PER_WORD
44
45 #define SIG_ATOMIC_TYPE "int"
46
47 /* ??? This definition of int8_t follows the system header but does
48 not conform to C99. Likewise int_fast8_t, int_least8_t. */
49 #define INT8_TYPE "char"
50 #define INT16_TYPE "short int"
51 #define INT32_TYPE "int"
52 #define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
53 #define UINT8_TYPE "unsigned char"
54 #define UINT16_TYPE "short unsigned int"
55 #define UINT32_TYPE "unsigned int"
56 #define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
57
58 #define INT_LEAST8_TYPE "char"
59 #define INT_LEAST16_TYPE "short int"
60 #define INT_LEAST32_TYPE "int"
61 #define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
62 #define UINT_LEAST8_TYPE "unsigned char"
63 #define UINT_LEAST16_TYPE "short unsigned int"
64 #define UINT_LEAST32_TYPE "unsigned int"
65 #define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
66
67 #define INT_FAST8_TYPE "char"
68 #define INT_FAST16_TYPE "int"
69 #define INT_FAST32_TYPE "int"
70 #define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
71 #define UINT_FAST8_TYPE "unsigned char"
72 #define UINT_FAST16_TYPE "unsigned int"
73 #define UINT_FAST32_TYPE "unsigned int"
74 #define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
75
76 #define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
77 #define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
78
79 /* ??? Note: in order for -compat-bsd to work fully,
80 we must somehow arrange to fixincludes /usr/ucbinclude
81 and put the result in $(libsubdir)/ucbinclude. */
82
83 #undef CPP_SUBTARGET_SPEC
84 #define CPP_SUBTARGET_SPEC "\
85 %{pthreads|pthread:-D_REENTRANT -D_PTHREADS} \
86 %{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
87 "
88
89 /* Names to predefine in the preprocessor for this target machine. */
90 #define TARGET_SUB_OS_CPP_BUILTINS()
91 #define TARGET_OS_CPP_BUILTINS() \
92 do { \
93 builtin_define_std ("unix"); \
94 builtin_define_std ("sun"); \
95 builtin_define ("__svr4__"); \
96 builtin_define ("__SVR4"); \
97 builtin_assert ("system=unix"); \
98 builtin_assert ("system=svr4"); \
99 /* For C++ we need to add some additional macro \
100 definitions required by the C++ standard \
101 library. */ \
102 if (c_dialect_cxx ()) \
103 { \
104 builtin_define ("__STDC_VERSION__=199901L");\
105 builtin_define ("_XOPEN_SOURCE=600"); \
106 builtin_define ("_LARGEFILE_SOURCE=1"); \
107 builtin_define ("_LARGEFILE64_SOURCE=1"); \
108 builtin_define ("__EXTENSIONS__"); \
109 } \
110 TARGET_SUB_OS_CPP_BUILTINS(); \
111 } while (0)
112
113 /* The system headers under Solaris 2 are C++-aware since 2.0. */
114 #define NO_IMPLICIT_EXTERN_C
115
116 /* It's safe to pass -s always, even if -g is not used. */
117 #undef ASM_SPEC
118 #define ASM_SPEC "\
119 %{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s \
120 %{fpic|fpie|fPIC|fPIE:-K PIC} \
121 %(asm_cpu) \
122 "
123
124 #ifndef CROSS_DIRECTORY_STRUCTURE
125 #undef MD_EXEC_PREFIX
126 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
127
128 #undef MD_STARTFILE_PREFIX
129 #define MD_STARTFILE_PREFIX "/usr/ccs/lib/"
130 #endif
131
132 /* We don't use the standard LIB_SPEC only because we don't yet support c++. */
133 #undef LIB_SPEC
134 #define LIB_SPEC \
135 "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
136 %{!symbolic:\
137 %{pthreads|pthread:" \
138 LIB_THREAD_LDFLAGS_SPEC " -lpthread " LIB_TLS_SPEC "} \
139 %{fprofile-generate*:" \
140 LIB_THREAD_LDFLAGS_SPEC " " LIB_TLS_SPEC "} \
141 %{p|pg:-ldl} -lc}"
142
143 #undef ENDFILE_SPEC
144 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
145
146 /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */
147 #undef STARTFILE_SPEC
148 #define STARTFILE_SPEC "%{!shared: \
149 %{!symbolic: \
150 %{p:mcrt1.o%s} \
151 %{!p: \
152 %{pg:gcrt1.o%s gmon.o%s} \
153 %{!pg:crt1.o%s}}}} \
154 crti.o%s %(startfile_arch) \
155 crtbegin.o%s"
156
157 #undef STARTFILE_ARCH32_SPEC
158 #define STARTFILE_ARCH32_SPEC "%{ansi:values-Xc.o%s} \
159 %{!ansi:values-Xa.o%s}"
160
161 #undef STARTFILE_ARCH_SPEC
162 #define STARTFILE_ARCH_SPEC STARTFILE_ARCH32_SPEC
163
164 #undef LINK_ARCH32_SPEC_BASE
165 #define LINK_ARCH32_SPEC_BASE \
166 "%{G:-G} \
167 %{YP,*} \
168 %{R*} \
169 %{compat-bsd: \
170 %{!YP,*:%{p|pg:-Y P,%R/usr/ucblib:%R/usr/ccs/lib/libp:%R/usr/lib/libp:%R/usr/ccs/lib:%R/usr/lib} \
171 %{!p:%{!pg:-Y P,%R/usr/ucblib:%R/usr/ccs/lib:%R/usr/lib}}} \
172 -R %R/usr/ucblib} \
173 %{!compat-bsd: \
174 %{!YP,*:%{p|pg:-Y P,%R/usr/ccs/lib/libp:%R/usr/lib/libp:%R/usr/ccs/lib:%R/usr/lib} \
175 %{!p:%{!pg:-Y P,%R/usr/ccs/lib:%R/usr/lib}}}}"
176
177 #undef LINK_ARCH32_SPEC
178 #define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE
179
180 #undef LINK_ARCH_SPEC
181 #define LINK_ARCH_SPEC LINK_ARCH32_SPEC
182
183 #undef LINK_SPEC
184 #define LINK_SPEC \
185 "%{h*} %{v:-V} \
186 %{!shared:%{!static:%{rdynamic: " RDYNAMIC_SPEC "}}} \
187 %{static:-dn -Bstatic} \
188 %{shared:-G -dy %{!mimpure-text:-z text}} \
189 %{symbolic:-Bsymbolic -G -dy -z text} \
190 %(link_arch) \
191 %{Qy:} %{!Qn:-Qy}"
192
193 /* With Sun ld, -rdynamic is a no-op. */
194 #define RDYNAMIC_SPEC ""
195
196 /* The Solaris linker doesn't understand constructor priorities. (The
197 GNU linker does support constructor priorities, so GNU ld
198 configuration files for Solaris override this setting.) */
199 #undef SUPPORTS_INIT_PRIORITY
200 #define SUPPORTS_INIT_PRIORITY 0
201
202 /* collect2.c can only parse GNU nm -n output. Solaris nm needs -png to
203 produce the same format. */
204 #define NM_FLAGS "-png"
205
206 #define STDC_0_IN_SYSTEM_HEADERS 1
207 \f
208 /*
209 * Attempt to turn on access permissions for the stack.
210 *
211 * _SC_STACK_PROT is only defined for post 2.6, but we want this code
212 * to run always. 2.6 can change the stack protection but has no way to
213 * query it.
214 *
215 */
216
217 /* sys/mman.h is not present on some non-Solaris configurations
218 that use sol2.h, so ENABLE_EXECUTE_STACK must use a magic
219 number instead of the appropriate PROT_* flags. */
220
221 #define ENABLE_EXECUTE_STACK \
222 \
223 /* #define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC) */ \
224 \
225 static int need_enable_exec_stack; \
226 \
227 static void check_enabling(void) __attribute__ ((constructor)); \
228 static void check_enabling(void) \
229 { \
230 extern long sysconf(int); \
231 \
232 int prot = (int) sysconf(515 /* _SC_STACK_PROT */); \
233 if (prot != 7 /* STACK_PROT_RWX */) \
234 need_enable_exec_stack = 1; \
235 } \
236 \
237 extern void __enable_execute_stack (void *); \
238 void \
239 __enable_execute_stack (void *addr) \
240 { \
241 extern int mprotect(void *, size_t, int); \
242 if (!need_enable_exec_stack) \
243 return; \
244 else { \
245 long size = getpagesize (); \
246 long mask = ~(size-1); \
247 char *page = (char *) (((long) addr) & mask); \
248 char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
249 \
250 if (mprotect (page, end - page, 7 /* STACK_PROT_RWX */) < 0) \
251 perror ("mprotect of trampoline code"); \
252 } \
253 }
254
255 /* Support Solaris-specific format checking for cmn_err. */
256 #define TARGET_N_FORMAT_TYPES 1
257 #define TARGET_FORMAT_TYPES solaris_format_types
258
259 /* #pragma init and #pragma fini are implemented on top of init and
260 fini attributes. */
261 #define SOLARIS_ATTRIBUTE_TABLE \
262 { "init", 0, 0, true, false, false, NULL, false }, \
263 { "fini", 0, 0, true, false, false, NULL, false }
264
265 /* Solaris/x86 as and gas support unquoted section names. */
266 #define SECTION_NAME_FORMAT "%s"
267
268 /* This is how to declare the size of a function. For Solaris, we output
269 any .init or .fini entries here. */
270 #undef ASM_DECLARE_FUNCTION_SIZE
271 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
272 do \
273 { \
274 if (!flag_inhibit_size_directive) \
275 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
276 solaris_output_init_fini (FILE, DECL); \
277 } \
278 while (0)
279
280 /* Solaris 'as' has a bug: a .common directive in .tbss or .tdata section
281 behaves as .tls_common rather than normal non-TLS .common. */
282 #undef ASM_OUTPUT_ALIGNED_COMMON
283 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
284 do \
285 { \
286 if (TARGET_SUN_TLS \
287 && in_section \
288 && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS)) \
289 switch_to_section (bss_section); \
290 fprintf ((FILE), "%s", COMMON_ASM_OP); \
291 assemble_name ((FILE), (NAME)); \
292 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
293 (SIZE), (ALIGN) / BITS_PER_UNIT); \
294 } \
295 while (0)
296
297 #ifndef USE_GAS
298 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
299 #define TARGET_ASM_ASSEMBLE_VISIBILITY solaris_assemble_visibility
300
301 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
302
303 #endif
304
305 extern GTY(()) tree solaris_pending_aligns;
306 extern GTY(()) tree solaris_pending_inits;
307 extern GTY(()) tree solaris_pending_finis;
308
309 /* Allow macro expansion in #pragma pack. */
310 #define HANDLE_PRAGMA_PACK_WITH_EXPANSION
311
312 #define TARGET_POSIX_IO
This page took 0.051778 seconds and 5 git commands to generate.