OSDN Git Service

* config/darwin.c, config/darwin.h, config/freebsd-spec.h,
[pf3gnuchains/gcc-fork.git] / gcc / config / sparc / linux64.h
1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2    Copyright 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005
3    Free Software Foundation, Inc.
4    Contributed by David S. Miller (davem@caip.rutgers.edu)
5
6 This file is part of GCC.
7
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 2, or (at your option)
11 any later version.
12
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.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 #define TARGET_OS_CPP_BUILTINS()                \
24   do                                            \
25     {                                           \
26         builtin_define_std ("unix");            \
27         builtin_define_std ("linux");           \
28         builtin_define ("_LONGLONG");           \
29         builtin_define ("__gnu_linux__");       \
30         builtin_assert ("system=linux");        \
31         builtin_assert ("system=unix");         \
32         builtin_assert ("system=posix");        \
33         if (flag_pic)                           \
34           {                                     \
35                 builtin_define ("__PIC__");     \
36                 builtin_define ("__pic__");     \
37           }                                     \
38     }                                           \
39   while (0)
40
41 /* Don't assume anything about the header files.  */
42 #define NO_IMPLICIT_EXTERN_C
43
44 #undef MD_EXEC_PREFIX
45 #undef MD_STARTFILE_PREFIX
46
47 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
48     || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc \
49     || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3
50 /* A 64 bit v9 compiler with stack-bias,
51    in a Medium/Low code model environment.  */
52
53 #undef TARGET_DEFAULT
54 #define TARGET_DEFAULT \
55   (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
56    + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
57 #endif
58
59 #undef ASM_CPU_DEFAULT_SPEC
60 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
61
62 #ifdef SPARC_BI_ARCH
63
64 #undef CPP_ARCH32_SPEC
65 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
66
67 #endif
68
69 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
70    the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
71    provides part of the support for getting C++ file-scope static
72    object constructed before entering `main'.  */
73    
74 #undef  STARTFILE_SPEC
75
76 #ifdef HAVE_LD_PIE
77 #define STARTFILE_SPEC \
78   "%{!shared:%{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
79    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
80 #else
81 #define STARTFILE_SPEC \
82   "%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\
83    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
84 #endif
85
86 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
87    the GNU/Linux magical crtend.o file (see crtstuff.c) which
88    provides part of the support for getting C++ file-scope static
89    object constructed before entering `main', followed by a normal
90    GNU/Linux "finalizer" file, `crtn.o'.  */
91
92 #undef  ENDFILE_SPEC
93
94 #define ENDFILE_SPEC \
95   "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
96    %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
97
98 /* The GNU C++ standard library requires that these macros be defined.  */
99 #undef CPLUSPLUS_CPP_SPEC
100 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
101
102 #undef TARGET_VERSION
103 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
104
105 /* The default code model.  */
106 #undef SPARC_DEFAULT_CMODEL
107 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
108
109 #undef SUBTARGET_SWITCHES
110 #define SUBTARGET_SWITCHES                                                  \
111 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") },  \
112 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
113
114 #undef WCHAR_TYPE
115 #define WCHAR_TYPE "int"
116
117 #undef WCHAR_TYPE_SIZE
118 #define WCHAR_TYPE_SIZE 32
119
120 /* Define for support of TFmode long double.
121    SPARC ABI says that long double is 4 words.  */
122 #undef LONG_DOUBLE_TYPE_SIZE
123 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
124
125 /* Define this to set long double type size to use in libgcc2.c, which can
126    not depend on target_flags.  */
127 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
128 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
129 #else
130 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
131 #endif
132
133 #undef CPP_SUBTARGET_SPEC
134 #define CPP_SUBTARGET_SPEC "\
135 %{posix:-D_POSIX_SOURCE} \
136 %{pthread:-D_REENTRANT} \
137 "
138
139 #undef LIB_SPEC
140 #define LIB_SPEC \
141   "%{pthread:-lpthread} \
142    %{shared:-lc} \
143    %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
144
145 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
146    for the special GCC options -static and -shared, which allow us to
147    link things in one of these three modes by applying the appropriate
148    combinations of options at link-time. We like to support here for
149    as many of the other GNU linker options as possible. But I don't
150    have the time to search for those flags. I am sure how to add
151    support for -soname shared_object_name. H.J.
152
153    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
154    -Wl,-V.
155
156    When the -shared link option is used a final link is not being
157    done.  */
158
159 /* If ELF is the default format, we should not use /lib/elf.  */
160
161 #ifdef SPARC_BI_ARCH
162
163 #undef SUBTARGET_EXTRA_SPECS
164 #define SUBTARGET_EXTRA_SPECS \
165   { "link_arch32",       LINK_ARCH32_SPEC },              \
166   { "link_arch64",       LINK_ARCH64_SPEC },              \
167   { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },        \
168   { "link_arch",         LINK_ARCH_SPEC },
169     
170 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
171   %{!shared: \
172     %{!ibcs: \
173       %{!static: \
174         %{rdynamic:-export-dynamic} \
175         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
176         %{static:-static}}} \
177 "
178
179 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
180   %{!shared: \
181     %{!ibcs: \
182       %{!static: \
183         %{rdynamic:-export-dynamic} \
184         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
185         %{static:-static}}} \
186 "
187
188 #define LINK_ARCH_SPEC "\
189 %{m32:%(link_arch32)} \
190 %{m64:%(link_arch64)} \
191 %{!m32:%{!m64:%(link_arch_default)}} \
192 "
193
194 #define LINK_ARCH_DEFAULT_SPEC \
195 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
196
197 #undef  LINK_SPEC
198 #define LINK_SPEC "\
199 %(link_arch) \
200 %{mlittle-endian:-EL} \
201 %{!mno-relax:%{!r:-relax}} \
202 "
203
204 #undef  CC1_SPEC
205 #if DEFAULT_ARCH32_P
206 #define CC1_SPEC "\
207 %{sun4:} %{target:} \
208 %{mcypress:-mcpu=cypress} \
209 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
210 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
211 %{m32:%{m64:%emay not use both -m32 and -m64}} \
212 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
213   %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
214   %{!mno-vis:%{!mcpu=v9:-mvis}}} \
215 "
216 #else
217 #define CC1_SPEC "\
218 %{sun4:} %{target:} \
219 %{mcypress:-mcpu=cypress} \
220 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
221 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
222 %{m32:%{m64:%emay not use both -m32 and -m64}} \
223 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
224   %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
225 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
226 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
227 "
228 #endif
229
230 /* Support for a compile-time default CPU, et cetera.  The rules are:
231    --with-cpu is ignored if -mcpu is specified.
232    --with-tune is ignored if -mtune is specified.
233    --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
234      are specified.
235    In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
236    here, otherwise say -mcpu=v7 would be passed even when -m64.
237    CC1_SPEC above takes care of this instead.  */
238 #undef OPTION_DEFAULT_SPECS
239 #if DEFAULT_ARCH32_P
240 #define OPTION_DEFAULT_SPECS \
241   {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
242   {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
243   {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
244 #else
245 #define OPTION_DEFAULT_SPECS \
246   {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
247   {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
248   {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
249 #endif
250
251 #if DEFAULT_ARCH32_P
252 #define MULTILIB_DEFAULTS { "m32" }
253 #else
254 #define MULTILIB_DEFAULTS { "m64" }
255 #endif
256
257 #else /* !SPARC_BI_ARCH */
258
259 #undef LINK_SPEC
260 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
261   %{!shared: \
262     %{!ibcs: \
263       %{!static: \
264         %{rdynamic:-export-dynamic} \
265         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
266         %{static:-static}}} \
267 %{mlittle-endian:-EL} \
268 %{!mno-relax:%{!r:-relax}} \
269 "
270
271 #endif /* !SPARC_BI_ARCH */
272
273 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
274    It's safe to pass -s always, even if -g is not used.  */
275 #undef ASM_SPEC
276 #define ASM_SPEC "\
277 %{V} \
278 %{v:%{!V:-V}} \
279 %{!Qn:-Qy} \
280 %{n} \
281 %{T} \
282 %{Ym,*} \
283 %{Wa,*:%*} \
284 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
285 %{mlittle-endian:-EL} \
286 %(asm_cpu) %(asm_arch) %(asm_relax)"
287
288 /* Same as sparc.h */
289 #undef DBX_REGISTER_NUMBER
290 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
291
292 #define DWARF2_DEBUGGING_INFO 1
293 #define DBX_DEBUGGING_INFO 1
294
295 #undef ASM_OUTPUT_ALIGNED_LOCAL
296 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
297 do {                                                                    \
298   fputs ("\t.local\t", (FILE));         \
299   assemble_name ((FILE), (NAME));                                       \
300   putc ('\n', (FILE));                                                  \
301   ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);                  \
302 } while (0)
303
304 #undef COMMON_ASM_OP
305 #define COMMON_ASM_OP "\t.common\t"
306
307 #undef  LOCAL_LABEL_PREFIX
308 #define LOCAL_LABEL_PREFIX  "."
309
310 /* This is how to output a reference to an internal numbered label where
311    PREFIX is the class of label and NUM is the number within the class.  */
312
313 #undef  ASM_OUTPUT_INTERNAL_LABELREF
314 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)   \
315   fprintf (FILE, ".L%s%d", PREFIX, NUM)
316
317 /* This is how to store into the string LABEL
318    the symbol_ref name of an internal numbered label where
319    PREFIX is the class of label and NUM is the number within the class.
320    This is suitable for output with `assemble_name'.  */
321
322 #undef  ASM_GENERATE_INTERNAL_LABEL
323 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
324   sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
325
326 /* DWARF bits.  */
327
328 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets. 
329    Obviously the Dwarf2 folks haven't tried to actually build systems
330    with their spec.  On a 64-bit system, only 64-bit relocs become
331    RELATIVE relocations.  */
332
333 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
334
335 #undef DITF_CONVERSION_LIBFUNCS
336 #define DITF_CONVERSION_LIBFUNCS 1
337
338 #if defined(HAVE_LD_EH_FRAME_HDR)
339 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
340 #endif
341 \f
342 #ifdef HAVE_AS_TLS
343 #undef TARGET_SUN_TLS
344 #undef TARGET_GNU_TLS
345 #define TARGET_SUN_TLS 0
346 #define TARGET_GNU_TLS 1
347 #endif
348 \f
349 /* Don't be different from other Linux platforms in this regard.  */
350 #define HANDLE_PRAGMA_PACK_PUSH_POP
351
352 /* We use GNU ld so undefine this so that attribute((init_priority)) works.  */
353 #undef CTORS_SECTION_ASM_OP
354 #undef DTORS_SECTION_ASM_OP
355
356 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
357
358 /* Determine whether the the entire c99 runtime is present in the
359    runtime library.  */
360 #define TARGET_C99_FUNCTIONS 1
361
362 #define TARGET_HAS_F_SETLKW
363
364 #undef LINK_GCC_C_SEQUENCE_SPEC
365 #define LINK_GCC_C_SEQUENCE_SPEC \
366   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
367
368 /* Use --as-needed -lgcc_s for eh support.  */
369 #ifdef HAVE_LD_AS_NEEDED
370 #define USE_LD_AS_NEEDED 1
371 #endif
372
373 #define MD_UNWIND_SUPPORT "config/sparc/linux-unwind.h"
374
375 /* Linux currently uses RMO in uniprocessor mode, which is equivalent to
376    TMO, and TMO in multiprocessor mode.  But they reserve the right to
377    change their minds.  */
378 #undef SPARC_RELAXED_ORDERING
379 #define SPARC_RELAXED_ORDERING true