79c54b58f00b5d3f36a31df85dbb853bd76ae79e
1 /* Operating system specific defines to be used when targeting GCC for any
3 Copyright 2002, 2003 Free Software Foundation, Inc.
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 2, 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 COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* We use stabs-in-elf for debugging, because that is what the native
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. */
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. */
37 #define WINT_TYPE "long int"
40 #define WINT_TYPE_SIZE BITS_PER_WORD
42 #define HANDLE_PRAGMA_REDEFINE_EXTNAME 1
44 /* ??? Note: in order for -compat-bsd to work fully,
45 we must somehow arrange to fixincludes /usr/ucbinclude
46 and put the result in $(libsubdir)/ucbinclude. */
48 #undef CPP_SUBTARGET_SPEC
49 #define CPP_SUBTARGET_SPEC "\
50 %{pthreads:-D_REENTRANT -D_PTHREADS} \
51 %{!pthreads:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}} \
52 %{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
55 /* Names to predefine in the preprocessor for this target machine. */
56 #define TARGET_SUB_OS_CPP_BUILTINS()
57 #define TARGET_OS_CPP_BUILTINS() \
59 builtin_define_std ("unix"); \
60 builtin_define_std ("sun"); \
61 builtin_define ("__svr4__"); \
62 builtin_define ("__SVR4"); \
63 builtin_define ("__PRAGMA_REDEFINE_EXTNAME"); \
64 builtin_assert ("system=unix"); \
65 builtin_assert ("system=svr4"); \
66 /* For C++ we need to add some additional macro \
67 definitions required by the C++ standard \
69 if (c_dialect_cxx ()) \
71 builtin_define ("_XOPEN_SOURCE=500"); \
72 builtin_define ("_LARGEFILE_SOURCE=1"); \
73 builtin_define ("_LARGEFILE64_SOURCE=1"); \
74 builtin_define ("__EXTENSIONS__"); \
76 TARGET_SUB_OS_CPP_BUILTINS(); \
79 /* The system headers under Solaris (at least 2.5.1 and up) are C++-aware. */
80 #define NO_IMPLICIT_EXTERN_C
82 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
83 It's safe to pass -s always, even if -g is not used. */
86 %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
87 %{fpic|fpie|fPIC|fPIE:-K PIC} \
91 /* We don't use the standard LIB_SPEC only because we don't yet support c++. */
94 "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
97 %{pthreads:-lpthread} \
98 %{!pthreads:%{threads:-lthread}} \
102 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
104 /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */
105 #undef STARTFILE_SPEC
106 #define STARTFILE_SPEC "%{!shared: \
110 %{pg:gcrt1.o%s gmon.o%s} \
112 crti.o%s %(startfile_arch) \
115 #undef STARTFILE_ARCH32_SPEC
116 #define STARTFILE_ARCH32_SPEC "%{ansi:values-Xc.o%s} \
117 %{!ansi:values-Xa.o%s}"
119 #undef STARTFILE_ARCH_SPEC
120 #define STARTFILE_ARCH_SPEC STARTFILE_ARCH32_SPEC
122 #undef LINK_ARCH32_SPEC
123 #define LINK_ARCH32_SPEC \
128 %{!YP,*:%{p|pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
129 %{!p:%{!pg:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
132 %{!YP,*:%{p|pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
133 %{!p:%{!pg:-Y P,/usr/ccs/lib:/usr/lib}}}}"
135 #undef LINK_ARCH_SPEC
136 #define LINK_ARCH_SPEC LINK_ARCH32_SPEC
138 /* This should be the same as in svr4.h, except with -R added. */
143 %{static:-dn -Bstatic} \
144 %{shared:-G -dy %{!mimpure-text:-z text}} \
145 %{symbolic:-Bsymbolic -G -dy -z text} \
149 /* This defines which switch letters take arguments.
150 It is as in svr4.h but with -R added. */
151 #undef SWITCH_TAKES_ARG
152 #define SWITCH_TAKES_ARG(CHAR) \
153 (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
158 #define STDC_0_IN_SYSTEM_HEADERS 1
161 * Attempt to turn on access permissions for the stack.
163 * This code must be defined when compiling gcc but not when compiling
164 * libgcc2.a, unless we're generating code for 64-bit SPARC
166 * _SC_STACK_PROT is only defined for post 2.6, but we want this code
167 * to run always. 2.6 can change the stack protection but has no way to
172 /* sys/mman.h is not present on some non-Solaris configurations
173 that use sol2.h, so TRANSFER_FROM_TRAMPOLINE must use a magic
174 number instead of the appropriate PROT_* flags. */
176 #define TRANSFER_FROM_TRAMPOLINE \
178 /* #define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC) */ \
180 static int need_enable_exec_stack; \
182 static void check_enabling(void) __attribute__ ((constructor)); \
183 static void check_enabling(void) \
185 extern long sysconf(int); \
187 int prot = (int) sysconf(515 /* _SC_STACK_PROT */); \
188 if (prot != 7 /* STACK_PROT_RWX */) \
189 need_enable_exec_stack = 1; \
192 extern void __enable_execute_stack (void *); \
194 __enable_execute_stack (addr) \
197 if (!need_enable_exec_stack) \
200 long size = getpagesize (); \
201 long mask = ~(size-1); \
202 char *page = (char *) (((long) addr) & mask); \
203 char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
205 if (mprotect (page, end - page, 7 /* STACK_PROT_RWX */) < 0) \
206 perror ("mprotect of trampoline code"); \