1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2 Copyright 1996, 1997, 1998, 2000, 2002, 2003, 2004
3 Free Software Foundation, Inc.
4 Contributed by David S. Miller (davem@caip.rutgers.edu)
6 This file is part of GCC.
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)
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.
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. */
23 #define TARGET_OS_CPP_BUILTINS() \
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"); \
35 builtin_define ("__PIC__"); \
36 builtin_define ("__pic__"); \
41 /* Don't assume anything about the header files. */
42 #define NO_IMPLICIT_EXTERN_C
45 #undef MD_STARTFILE_PREFIX
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. */
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)
59 #undef ASM_CPU_DEFAULT_SPEC
60 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
64 #undef CPP_ARCH32_SPEC
65 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
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'. */
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}"
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}"
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'. */
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}"
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)"
102 #undef TARGET_VERSION
103 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
105 /* The default code model. */
106 #undef SPARC_DEFAULT_CMODEL
107 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
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") },
115 #define WCHAR_TYPE "int"
117 #undef WCHAR_TYPE_SIZE
118 #define WCHAR_TYPE_SIZE 32
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)
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
130 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
133 #undef CPP_SUBTARGET_SPEC
134 #define CPP_SUBTARGET_SPEC "\
135 %{posix:-D_POSIX_SOURCE} \
136 %{pthread:-D_REENTRANT} \
141 "%{pthread:-lpthread} \
143 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
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.
153 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
156 When the -shared link option is used a final link is not being
159 /* If ELF is the default format, we should not use /lib/elf. */
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 },
170 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
174 %{rdynamic:-export-dynamic} \
175 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
176 %{static:-static}}} \
179 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
183 %{rdynamic:-export-dynamic} \
184 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
185 %{static:-static}}} \
188 #define LINK_ARCH_SPEC "\
189 %{m32:%(link_arch32)} \
190 %{m64:%(link_arch64)} \
191 %{!m32:%{!m64:%(link_arch_default)}} \
194 #define LINK_ARCH_DEFAULT_SPEC \
195 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
200 %{mlittle-endian:-EL} \
201 %{!mno-relax:%{!r:-relax}} \
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}}} \
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}}} \
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
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
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}}}}" }
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}}}}" }
252 #define MULTILIB_DEFAULTS { "m32" }
254 #define MULTILIB_DEFAULTS { "m64" }
257 #else /* !SPARC_BI_ARCH */
260 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
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}} \
271 #endif /* !SPARC_BI_ARCH */
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. */
284 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
285 %{mlittle-endian:-EL} \
286 %(asm_cpu) %(asm_arch) %(asm_relax)"
288 /* Same as sparc.h */
289 #undef DBX_REGISTER_NUMBER
290 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
292 #define DWARF2_DEBUGGING_INFO 1
293 #define DBX_DEBUGGING_INFO 1
295 #undef ASM_OUTPUT_ALIGNED_LOCAL
296 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
298 fputs ("\t.local\t", (FILE)); \
299 assemble_name ((FILE), (NAME)); \
300 putc ('\n', (FILE)); \
301 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
305 #define COMMON_ASM_OP "\t.common\t"
307 #undef LOCAL_LABEL_PREFIX
308 #define LOCAL_LABEL_PREFIX "."
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. */
313 #undef ASM_OUTPUT_INTERNAL_LABELREF
314 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
315 fprintf (FILE, ".L%s%d", PREFIX, NUM)
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'. */
322 #undef ASM_GENERATE_INTERNAL_LABEL
323 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
324 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
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. */
333 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
335 #undef DITF_CONVERSION_LIBFUNCS
336 #define DITF_CONVERSION_LIBFUNCS 1
338 #if defined(HAVE_LD_EH_FRAME_HDR)
339 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
343 #undef TARGET_SUN_TLS
344 #undef TARGET_GNU_TLS
345 #define TARGET_SUN_TLS 0
346 #define TARGET_GNU_TLS 1
349 /* Don't be different from other Linux platforms in this regard. */
350 #define HANDLE_PRAGMA_PACK_PUSH_POP
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
356 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
358 /* Determine whether the the entire c99 runtime is present in the
360 #define TARGET_C99_FUNCTIONS 1
362 #define TARGET_HAS_F_SETLKW
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}"
368 /* Use --as-needed -lgcc_s for eh support. */
369 #ifdef HAVE_LD_AS_NEEDED
370 #define USE_LD_AS_NEEDED 1
373 #define MD_UNWIND_SUPPORT "config/sparc/linux-unwind.h"
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