OSDN Git Service

a387dc24a1885a09f7fa20367c4e1465814ed902
[pf3gnuchains/gcc-fork.git] / gcc / config / sparc / sol2.h
1 /* Definitions of target machine for GNU compiler, for SPARC running Solaris 2
2    Copyright 1992, 1995, 1996, 1997, 1998, 1999, 2000,
3    2001 Free Software Foundation, Inc.
4    Contributed by Ron Guilmette (rfg@netcom.com).
5    Additional changes by David V. Henkel-Wallace (gumby@cygnus.com).
6
7 This file is part of GNU CC.
8
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING.  If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.  */
23
24 /* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
25
26 /* Solaris 2 uses a wint_t different from the default. This is required
27    by the SCD 2.4.1, p. 6-83, Figure 6-66.  */
28 #undef  WINT_TYPE
29 #define WINT_TYPE "long int"
30
31 #undef  WINT_TYPE_SIZE
32 #define WINT_TYPE_SIZE BITS_PER_WORD
33
34 #undef CPP_PREDEFINES
35 #define CPP_PREDEFINES \
36 "-Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 \
37 -Asystem=unix -Asystem=svr4"
38
39 #undef CPP_SUBTARGET_SPEC
40 #define CPP_SUBTARGET_SPEC "\
41 %{pthreads:-D_REENTRANT -D_PTHREADS} \
42 %{!pthreads:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}} \
43 %{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
44 "
45
46 /* For C++ we need to add some additional macro definitions required
47    by the C++ standard library.  */
48 #define CPLUSPLUS_CPP_SPEC "\
49 -D_XOPEN_SOURCE=500 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
50 -D__EXTENSIONS__ \
51 %(cpp) \
52 "
53
54 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
55    It's safe to pass -s always, even if -g is not used.  */
56 #undef ASM_SPEC
57 #define ASM_SPEC "\
58 %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
59 %{fpic:-K PIC} %{fPIC:-K PIC} \
60 %(asm_cpu) \
61 "
62
63 /* This is here rather than in sparc.h because it's not known what
64    other assemblers will accept.  */
65 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9
66 #undef ASM_CPU_DEFAULT_SPEC
67 #define ASM_CPU_DEFAULT_SPEC "-xarch=v8plus"
68 #endif
69 #if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
70 #undef ASM_CPU_DEFAULT_SPEC
71 #define ASM_CPU_DEFAULT_SPEC "-xarch=v8plusa"
72 #endif
73 #undef ASM_CPU_SPEC
74 #define ASM_CPU_SPEC "\
75 %{mcpu=v8plus:-xarch=v8plus} \
76 %{mcpu=ultrasparc:-xarch=v8plusa} \
77 %{!mcpu*:%(asm_cpu_default)} \
78 "
79
80 /* However it appears that Solaris 2.0 uses the same reg numbering as
81    the old BSD-style system did.  */
82
83 #undef DBX_REGISTER_NUMBER
84 /* Same as sparc.h */
85 #define DBX_REGISTER_NUMBER(REGNO) \
86   (TARGET_FLAT && (REGNO) == HARD_FRAME_POINTER_REGNUM ? 31 : REGNO)
87
88 /* We use stabs-in-elf for debugging, because that is what the native
89    toolchain uses.  */
90 #undef PREFERRED_DEBUGGING_TYPE
91 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
92
93 /* The Solaris 2 assembler uses .skip, not .zero, so put this back.  */
94 #undef ASM_OUTPUT_SKIP
95 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
96   fprintf (FILE, "\t.skip %u\n", (SIZE))
97
98 /* This is how to output a definition of an internal numbered label where
99    PREFIX is the class of label and NUM is the number within the class.  */
100
101 #undef  ASM_OUTPUT_INTERNAL_LABEL
102 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
103   fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
104
105 /* This is how to output a reference to an internal numbered label where
106    PREFIX is the class of label and NUM is the number within the class.  */
107
108 #undef  ASM_OUTPUT_INTERNAL_LABELREF
109 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)   \
110   fprintf (FILE, ".L%s%d", PREFIX, NUM)
111
112 /* This is how to store into the string LABEL
113    the symbol_ref name of an internal numbered label where
114    PREFIX is the class of label and NUM is the number within the class.
115    This is suitable for output with `assemble_name'.  */
116
117 #undef  ASM_GENERATE_INTERNAL_LABEL
118 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
119   sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
120
121 \f
122 /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us.
123    We don't use the standard LIB_SPEC only because we don't yet support c++ */
124
125 #undef STARTFILE_SPEC
126 #define STARTFILE_SPEC "%{!shared: \
127                          %{!symbolic: \
128                           %{p:mcrt1.o%s} \
129                           %{!p: \
130                             %{pg:gcrt1.o%s gmon.o%s} \
131                             %{!pg:crt1.o%s}}}} \
132                         crti.o%s \
133                         %{ansi:values-Xc.o%s} \
134                         %{!ansi: \
135                          %{traditional:values-Xt.o%s} \
136                          %{!traditional:values-Xa.o%s}} \
137                         crtbegin.o%s"
138
139 /* ??? Note: in order for -compat-bsd to work fully,
140    we must somehow arrange to fixincludes /usr/ucbinclude
141    and put the result in $(libsubdir)/ucbinclude.  */
142
143 #undef LIB_SPEC
144 #define LIB_SPEC \
145   "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
146    %{!shared:\
147      %{!symbolic:\
148        %{pthreads:-lpthread} \
149        %{!pthreads:%{threads:-lthread}} \
150        %{p|pg:-ldl} -lc}}"
151
152 #undef  ENDFILE_SPEC
153 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
154
155 /* This should be the same as in svr4.h, except with -R added.  */
156 #undef LINK_SPEC
157 #define LINK_SPEC \
158   "%{h*} %{v:-V} \
159    %{b} %{Wl,*:%*} \
160    %{static:-dn -Bstatic} \
161    %{shared:-G -dy %{!mimpure-text:-z text}} \
162    %{symbolic:-Bsymbolic -G -dy -z text} \
163    %{G:-G} \
164    %{YP,*} \
165    %{R*} \
166    %{compat-bsd: \
167      %{!YP,*:%{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
168              %{!pg:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
169                    %{!p:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
170              -R /usr/ucblib} \
171    %{!compat-bsd: \
172      %{!YP,*:%{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
173              %{!pg:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
174                    %{!p:-Y P,/usr/ccs/lib:/usr/lib}}}} \
175    %{Qy:} %{!Qn:-Qy}"
176
177 /* This defines which switch letters take arguments.
178    It is as in svr4.h but with -R added.  */
179
180 #undef SWITCH_TAKES_ARG
181 #define SWITCH_TAKES_ARG(CHAR) \
182   (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
183    || (CHAR) == 'R' \
184    || (CHAR) == 'h' \
185    || (CHAR) == 'x' \
186    || (CHAR) == 'z')
187
188 /* Select a format to encode pointers in exception handling data.  CODE
189    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
190    true if the symbol may be affected by dynamic relocations.
191
192    Some Solaris dynamic linkers don't handle unaligned section relative
193    relocs properly, so force them to be aligned.  */
194 #ifndef HAVE_AS_SPARC_UA_PCREL
195 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)               \
196   ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr)
197 #endif
198 \f
199 /* ??? This does not work in SunOS 4.x, so it is not enabled in sparc.h.
200    Instead, it is enabled here, because it does work under Solaris.  */
201 /* Define for support of TFmode long double and REAL_ARITHMETIC.
202    Sparc ABI says that long double is 4 words.  */
203 #define LONG_DOUBLE_TYPE_SIZE 128
204
205 /* But indicate that it isn't supported by the hardware.  */
206 #define WIDEST_HARDWARE_FP_SIZE 64
207
208 #define STDC_0_IN_SYSTEM_HEADERS 1
209
210 #define MULDI3_LIBCALL "__mul64"
211 #define DIVDI3_LIBCALL "__div64"
212 #define UDIVDI3_LIBCALL "__udiv64"
213 #define MODDI3_LIBCALL "__rem64"
214 #define UMODDI3_LIBCALL "__urem64"
215
216 #undef INIT_SUBTARGET_OPTABS
217 #define INIT_SUBTARGET_OPTABS                                           \
218   fixsfdi_libfunc                                                       \
219     = init_one_libfunc (TARGET_ARCH64 ? "__ftol" : "__ftoll");          \
220   fixunssfdi_libfunc                                                    \
221     = init_one_libfunc (TARGET_ARCH64 ? "__ftoul" : "__ftoull");        \
222   fixdfdi_libfunc                                                       \
223     = init_one_libfunc (TARGET_ARCH64 ? "__dtol" : "__dtoll");          \
224   fixunsdfdi_libfunc                                                    \
225     = init_one_libfunc (TARGET_ARCH64 ? "__dtoul" : "__dtoull")
226
227 /* Solaris allows 64 bit out and global registers in 32 bit mode.
228    sparc_override_options will disable V8+ if not generating V9 code.  */
229 #undef TARGET_DEFAULT
230 #define TARGET_DEFAULT (MASK_EPILOGUE + MASK_FPU + MASK_V8PLUS + MASK_LONG_DOUBLE_128)
231 \f
232 /*
233  * Attempt to turn on access permissions for the stack.
234  *
235  * This code must be defined when compiling gcc but not when compiling
236  * libgcc2.a, unless we're generating code for 64 bits SPARC
237  *
238  * _SC_STACK_PROT is only defined for post 2.6, but we want this code
239  * to run always.  2.6 can change the stack protection but has no way to
240  * query it.
241  *
242  */
243
244 /* This declares mprotect (used in TRANSFER_FROM_TRAMPOLINE) for
245    libgcc2.c.  */
246 #ifdef L_trampoline
247 #include <sys/mman.h>
248 #endif
249
250 #define TRANSFER_FROM_TRAMPOLINE                                        \
251 static int need_enable_exec_stack;                                      \
252                                                                         \
253 static void check_enabling(void) __attribute__ ((constructor));         \
254 static void check_enabling(void)                                        \
255 {                                                                       \
256   extern long sysconf(int);                                             \
257                                                                         \
258   int prot = (int) sysconf(515 /*_SC_STACK_PROT */);                    \
259   if (prot != 7)                                                        \
260     need_enable_exec_stack = 1;                                         \
261 }                                                                       \
262                                                                         \
263 extern void __enable_execute_stack (void *);                            \
264 void                                                                    \
265 __enable_execute_stack (addr)                                           \
266      void *addr;                                                        \
267 {                                                                       \
268   if (!need_enable_exec_stack)                                          \
269     return;                                                             \
270   else {                                                                \
271     long size = getpagesize ();                                         \
272     long mask = ~(size-1);                                              \
273     char *page = (char *) (((long) addr) & mask);                       \
274     char *end  = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
275                                                                         \
276     /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */                       \
277     if (mprotect (page, end - page, 7) < 0)                             \
278       perror ("mprotect of trampoline code");                           \
279   }                                                                     \
280 }