Daily bump.
[official-gcc.git] / gcc / config / sol2.h
blob7e42ddb6a4be722dc7003869e25b41c4462df731
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.
6 This file is part of GCC.
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.
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.
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/>. */
22 /* We use stabs-in-elf for debugging, because that is what the native
23 toolchain uses. */
24 #undef PREFERRED_DEBUGGING_TYPE
25 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
27 /* Solaris 2 (at least as of 2.5.1) uses a 32-bit wchar_t. */
28 #undef WCHAR_TYPE
29 #define WCHAR_TYPE "long int"
31 #undef WCHAR_TYPE_SIZE
32 #define WCHAR_TYPE_SIZE BITS_PER_WORD
34 /* Solaris 2 uses a wint_t different from the default. This is required
35 by the SCD 2.4.1, p. 6-83, Figure 6-66. */
36 #undef WINT_TYPE
37 #define WINT_TYPE "long int"
39 #undef WINT_TYPE_SIZE
40 #define WINT_TYPE_SIZE BITS_PER_WORD
42 #define SIG_ATOMIC_TYPE "int"
44 /* ??? This definition of int8_t follows the system header but does
45 not conform to C99. Likewise int_fast8_t, int_least8_t. */
46 #define INT8_TYPE "char"
47 #define INT16_TYPE "short int"
48 #define INT32_TYPE "int"
49 #define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
50 #define UINT8_TYPE "unsigned char"
51 #define UINT16_TYPE "short unsigned int"
52 #define UINT32_TYPE "unsigned int"
53 #define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
55 #define INT_LEAST8_TYPE "char"
56 #define INT_LEAST16_TYPE "short int"
57 #define INT_LEAST32_TYPE "int"
58 #define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
59 #define UINT_LEAST8_TYPE "unsigned char"
60 #define UINT_LEAST16_TYPE "short unsigned int"
61 #define UINT_LEAST32_TYPE "unsigned int"
62 #define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
64 #define INT_FAST8_TYPE "char"
65 #define INT_FAST16_TYPE "int"
66 #define INT_FAST32_TYPE "int"
67 #define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
68 #define UINT_FAST8_TYPE "unsigned char"
69 #define UINT_FAST16_TYPE "unsigned int"
70 #define UINT_FAST32_TYPE "unsigned int"
71 #define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
73 #define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
74 #define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
76 /* ??? Note: in order for -compat-bsd to work fully,
77 we must somehow arrange to fixincludes /usr/ucbinclude
78 and put the result in $(libsubdir)/ucbinclude. */
80 #undef CPP_SUBTARGET_SPEC
81 #define CPP_SUBTARGET_SPEC "\
82 %{pthreads|pthread:-D_REENTRANT -D_PTHREADS} \
83 %{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
86 /* Names to predefine in the preprocessor for this target machine. */
87 #define TARGET_SUB_OS_CPP_BUILTINS()
88 #define TARGET_OS_CPP_BUILTINS() \
89 do { \
90 builtin_define_std ("unix"); \
91 builtin_define_std ("sun"); \
92 builtin_define ("__svr4__"); \
93 builtin_define ("__SVR4"); \
94 builtin_assert ("system=unix"); \
95 builtin_assert ("system=svr4"); \
96 /* For C++ we need to add some additional macro \
97 definitions required by the C++ standard \
98 library. */ \
99 if (c_dialect_cxx ()) \
101 builtin_define ("__STDC_VERSION__=199901L");\
102 builtin_define ("_XOPEN_SOURCE=600"); \
103 builtin_define ("_LARGEFILE_SOURCE=1"); \
104 builtin_define ("_LARGEFILE64_SOURCE=1"); \
105 builtin_define ("__EXTENSIONS__"); \
107 TARGET_SUB_OS_CPP_BUILTINS(); \
108 } while (0)
110 /* The system headers under Solaris 2 are C++-aware since 2.0. */
111 #define NO_IMPLICIT_EXTERN_C
113 /* It's safe to pass -s always, even if -g is not used. */
114 #undef ASM_SPEC
115 #define ASM_SPEC "\
116 %{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s \
117 %{fpic|fpie|fPIC|fPIE:-K PIC} \
118 %(asm_cpu) \
121 #ifndef CROSS_DIRECTORY_STRUCTURE
122 #undef MD_EXEC_PREFIX
123 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
125 #undef MD_STARTFILE_PREFIX
126 #define MD_STARTFILE_PREFIX "/usr/ccs/lib/"
127 #endif
129 /* We don't use the standard LIB_SPEC only because we don't yet support c++. */
130 #undef LIB_SPEC
131 #define LIB_SPEC \
132 "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
133 %{!symbolic:\
134 %{pthreads|pthread:" \
135 LIB_THREAD_LDFLAGS_SPEC " -lpthread " LIB_TLS_SPEC "} \
136 %{p|pg:-ldl} -lc}"
138 #undef ENDFILE_SPEC
139 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
141 /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */
142 #undef STARTFILE_SPEC
143 #define STARTFILE_SPEC "%{!shared: \
144 %{!symbolic: \
145 %{p:mcrt1.o%s} \
146 %{!p: \
147 %{pg:gcrt1.o%s gmon.o%s} \
148 %{!pg:crt1.o%s}}}} \
149 crti.o%s %(startfile_arch) \
150 crtbegin.o%s"
152 #undef STARTFILE_ARCH32_SPEC
153 #define STARTFILE_ARCH32_SPEC "%{ansi:values-Xc.o%s} \
154 %{!ansi:values-Xa.o%s}"
156 #undef STARTFILE_ARCH_SPEC
157 #define STARTFILE_ARCH_SPEC STARTFILE_ARCH32_SPEC
159 #undef LINK_ARCH32_SPEC_BASE
160 #define LINK_ARCH32_SPEC_BASE \
161 "%{G:-G} \
162 %{YP,*} \
163 %{R*} \
164 %{compat-bsd: \
165 %{!YP,*:%{p|pg:-Y P,%R/usr/ucblib:%R/usr/ccs/lib/libp:%R/usr/lib/libp:%R/usr/ccs/lib:%R/usr/lib} \
166 %{!p:%{!pg:-Y P,%R/usr/ucblib:%R/usr/ccs/lib:%R/usr/lib}}} \
167 -R %R/usr/ucblib} \
168 %{!compat-bsd: \
169 %{!YP,*:%{p|pg:-Y P,%R/usr/ccs/lib/libp:%R/usr/lib/libp:%R/usr/ccs/lib:%R/usr/lib} \
170 %{!p:%{!pg:-Y P,%R/usr/ccs/lib:%R/usr/lib}}}}"
172 #undef LINK_ARCH32_SPEC
173 #define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE
175 #undef LINK_ARCH_SPEC
176 #define LINK_ARCH_SPEC LINK_ARCH32_SPEC
178 #undef LINK_SPEC
179 #define LINK_SPEC \
180 "%{h*} %{v:-V} \
181 %{!shared:%{!static:%{rdynamic: " RDYNAMIC_SPEC "}}} \
182 %{static:-dn -Bstatic} \
183 %{shared:-G -dy %{!mimpure-text:-z text}} \
184 %{symbolic:-Bsymbolic -G -dy -z text} \
185 %(link_arch) \
186 %{Qy:} %{!Qn:-Qy}"
188 /* With Sun ld, -rdynamic is a no-op. */
189 #define RDYNAMIC_SPEC ""
191 /* The Solaris linker doesn't understand constructor priorities. (The
192 GNU linker does support constructor priorities, so GNU ld
193 configuration files for Solaris override this setting.) */
194 #undef SUPPORTS_INIT_PRIORITY
195 #define SUPPORTS_INIT_PRIORITY 0
197 /* collect2.c can only parse GNU nm -n output. Solaris nm needs -png to
198 produce the same format. */
199 #define NM_FLAGS "-png"
201 #define STDC_0_IN_SYSTEM_HEADERS 1
204 * Attempt to turn on access permissions for the stack.
206 * _SC_STACK_PROT is only defined for post 2.6, but we want this code
207 * to run always. 2.6 can change the stack protection but has no way to
208 * query it.
212 /* sys/mman.h is not present on some non-Solaris configurations
213 that use sol2.h, so ENABLE_EXECUTE_STACK must use a magic
214 number instead of the appropriate PROT_* flags. */
216 #define ENABLE_EXECUTE_STACK \
218 /* #define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC) */ \
220 static int need_enable_exec_stack; \
222 static void check_enabling(void) __attribute__ ((constructor)); \
223 static void check_enabling(void) \
225 extern long sysconf(int); \
227 int prot = (int) sysconf(515 /* _SC_STACK_PROT */); \
228 if (prot != 7 /* STACK_PROT_RWX */) \
229 need_enable_exec_stack = 1; \
232 extern void __enable_execute_stack (void *); \
233 void \
234 __enable_execute_stack (void *addr) \
236 extern int mprotect(void *, size_t, int); \
237 if (!need_enable_exec_stack) \
238 return; \
239 else { \
240 long size = getpagesize (); \
241 long mask = ~(size-1); \
242 char *page = (char *) (((long) addr) & mask); \
243 char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
245 if (mprotect (page, end - page, 7 /* STACK_PROT_RWX */) < 0) \
246 perror ("mprotect of trampoline code"); \
250 /* Support Solaris-specific format checking for cmn_err. */
251 #define TARGET_N_FORMAT_TYPES 1
252 #define TARGET_FORMAT_TYPES solaris_format_types
254 /* #pragma init and #pragma fini are implemented on top of init and
255 fini attributes. */
256 #define SOLARIS_ATTRIBUTE_TABLE \
257 { "init", 0, 0, true, false, false, NULL, false }, \
258 { "fini", 0, 0, true, false, false, NULL, false }
260 /* Solaris/x86 as and gas support the common ELF .section/.pushsection
261 syntax. */
262 #define PUSHSECTION_FORMAT "\t.pushsection\t%s\n"
264 /* This is how to declare the size of a function. For Solaris, we output
265 any .init or .fini entries here. */
266 #undef ASM_DECLARE_FUNCTION_SIZE
267 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
268 do \
270 if (!flag_inhibit_size_directive) \
271 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
272 solaris_output_init_fini (FILE, DECL); \
274 while (0)
276 /* Solaris 'as' has a bug: a .common directive in .tbss or .tdata section
277 behaves as .tls_common rather than normal non-TLS .common. */
278 #undef ASM_OUTPUT_ALIGNED_COMMON
279 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
280 do \
282 if (TARGET_SUN_TLS \
283 && in_section \
284 && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS)) \
285 switch_to_section (bss_section); \
286 fprintf ((FILE), "%s", COMMON_ASM_OP); \
287 assemble_name ((FILE), (NAME)); \
288 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
289 (SIZE), (ALIGN) / BITS_PER_UNIT); \
291 while (0)
293 #ifndef USE_GAS
294 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
295 #define TARGET_ASM_ASSEMBLE_VISIBILITY solaris_assemble_visibility
297 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
299 #endif
301 extern GTY(()) tree solaris_pending_aligns;
302 extern GTY(()) tree solaris_pending_inits;
303 extern GTY(()) tree solaris_pending_finis;
305 /* Allow macro expansion in #pragma pack. */
306 #define HANDLE_PRAGMA_PACK_WITH_EXPANSION
308 #define TARGET_POSIX_IO