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