]>
Commit | Line | Data |
---|---|---|
8433a25e RO |
1 | /* Operating system specific defines to be used when targeting GCC for any |
2 | Solaris 2 system. | |
07a43492 | 3 | Copyright 2002, 2003, 2004 Free Software Foundation, Inc. |
8433a25e | 4 | |
814499a4 | 5 | This file is part of GCC. |
8433a25e | 6 | |
814499a4 | 7 | GCC is free software; you can redistribute it and/or modify |
8433a25e RO |
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) | |
10 | any later version. | |
11 | ||
814499a4 | 12 | GCC is distributed in the hope that it will be useful, |
8433a25e RO |
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
814499a4 | 18 | along with GCC; see the file COPYING. If not, write to |
39d14dda KC |
19 | the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. */ | |
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 | ||
84b8b0e0 | 42 | #define TARGET_HANDLE_PRAGMA_REDEFINE_EXTNAME 1 |
8433a25e RO |
43 | |
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. */ | |
47 | ||
48 | #undef CPP_SUBTARGET_SPEC | |
49 | #define CPP_SUBTARGET_SPEC "\ | |
f5e2061b EB |
50 | %{pthreads|pthread:-D_REENTRANT -D_PTHREADS} \ |
51 | %{!pthreads:%{!pthread:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}}} \ | |
8433a25e RO |
52 | %{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \ |
53 | " | |
54 | ||
55 | /* Names to predefine in the preprocessor for this target machine. */ | |
6508bdd5 | 56 | #define TARGET_SUB_OS_CPP_BUILTINS() |
8433a25e RO |
57 | #define TARGET_OS_CPP_BUILTINS() \ |
58 | do { \ | |
59 | builtin_define_std ("unix"); \ | |
60 | builtin_define_std ("sun"); \ | |
61 | builtin_define ("__svr4__"); \ | |
62 | builtin_define ("__SVR4"); \ | |
8433a25e RO |
63 | builtin_assert ("system=unix"); \ |
64 | builtin_assert ("system=svr4"); \ | |
6508bdd5 | 65 | /* For C++ we need to add some additional macro \ |
8433a25e RO |
66 | definitions required by the C++ standard \ |
67 | library. */ \ | |
04df6730 | 68 | if (c_dialect_cxx ()) \ |
8433a25e RO |
69 | { \ |
70 | builtin_define ("_XOPEN_SOURCE=500"); \ | |
71 | builtin_define ("_LARGEFILE_SOURCE=1"); \ | |
72 | builtin_define ("_LARGEFILE64_SOURCE=1"); \ | |
73 | builtin_define ("__EXTENSIONS__"); \ | |
74 | } \ | |
6508bdd5 | 75 | TARGET_SUB_OS_CPP_BUILTINS(); \ |
8433a25e RO |
76 | } while (0) |
77 | ||
b689848f | 78 | /* The system headers under Solaris 2 are C++-aware since 2.0. */ |
49fa0661 JM |
79 | #define NO_IMPLICIT_EXTERN_C |
80 | ||
8433a25e RO |
81 | /* The sun bundled assembler doesn't accept -Yd, (and neither does gas). |
82 | It's safe to pass -s always, even if -g is not used. */ | |
83 | #undef ASM_SPEC | |
84 | #define ASM_SPEC "\ | |
85 | %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \ | |
24a4dd31 | 86 | %{fpic|fpie|fPIC|fPIE:-K PIC} \ |
8433a25e RO |
87 | %(asm_cpu) \ |
88 | " | |
89 | ||
90 | /* We don't use the standard LIB_SPEC only because we don't yet support c++. */ | |
91 | #undef LIB_SPEC | |
92 | #define LIB_SPEC \ | |
93 | "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \ | |
94 | %{!shared:\ | |
95 | %{!symbolic:\ | |
f5e2061b EB |
96 | %{pthreads|pthread:-lpthread} \ |
97 | %{!pthreads:%{!pthread:%{threads:-lthread}}} \ | |
8433a25e RO |
98 | %{p|pg:-ldl} -lc}}" |
99 | ||
100 | #undef ENDFILE_SPEC | |
101 | #define ENDFILE_SPEC "crtend.o%s crtn.o%s" | |
102 | ||
103 | /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */ | |
104 | #undef STARTFILE_SPEC | |
105 | #define STARTFILE_SPEC "%{!shared: \ | |
106 | %{!symbolic: \ | |
107 | %{p:mcrt1.o%s} \ | |
108 | %{!p: \ | |
109 | %{pg:gcrt1.o%s gmon.o%s} \ | |
110 | %{!pg:crt1.o%s}}}} \ | |
111 | crti.o%s %(startfile_arch) \ | |
112 | crtbegin.o%s" | |
113 | ||
114 | #undef STARTFILE_ARCH32_SPEC | |
115 | #define STARTFILE_ARCH32_SPEC "%{ansi:values-Xc.o%s} \ | |
116 | %{!ansi:values-Xa.o%s}" | |
117 | ||
118 | #undef STARTFILE_ARCH_SPEC | |
119 | #define STARTFILE_ARCH_SPEC STARTFILE_ARCH32_SPEC | |
120 | ||
61aaea23 MM |
121 | #undef LINK_ARCH32_SPEC_BASE |
122 | #define LINK_ARCH32_SPEC_BASE \ | |
8433a25e RO |
123 | "%{G:-G} \ |
124 | %{YP,*} \ | |
125 | %{R*} \ | |
126 | %{compat-bsd: \ | |
127 | %{!YP,*:%{p|pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \ | |
128 | %{!p:%{!pg:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \ | |
129 | -R /usr/ucblib} \ | |
130 | %{!compat-bsd: \ | |
131 | %{!YP,*:%{p|pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \ | |
132 | %{!p:%{!pg:-Y P,/usr/ccs/lib:/usr/lib}}}}" | |
133 | ||
61aaea23 MM |
134 | #undef LINK_ARCH32_SPEC |
135 | #define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE | |
136 | ||
8433a25e RO |
137 | #undef LINK_ARCH_SPEC |
138 | #define LINK_ARCH_SPEC LINK_ARCH32_SPEC | |
139 | ||
140 | /* This should be the same as in svr4.h, except with -R added. */ | |
141 | #undef LINK_SPEC | |
142 | #define LINK_SPEC \ | |
143 | "%{h*} %{v:-V} \ | |
3f94bdec | 144 | %{b} \ |
8433a25e RO |
145 | %{static:-dn -Bstatic} \ |
146 | %{shared:-G -dy %{!mimpure-text:-z text}} \ | |
147 | %{symbolic:-Bsymbolic -G -dy -z text} \ | |
148 | %(link_arch) \ | |
149 | %{Qy:} %{!Qn:-Qy}" | |
150 | ||
6e70657a MM |
151 | /* The Solaris linker doesn't understand constructor priorities. (The |
152 | GNU linker does support constructor priorities, so GNU ld | |
153 | configuration files for Solaris override this setting.) */ | |
154 | #undef SUPPORTS_INIT_PRIORITY | |
155 | #define SUPPORTS_INIT_PRIORITY 0 | |
156 | ||
8433a25e RO |
157 | /* This defines which switch letters take arguments. |
158 | It is as in svr4.h but with -R added. */ | |
159 | #undef SWITCH_TAKES_ARG | |
160 | #define SWITCH_TAKES_ARG(CHAR) \ | |
161 | (DEFAULT_SWITCH_TAKES_ARG(CHAR) \ | |
162 | || (CHAR) == 'R' \ | |
163 | || (CHAR) == 'h' \ | |
164 | || (CHAR) == 'z') | |
165 | ||
166 | #define STDC_0_IN_SYSTEM_HEADERS 1 | |
167 | \f | |
168 | /* | |
169 | * Attempt to turn on access permissions for the stack. | |
170 | * | |
8433a25e RO |
171 | * _SC_STACK_PROT is only defined for post 2.6, but we want this code |
172 | * to run always. 2.6 can change the stack protection but has no way to | |
173 | * query it. | |
174 | * | |
175 | */ | |
176 | ||
ca11c37c | 177 | /* sys/mman.h is not present on some non-Solaris configurations |
e7a742ec | 178 | that use sol2.h, so ENABLE_EXECUTE_STACK must use a magic |
ca11c37c | 179 | number instead of the appropriate PROT_* flags. */ |
8433a25e | 180 | |
e7a742ec | 181 | #define ENABLE_EXECUTE_STACK \ |
8433a25e RO |
182 | \ |
183 | /* #define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC) */ \ | |
184 | \ | |
185 | static int need_enable_exec_stack; \ | |
186 | \ | |
187 | static void check_enabling(void) __attribute__ ((constructor)); \ | |
188 | static void check_enabling(void) \ | |
189 | { \ | |
190 | extern long sysconf(int); \ | |
191 | \ | |
192 | int prot = (int) sysconf(515 /* _SC_STACK_PROT */); \ | |
193 | if (prot != 7 /* STACK_PROT_RWX */) \ | |
194 | need_enable_exec_stack = 1; \ | |
195 | } \ | |
196 | \ | |
197 | extern void __enable_execute_stack (void *); \ | |
198 | void \ | |
d3157fb6 | 199 | __enable_execute_stack (void *addr) \ |
8433a25e | 200 | { \ |
84b8b0e0 | 201 | extern int mprotect(void *, size_t, int); \ |
8433a25e RO |
202 | if (!need_enable_exec_stack) \ |
203 | return; \ | |
204 | else { \ | |
205 | long size = getpagesize (); \ | |
206 | long mask = ~(size-1); \ | |
207 | char *page = (char *) (((long) addr) & mask); \ | |
208 | char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \ | |
209 | \ | |
210 | if (mprotect (page, end - page, 7 /* STACK_PROT_RWX */) < 0) \ | |
211 | perror ("mprotect of trampoline code"); \ | |
212 | } \ | |
213 | } | |
a2bec818 | 214 | |
07a43492 | 215 | /* Support Solaris-specific format checking for cmn_err. */ |
a2bec818 DJ |
216 | #define TARGET_N_FORMAT_TYPES 1 |
217 | #define TARGET_FORMAT_TYPES solaris_format_types | |
07a43492 DJ |
218 | |
219 | /* #pragma init and #pragma fini are implemented on top of init and | |
220 | fini attributes. */ | |
221 | #define SOLARIS_ATTRIBUTE_TABLE \ | |
222 | { "init", 0, 0, true, false, false, NULL }, \ | |
223 | { "fini", 0, 0, true, false, false, NULL } | |
224 | ||
225 | /* This is how to declare the size of a function. For Solaris, we output | |
226 | any .init or .fini entries here. */ | |
227 | #undef ASM_DECLARE_FUNCTION_SIZE | |
228 | #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ | |
229 | do \ | |
230 | { \ | |
231 | if (!flag_inhibit_size_directive) \ | |
232 | ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \ | |
233 | solaris_output_init_fini (FILE, DECL); \ | |
234 | } \ | |
235 | while (0) | |
236 | ||
237 | /* Register the Solaris-specific #pragma directives. */ | |
238 | #define REGISTER_TARGET_PRAGMAS() solaris_register_pragmas () | |
239 | ||
240 | extern GTY(()) tree solaris_pending_aligns; | |
241 | extern GTY(()) tree solaris_pending_inits; | |
242 | extern GTY(()) tree solaris_pending_finis; | |
b5b3e36a DJ |
243 | |
244 | /* Allow macro expansion in #pragma pack. */ | |
245 | #define HANDLE_PRAGMA_PACK_WITH_EXPANSION |