]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/sparc/linux64.h
re PR fortran/35990 (run-time abort for PACK of run-time zero sized array)
[thirdparty/gcc.git] / gcc / config / sparc / linux64.h
CommitLineData
956d6950 1/* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2f83c7d6 2 Copyright 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007
aa335b76 3 Free Software Foundation, Inc.
bfe87013
DE
4 Contributed by David S. Miller (davem@caip.rutgers.edu)
5
de0a398e 6This file is part of GCC.
bfe87013 7
de0a398e 8GCC is free software; you can redistribute it and/or modify
bfe87013 9it under the terms of the GNU General Public License as published by
2f83c7d6 10the Free Software Foundation; either version 3, or (at your option)
bfe87013
DE
11any later version.
12
de0a398e 13GCC is distributed in the hope that it will be useful,
bfe87013
DE
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
2f83c7d6
NC
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
bfe87013 21
fbf2ca7b
JJ
22#define TARGET_OS_CPP_BUILTINS() \
23 do \
24 { \
25 builtin_define_std ("unix"); \
26 builtin_define_std ("linux"); \
27 builtin_define ("_LONGLONG"); \
28 builtin_define ("__gnu_linux__"); \
29 builtin_assert ("system=linux"); \
30 builtin_assert ("system=unix"); \
31 builtin_assert ("system=posix"); \
32 if (TARGET_ARCH32 && TARGET_LONG_DOUBLE_128) \
33 builtin_define ("__LONG_DOUBLE_128__"); \
34 } \
9b8466f4
NB
35 while (0)
36
80ffc95e 37/* Don't assume anything about the header files. */
bfe87013
DE
38#define NO_IMPLICIT_EXTERN_C
39
bfe87013
DE
40#undef MD_EXEC_PREFIX
41#undef MD_STARTFILE_PREFIX
42
f2c0cb15
JJ
43#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
44 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc \
4c837a1e 45 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3 \
9eeaed6e
DM
46 || TARGET_CPU_DEFAULT == TARGET_CPU_niagara \
47 || TARGET_CPU_DEFAULT == TARGET_CPU_niagara2
345a6161
DM
48/* A 64 bit v9 compiler with stack-bias,
49 in a Medium/Low code model environment. */
50
51#undef TARGET_DEFAULT
52#define TARGET_DEFAULT \
53 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
33074e5f 54 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
345a6161
DM
55#endif
56
a0a301fc
DE
57#undef ASM_CPU_DEFAULT_SPEC
58#define ASM_CPU_DEFAULT_SPEC "-Av9a"
bfe87013 59
956d6950
JL
60/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
61 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
bfe87013 62 provides part of the support for getting C++ file-scope static
80ffc95e 63 object constructed before entering `main'. */
bfe87013
DE
64
65#undef STARTFILE_SPEC
345a6161 66
24a4dd31 67#ifdef HAVE_LD_PIE
5bbcd587 68#define STARTFILE_SPEC \
24a4dd31
JJ
69 "%{!shared:%{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
70 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
71#else
72#define STARTFILE_SPEC \
73 "%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\
74 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
75#endif
bfe87013 76
956d6950
JL
77/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
78 the GNU/Linux magical crtend.o file (see crtstuff.c) which
bfe87013
DE
79 provides part of the support for getting C++ file-scope static
80 object constructed before entering `main', followed by a normal
956d6950 81 GNU/Linux "finalizer" file, `crtn.o'. */
bfe87013
DE
82
83#undef ENDFILE_SPEC
345a6161 84
5bbcd587 85#define ENDFILE_SPEC \
24a4dd31 86 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
5bbcd587 87 %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
345a6161 88
2be1602e
DM
89/* The GNU C++ standard library requires that these macros be defined. */
90#undef CPLUSPLUS_CPP_SPEC
91#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
92
345a6161
DM
93#undef TARGET_VERSION
94#define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
a0a301fc
DE
95
96/* The default code model. */
97#undef SPARC_DEFAULT_CMODEL
be3f1ff5 98#define SPARC_DEFAULT_CMODEL CM_MEDLOW
bfe87013 99
bfe87013 100#undef WCHAR_TYPE
247cfc5c
JJ
101#define WCHAR_TYPE "int"
102
bfe87013 103#undef WCHAR_TYPE_SIZE
247cfc5c
JJ
104#define WCHAR_TYPE_SIZE 32
105
ba31d94e 106/* Define for support of TFmode long double.
56149abc 107 SPARC ABI says that long double is 4 words. */
a0a301fc 108#undef LONG_DOUBLE_TYPE_SIZE
4710d3eb
JJ
109#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
110
4710d3eb
JJ
111/* Define this to set long double type size to use in libgcc2.c, which can
112 not depend on target_flags. */
113#if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
114#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
115#else
116#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
117#endif
345a6161 118
a0a301fc
DE
119#undef CPP_SUBTARGET_SPEC
120#define CPP_SUBTARGET_SPEC "\
bfe87013 121%{posix:-D_POSIX_SOURCE} \
afc96791 122%{pthread:-D_REENTRANT} \
bfe87013 123"
afc96791 124
bfe87013
DE
125#undef LIB_SPEC
126#define LIB_SPEC \
17772b2a
JJ
127 "%{pthread:-lpthread} \
128 %{shared:-lc} \
129 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
bfe87013 130
956d6950 131/* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
bfe87013
DE
132 for the special GCC options -static and -shared, which allow us to
133 link things in one of these three modes by applying the appropriate
134 combinations of options at link-time. We like to support here for
135 as many of the other GNU linker options as possible. But I don't
136 have the time to search for those flags. I am sure how to add
137 support for -soname shared_object_name. H.J.
138
139 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
140 -Wl,-V.
141
142 When the -shared link option is used a final link is not being
143 done. */
144
80ffc95e 145/* If ELF is the default format, we should not use /lib/elf. */
bfe87013 146
7bd85ce0
JM
147#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
148#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
149#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
150#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
151#if UCLIBC_DEFAULT
152#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
153#else
154#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
155#endif
156#define LINUX_DYNAMIC_LINKER32 \
157 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
158#define LINUX_DYNAMIC_LINKER64 \
159 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
160
345a6161
DM
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 },
7bd85ce0 169
345a6161
DM
170#define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
171 %{!shared: \
172 %{!ibcs: \
173 %{!static: \
174 %{rdynamic:-export-dynamic} \
7bd85ce0 175 %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER32 "}} \
345a6161
DM
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} \
7bd85ce0 184 %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}} \
345a6161
DM
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
bfe87013 197#undef LINK_SPEC
345a6161
DM
198#define LINK_SPEC "\
199%(link_arch) \
200%{mlittle-endian:-EL} \
e95b1e6a 201%{!mno-relax:%{!r:-relax}} \
345a6161
DM
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} \
d6964c30 211%{m32:%{m64:%emay not use both -m32 and -m64}} \
4710d3eb 212%{m64:-mptr64 -mstack-bias -mlong-double-128 \
247cfc5c
JJ
213 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
214 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
345a6161
DM
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} \
d6964c30 222%{m32:%{m64:%emay not use both -m32 and -m64}} \
4710d3eb 223%{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
b25c3a22 224 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
9ce13279 225%{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
247cfc5c 226%{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
345a6161
DM
227"
228#endif
229
942e0f44
JJ
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
345a6161
DM
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
e95b1e6a 260#define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
bfe87013
DE
261 %{!shared: \
262 %{!ibcs: \
263 %{!static: \
264 %{rdynamic:-export-dynamic} \
7bd85ce0 265 %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}} \
bfe87013
DE
266 %{static:-static}}} \
267%{mlittle-endian:-EL} \
e95b1e6a 268%{!mno-relax:%{!r:-relax}} \
bfe87013
DE
269"
270
345a6161
DM
271#endif /* !SPARC_BI_ARCH */
272
bfe87013 273/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
80ffc95e 274 It's safe to pass -s always, even if -g is not used. */
bfe87013
DE
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,*:%*} \
24a4dd31 284-s %{fpic|fPIC|fpie|fPIE:-K PIC} \
bfe87013 285%{mlittle-endian:-EL} \
e95b1e6a 286%(asm_cpu) %(asm_arch) %(asm_relax)"
bfe87013
DE
287
288/* Same as sparc.h */
289#undef DBX_REGISTER_NUMBER
290#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
291
bfe87013
DE
292#undef ASM_OUTPUT_ALIGNED_LOCAL
293#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
294do { \
295 fputs ("\t.local\t", (FILE)); \
296 assemble_name ((FILE), (NAME)); \
297 putc ('\n', (FILE)); \
298 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
299} while (0)
300
301#undef COMMON_ASM_OP
471b6f1b 302#define COMMON_ASM_OP "\t.common\t"
bfe87013 303
59f96879
RH
304#undef LOCAL_LABEL_PREFIX
305#define LOCAL_LABEL_PREFIX "."
306
bfe87013
DE
307/* This is how to store into the string LABEL
308 the symbol_ref name of an internal numbered label where
309 PREFIX is the class of label and NUM is the number within the class.
310 This is suitable for output with `assemble_name'. */
311
312#undef ASM_GENERATE_INTERNAL_LABEL
313#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
e59f7d3d 314 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
bfe87013 315
bfe87013
DE
316/* DWARF bits. */
317
318/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
d6a7951f 319 Obviously the Dwarf2 folks haven't tried to actually build systems
bfe87013
DE
320 with their spec. On a 64-bit system, only 64-bit relocs become
321 RELATIVE relocations. */
322
323/* #define DWARF_OFFSET_SIZE PTR_SIZE */
275b60d6 324
45dcc026
JJ
325#undef DITF_CONVERSION_LIBFUNCS
326#define DITF_CONVERSION_LIBFUNCS 1
327
275b60d6
JJ
328#if defined(HAVE_LD_EH_FRAME_HDR)
329#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
330#endif
f7e0e539 331\f
5751a10b
JJ
332#ifdef HAVE_AS_TLS
333#undef TARGET_SUN_TLS
334#undef TARGET_GNU_TLS
335#define TARGET_SUN_TLS 0
336#define TARGET_GNU_TLS 1
337#endif
338\f
b5de1a27
DM
339/* Don't be different from other Linux platforms in this regard. */
340#define HANDLE_PRAGMA_PACK_PUSH_POP
7a31a340
DM
341
342/* We use GNU ld so undefine this so that attribute((init_priority)) works. */
343#undef CTORS_SECTION_ASM_OP
344#undef DTORS_SECTION_ASM_OP
db430d26 345
a4d05547 346/* Determine whether the entire c99 runtime is present in the
3017c534 347 runtime library. */
7bd85ce0 348#define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
3017c534 349
006339cd
RG
350/* Whether we have sincos that follows the GNU extension. */
351#define TARGET_HAS_SINCOS (OPTION_GLIBC)
352
4969c0d8 353#define TARGET_POSIX_IO
c2cd64b5 354
d00eacab 355#undef LINK_GCC_C_SEQUENCE_SPEC
42df2193
JJ
356#define LINK_GCC_C_SEQUENCE_SPEC \
357 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
358
8efcd34f
AM
359/* Use --as-needed -lgcc_s for eh support. */
360#ifdef HAVE_LD_AS_NEEDED
361#define USE_LD_AS_NEEDED 1
362#endif
363
8662eb14 364#define MD_UNWIND_SUPPORT "config/sparc/linux-unwind.h"
548a6c4f
EB
365
366/* Linux currently uses RMO in uniprocessor mode, which is equivalent to
367 TMO, and TMO in multiprocessor mode. But they reserve the right to
368 change their minds. */
369#undef SPARC_RELAXED_ORDERING
370#define SPARC_RELAXED_ORDERING true
5e77eb53
EB
371
372#undef NEED_INDICATE_EXEC_STACK
373#define NEED_INDICATE_EXEC_STACK 1
8ec11fe9
JJ
374
375#ifdef TARGET_LIBC_PROVIDES_SSP
376/* sparc glibc provides __stack_chk_guard in [%g7 + 0x14],
377 sparc64 glibc provides it at [%g7 + 0x28]. */
378#define TARGET_THREAD_SSP_OFFSET (TARGET_ARCH64 ? 0x28 : 0x14)
379#endif
7269aee7
AH
380
381/* Define if long doubles should be mangled as 'g'. */
382#define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING