]> gcc.gnu.org Git - gcc.git/blame - gcc/config/sol2.h
Added forgotten ChangeLog entry.
[gcc.git] / gcc / config / sol2.h
CommitLineData
8433a25e
RO
1/* Operating system specific defines to be used when targeting GCC for any
2 Solaris 2 system.
f1c26cad
RO
3 Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
8433a25e 5
814499a4 6This file is part of GCC.
8433a25e 7
814499a4 8GCC is free software; you can redistribute it and/or modify
8433a25e 9it under the terms of the GNU General Public License as published by
2f83c7d6 10the Free Software Foundation; either version 3, or (at your option)
8433a25e
RO
11any later version.
12
814499a4 13GCC is distributed in the hope that it will be useful,
8433a25e
RO
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
2f83c7d6
NC
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
8433a25e
RO
21
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
26
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"
30
31#undef WCHAR_TYPE_SIZE
32#define WCHAR_TYPE_SIZE BITS_PER_WORD
33
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"
38
39#undef WINT_TYPE_SIZE
40#define WINT_TYPE_SIZE BITS_PER_WORD
41
207bf79d
JM
42#define SIG_ATOMIC_TYPE "int"
43
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")
54
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")
63
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")
72
73#define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
74#define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
75
8433a25e
RO
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. */
79
80#undef CPP_SUBTARGET_SPEC
81#define CPP_SUBTARGET_SPEC "\
f5e2061b
EB
82%{pthreads|pthread:-D_REENTRANT -D_PTHREADS} \
83%{!pthreads:%{!pthread:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}}} \
8433a25e
RO
84%{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
85"
86
87/* Names to predefine in the preprocessor for this target machine. */
6508bdd5 88#define TARGET_SUB_OS_CPP_BUILTINS()
8433a25e
RO
89#define TARGET_OS_CPP_BUILTINS() \
90 do { \
91 builtin_define_std ("unix"); \
92 builtin_define_std ("sun"); \
93 builtin_define ("__svr4__"); \
94 builtin_define ("__SVR4"); \
8433a25e
RO
95 builtin_assert ("system=unix"); \
96 builtin_assert ("system=svr4"); \
6508bdd5 97 /* For C++ we need to add some additional macro \
8433a25e
RO
98 definitions required by the C++ standard \
99 library. */ \
04df6730 100 if (c_dialect_cxx ()) \
8433a25e
RO
101 { \
102 builtin_define ("_XOPEN_SOURCE=500"); \
103 builtin_define ("_LARGEFILE_SOURCE=1"); \
104 builtin_define ("_LARGEFILE64_SOURCE=1"); \
105 builtin_define ("__EXTENSIONS__"); \
106 } \
6508bdd5 107 TARGET_SUB_OS_CPP_BUILTINS(); \
8433a25e
RO
108 } while (0)
109
b689848f 110/* The system headers under Solaris 2 are C++-aware since 2.0. */
49fa0661
JM
111#define NO_IMPLICIT_EXTERN_C
112
8433a25e
RO
113/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
114 It's safe to pass -s always, even if -g is not used. */
115#undef ASM_SPEC
116#define ASM_SPEC "\
117%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
24a4dd31 118%{fpic|fpie|fPIC|fPIE:-K PIC} \
8433a25e
RO
119%(asm_cpu) \
120"
121
122/* We don't use the standard LIB_SPEC only because we don't yet support c++. */
123#undef LIB_SPEC
124#define LIB_SPEC \
125 "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
126 %{!shared:\
127 %{!symbolic:\
f5e2061b
EB
128 %{pthreads|pthread:-lpthread} \
129 %{!pthreads:%{!pthread:%{threads:-lthread}}} \
8433a25e
RO
130 %{p|pg:-ldl} -lc}}"
131
132#undef ENDFILE_SPEC
133#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
134
135/* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */
136#undef STARTFILE_SPEC
137#define STARTFILE_SPEC "%{!shared: \
138 %{!symbolic: \
139 %{p:mcrt1.o%s} \
140 %{!p: \
141 %{pg:gcrt1.o%s gmon.o%s} \
142 %{!pg:crt1.o%s}}}} \
143 crti.o%s %(startfile_arch) \
144 crtbegin.o%s"
145
146#undef STARTFILE_ARCH32_SPEC
147#define STARTFILE_ARCH32_SPEC "%{ansi:values-Xc.o%s} \
148 %{!ansi:values-Xa.o%s}"
149
150#undef STARTFILE_ARCH_SPEC
151#define STARTFILE_ARCH_SPEC STARTFILE_ARCH32_SPEC
152
61aaea23
MM
153#undef LINK_ARCH32_SPEC_BASE
154#define LINK_ARCH32_SPEC_BASE \
8433a25e
RO
155 "%{G:-G} \
156 %{YP,*} \
157 %{R*} \
158 %{compat-bsd: \
50617257
JM
159 %{!YP,*:%{p|pg:-Y P,%R/usr/ucblib:%R/usr/ccs/lib/libp:%R/usr/lib/libp:%R/usr/ccs/lib:%R/usr/lib} \
160 %{!p:%{!pg:-Y P,%R/usr/ucblib:%R/usr/ccs/lib:%R/usr/lib}}} \
161 -R %R/usr/ucblib} \
8433a25e 162 %{!compat-bsd: \
50617257
JM
163 %{!YP,*:%{p|pg:-Y P,%R/usr/ccs/lib/libp:%R/usr/lib/libp:%R/usr/ccs/lib:%R/usr/lib} \
164 %{!p:%{!pg:-Y P,%R/usr/ccs/lib:%R/usr/lib}}}}"
8433a25e 165
61aaea23
MM
166#undef LINK_ARCH32_SPEC
167#define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE
168
8433a25e
RO
169#undef LINK_ARCH_SPEC
170#define LINK_ARCH_SPEC LINK_ARCH32_SPEC
171
172/* This should be the same as in svr4.h, except with -R added. */
173#undef LINK_SPEC
174#define LINK_SPEC \
175 "%{h*} %{v:-V} \
3f94bdec 176 %{b} \
8433a25e
RO
177 %{static:-dn -Bstatic} \
178 %{shared:-G -dy %{!mimpure-text:-z text}} \
179 %{symbolic:-Bsymbolic -G -dy -z text} \
180 %(link_arch) \
181 %{Qy:} %{!Qn:-Qy}"
182
6e70657a
MM
183/* The Solaris linker doesn't understand constructor priorities. (The
184 GNU linker does support constructor priorities, so GNU ld
185 configuration files for Solaris override this setting.) */
186#undef SUPPORTS_INIT_PRIORITY
187#define SUPPORTS_INIT_PRIORITY 0
188
8433a25e
RO
189/* This defines which switch letters take arguments.
190 It is as in svr4.h but with -R added. */
191#undef SWITCH_TAKES_ARG
192#define SWITCH_TAKES_ARG(CHAR) \
193 (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
194 || (CHAR) == 'R' \
195 || (CHAR) == 'h' \
196 || (CHAR) == 'z')
197
198#define STDC_0_IN_SYSTEM_HEADERS 1
199\f
200/*
201 * Attempt to turn on access permissions for the stack.
202 *
8433a25e
RO
203 * _SC_STACK_PROT is only defined for post 2.6, but we want this code
204 * to run always. 2.6 can change the stack protection but has no way to
205 * query it.
206 *
207 */
208
ca11c37c 209/* sys/mman.h is not present on some non-Solaris configurations
e7a742ec 210 that use sol2.h, so ENABLE_EXECUTE_STACK must use a magic
ca11c37c 211 number instead of the appropriate PROT_* flags. */
8433a25e 212
e7a742ec 213#define ENABLE_EXECUTE_STACK \
8433a25e
RO
214 \
215/* #define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC) */ \
216 \
217static int need_enable_exec_stack; \
218 \
219static void check_enabling(void) __attribute__ ((constructor)); \
220static void check_enabling(void) \
221{ \
222 extern long sysconf(int); \
223 \
224 int prot = (int) sysconf(515 /* _SC_STACK_PROT */); \
225 if (prot != 7 /* STACK_PROT_RWX */) \
226 need_enable_exec_stack = 1; \
227} \
228 \
229extern void __enable_execute_stack (void *); \
230void \
d3157fb6 231__enable_execute_stack (void *addr) \
8433a25e 232{ \
84b8b0e0 233 extern int mprotect(void *, size_t, int); \
8433a25e
RO
234 if (!need_enable_exec_stack) \
235 return; \
236 else { \
237 long size = getpagesize (); \
238 long mask = ~(size-1); \
239 char *page = (char *) (((long) addr) & mask); \
240 char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
241 \
242 if (mprotect (page, end - page, 7 /* STACK_PROT_RWX */) < 0) \
243 perror ("mprotect of trampoline code"); \
244 } \
245}
a2bec818 246
07a43492 247/* Support Solaris-specific format checking for cmn_err. */
a2bec818
DJ
248#define TARGET_N_FORMAT_TYPES 1
249#define TARGET_FORMAT_TYPES solaris_format_types
07a43492
DJ
250
251/* #pragma init and #pragma fini are implemented on top of init and
252 fini attributes. */
253#define SOLARIS_ATTRIBUTE_TABLE \
254 { "init", 0, 0, true, false, false, NULL }, \
255 { "fini", 0, 0, true, false, false, NULL }
256
257/* This is how to declare the size of a function. For Solaris, we output
258 any .init or .fini entries here. */
259#undef ASM_DECLARE_FUNCTION_SIZE
260#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
261 do \
262 { \
263 if (!flag_inhibit_size_directive) \
264 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
265 solaris_output_init_fini (FILE, DECL); \
266 } \
267 while (0)
268
f1c26cad
RO
269/* Solaris 'as' has a bug: a .common directive in .tbss section
270 behaves as .tls_common rather than normal non-TLS .common. */
271#undef ASM_OUTPUT_ALIGNED_COMMON
272#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
273 do \
274 { \
275 if (TARGET_SUN_TLS \
276 && in_section \
277 && ((in_section->common.flags & (SECTION_TLS | SECTION_BSS)) \
278 == (SECTION_TLS | SECTION_BSS))) \
279 switch_to_section (bss_section); \
280 fprintf ((FILE), "%s", COMMON_ASM_OP); \
281 assemble_name ((FILE), (NAME)); \
282 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
283 (SIZE), (ALIGN) / BITS_PER_UNIT); \
284 } \
285 while (0)
286
07a43492
DJ
287extern GTY(()) tree solaris_pending_aligns;
288extern GTY(()) tree solaris_pending_inits;
289extern GTY(()) tree solaris_pending_finis;
b5b3e36a
DJ
290
291/* Allow macro expansion in #pragma pack. */
292#define HANDLE_PRAGMA_PACK_WITH_EXPANSION
This page took 1.746789 seconds and 5 git commands to generate.