]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/sparc/linux64.h
linux64.h (OPTION_DEFAULT_SPECS): If SPARC_BI_ARCH, override sparc.h definition.
[thirdparty/gcc.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
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 } \
34 while (0)
35
36 /* Don't assume anything about the header files. */
37 #define NO_IMPLICIT_EXTERN_C
38
39 #undef MD_EXEC_PREFIX
40 #undef MD_STARTFILE_PREFIX
41
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. */
47
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
53
54 #undef ASM_CPU_DEFAULT_SPEC
55 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
56
57 #ifdef SPARC_BI_ARCH
58
59 #undef CPP_ARCH32_SPEC
60 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
61
62 #endif
63
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'. */
68
69 #undef STARTFILE_SPEC
70
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
80
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'. */
86
87 #undef ENDFILE_SPEC
88
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}"
92
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)"
96
97 #undef TARGET_VERSION
98 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
99
100 /* The default code model. */
101 #undef SPARC_DEFAULT_CMODEL
102 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
103
104 #undef SUBTARGET_SWITCHES
105 #define SUBTARGET_SWITCHES \
106 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
107 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
108
109 #undef WCHAR_TYPE
110 #define WCHAR_TYPE "int"
111
112 #undef WCHAR_TYPE_SIZE
113 #define WCHAR_TYPE_SIZE 32
114
115 /* Define for support of TFmode long double.
116 SPARC ABI says that long double is 4 words. */
117 #undef LONG_DOUBLE_TYPE_SIZE
118 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
119
120 /* Define this to set long double type size to use in libgcc2.c, which can
121 not depend on target_flags. */
122 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
123 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
124 #else
125 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
126 #endif
127
128 #undef CPP_SUBTARGET_SPEC
129 #define CPP_SUBTARGET_SPEC "\
130 %{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \
131 %{posix:-D_POSIX_SOURCE} \
132 %{pthread:-D_REENTRANT} \
133 "
134
135 #undef LIB_SPEC
136 #define LIB_SPEC \
137 "%{pthread:-lpthread} \
138 %{shared:-lc} \
139 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
140
141 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
142 for the special GCC options -static and -shared, which allow us to
143 link things in one of these three modes by applying the appropriate
144 combinations of options at link-time. We like to support here for
145 as many of the other GNU linker options as possible. But I don't
146 have the time to search for those flags. I am sure how to add
147 support for -soname shared_object_name. H.J.
148
149 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
150 -Wl,-V.
151
152 When the -shared link option is used a final link is not being
153 done. */
154
155 /* If ELF is the default format, we should not use /lib/elf. */
156
157 #ifdef SPARC_BI_ARCH
158
159 #undef SUBTARGET_EXTRA_SPECS
160 #define SUBTARGET_EXTRA_SPECS \
161 { "link_arch32", LINK_ARCH32_SPEC }, \
162 { "link_arch64", LINK_ARCH64_SPEC }, \
163 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
164 { "link_arch", LINK_ARCH_SPEC },
165
166 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
167 %{!shared: \
168 %{!ibcs: \
169 %{!static: \
170 %{rdynamic:-export-dynamic} \
171 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
172 %{static:-static}}} \
173 "
174
175 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
176 %{!shared: \
177 %{!ibcs: \
178 %{!static: \
179 %{rdynamic:-export-dynamic} \
180 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
181 %{static:-static}}} \
182 "
183
184 #define LINK_ARCH_SPEC "\
185 %{m32:%(link_arch32)} \
186 %{m64:%(link_arch64)} \
187 %{!m32:%{!m64:%(link_arch_default)}} \
188 "
189
190 #define LINK_ARCH_DEFAULT_SPEC \
191 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
192
193 #undef LINK_SPEC
194 #define LINK_SPEC "\
195 %(link_arch) \
196 %{mlittle-endian:-EL} \
197 %{!mno-relax:%{!r:-relax}} \
198 "
199
200 #undef CC1_SPEC
201 #if DEFAULT_ARCH32_P
202 #define CC1_SPEC "\
203 %{sun4:} %{target:} \
204 %{mcypress:-mcpu=cypress} \
205 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
206 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
207 %{m32:%{m64:%emay not use both -m32 and -m64}} \
208 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
209 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
210 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
211 "
212 #else
213 #define CC1_SPEC "\
214 %{sun4:} %{target:} \
215 %{mcypress:-mcpu=cypress} \
216 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
217 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
218 %{m32:%{m64:%emay not use both -m32 and -m64}} \
219 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
220 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
221 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
222 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
223 "
224 #endif
225
226 /* Support for a compile-time default CPU, et cetera. The rules are:
227 --with-cpu is ignored if -mcpu is specified.
228 --with-tune is ignored if -mtune is specified.
229 --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu
230 are specified.
231 In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)}
232 here, otherwise say -mcpu=v7 would be passed even when -m64.
233 CC1_SPEC above takes care of this instead. */
234 #undef OPTION_DEFAULT_SPECS
235 #if DEFAULT_ARCH32_P
236 #define OPTION_DEFAULT_SPECS \
237 {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
238 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
239 {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
240 #else
241 #define OPTION_DEFAULT_SPECS \
242 {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
243 {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
244 {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" }
245 #endif
246
247 #if DEFAULT_ARCH32_P
248 #define MULTILIB_DEFAULTS { "m32" }
249 #else
250 #define MULTILIB_DEFAULTS { "m64" }
251 #endif
252
253 #else /* !SPARC_BI_ARCH */
254
255 #undef LINK_SPEC
256 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
257 %{!shared: \
258 %{!ibcs: \
259 %{!static: \
260 %{rdynamic:-export-dynamic} \
261 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
262 %{static:-static}}} \
263 %{mlittle-endian:-EL} \
264 %{!mno-relax:%{!r:-relax}} \
265 "
266
267 #endif /* !SPARC_BI_ARCH */
268
269 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
270 It's safe to pass -s always, even if -g is not used. */
271 #undef ASM_SPEC
272 #define ASM_SPEC "\
273 %{V} \
274 %{v:%{!V:-V}} \
275 %{!Qn:-Qy} \
276 %{n} \
277 %{T} \
278 %{Ym,*} \
279 %{Wa,*:%*} \
280 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
281 %{mlittle-endian:-EL} \
282 %(asm_cpu) %(asm_arch) %(asm_relax)"
283
284 /* Same as sparc.h */
285 #undef DBX_REGISTER_NUMBER
286 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
287
288 #define DWARF2_DEBUGGING_INFO 1
289 #define DBX_DEBUGGING_INFO 1
290
291 #undef ASM_OUTPUT_ALIGNED_LOCAL
292 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
293 do { \
294 fputs ("\t.local\t", (FILE)); \
295 assemble_name ((FILE), (NAME)); \
296 putc ('\n', (FILE)); \
297 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
298 } while (0)
299
300 #undef COMMON_ASM_OP
301 #define COMMON_ASM_OP "\t.common\t"
302
303 #undef LOCAL_LABEL_PREFIX
304 #define LOCAL_LABEL_PREFIX "."
305
306 /* This is how to output a reference to an internal numbered label where
307 PREFIX is the class of label and NUM is the number within the class. */
308
309 #undef ASM_OUTPUT_INTERNAL_LABELREF
310 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
311 fprintf (FILE, ".L%s%d", PREFIX, NUM)
312
313 /* This is how to store into the string LABEL
314 the symbol_ref name of an internal numbered label where
315 PREFIX is the class of label and NUM is the number within the class.
316 This is suitable for output with `assemble_name'. */
317
318 #undef ASM_GENERATE_INTERNAL_LABEL
319 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
320 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
321
322 /* DWARF bits. */
323
324 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
325 Obviously the Dwarf2 folks haven't tried to actually build systems
326 with their spec. On a 64-bit system, only 64-bit relocs become
327 RELATIVE relocations. */
328
329 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
330
331 #undef DITF_CONVERSION_LIBFUNCS
332 #define DITF_CONVERSION_LIBFUNCS 1
333
334 #if defined(HAVE_LD_EH_FRAME_HDR)
335 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
336 #endif
337 \f
338 #ifdef HAVE_AS_TLS
339 #undef TARGET_SUN_TLS
340 #undef TARGET_GNU_TLS
341 #define TARGET_SUN_TLS 0
342 #define TARGET_GNU_TLS 1
343 #endif
344 \f
345 /* Don't be different from other Linux platforms in this regard. */
346 #define HANDLE_PRAGMA_PACK_PUSH_POP
347
348 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
349 #undef CTORS_SECTION_ASM_OP
350 #undef DTORS_SECTION_ASM_OP
351
352 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
353
354 #define TARGET_HAS_F_SETLKW
355
356 #undef LINK_GCC_C_SEQUENCE_SPEC
357 #define LINK_GCC_C_SEQUENCE_SPEC \
358 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
359
360 /* Use --as-needed -lgcc_s for eh support. */
361 #ifdef HAVE_LD_AS_NEEDED
362 #define USE_LD_AS_NEEDED 1
363 #endif
364
365 /* Do code reading to identify a signal frame, and set the frame
366 state data appropriately. See unwind-dw2.c for the structs. */
367
368 /* Handle multilib correctly. */
369 #if defined(__arch64__)
370 /* 64-bit SPARC version */
371 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
372 do { \
373 unsigned int *pc_ = (CONTEXT)->ra; \
374 long new_cfa_, i_; \
375 long regs_off_, fpu_save_off_; \
376 long this_cfa_, fpu_save_; \
377 \
378 if (pc_[0] != 0x82102065 /* mov NR_rt_sigreturn, %g1 */ \
379 || pc_[1] != 0x91d0206d) /* ta 0x6d */ \
380 break; \
381 regs_off_ = 192 + 128; \
382 fpu_save_off_ = regs_off_ + (16 * 8) + (3 * 8) + (2 * 4); \
383 this_cfa_ = (long) (CONTEXT)->cfa; \
384 new_cfa_ = *(long *)(((CONTEXT)->cfa) + (regs_off_ + (14 * 8))); \
385 new_cfa_ += 2047; /* Stack bias */ \
386 fpu_save_ = *(long *)((this_cfa_) + (fpu_save_off_)); \
387 (FS)->cfa_how = CFA_REG_OFFSET; \
388 (FS)->cfa_reg = 14; \
389 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
390 for (i_ = 1; i_ < 16; ++i_) \
391 { \
392 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
393 (FS)->regs.reg[i_].loc.offset = \
394 this_cfa_ + (regs_off_ + (i_ * 8)) - new_cfa_; \
395 } \
396 for (i_ = 0; i_ < 16; ++i_) \
397 { \
398 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
399 (FS)->regs.reg[i_ + 16].loc.offset = \
400 this_cfa_ + (i_ * 8) - new_cfa_; \
401 } \
402 if (fpu_save_) \
403 { \
404 for (i_ = 0; i_ < 64; ++i_) \
405 { \
406 if (i_ > 32 && (i_ & 0x1)) \
407 continue; \
408 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
409 (FS)->regs.reg[i_ + 32].loc.offset = \
410 (fpu_save_ + (i_ * 4)) - new_cfa_; \
411 } \
412 } \
413 /* Stick return address into %g0, same trick Alpha uses. */ \
414 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
415 (FS)->regs.reg[0].loc.offset = \
416 this_cfa_ + (regs_off_ + (16 * 8) + 8) - new_cfa_; \
417 (FS)->retaddr_column = 0; \
418 goto SUCCESS; \
419 } while (0)
420 #else
421 /* 32-bit SPARC version */
422 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
423 do { \
424 unsigned int *pc_ = (CONTEXT)->ra; \
425 int new_cfa_, i_, oldstyle_; \
426 int regs_off_, fpu_save_off_; \
427 int fpu_save_, this_cfa_; \
428 \
429 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
430 break; \
431 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
432 oldstyle_ = 1; \
433 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
434 oldstyle_ = 0; \
435 else \
436 break; \
437 if (oldstyle_) \
438 { \
439 regs_off_ = 96; \
440 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
441 } \
442 else \
443 { \
444 regs_off_ = 96 + 128; \
445 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
446 } \
447 this_cfa_ = (int) (CONTEXT)->cfa; \
448 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
449 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
450 (FS)->cfa_how = CFA_REG_OFFSET; \
451 (FS)->cfa_reg = 14; \
452 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
453 for (i_ = 1; i_ < 16; ++i_) \
454 { \
455 if (i_ == 14) \
456 continue; \
457 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
458 (FS)->regs.reg[i_].loc.offset = \
459 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
460 } \
461 for (i_ = 0; i_ < 16; ++i_) \
462 { \
463 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
464 (FS)->regs.reg[i_ + 16].loc.offset = \
465 this_cfa_ + (i_ * 4) - new_cfa_; \
466 } \
467 if (fpu_save_) \
468 { \
469 for (i_ = 0; i_ < 32; ++i_) \
470 { \
471 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
472 (FS)->regs.reg[i_ + 32].loc.offset = \
473 (fpu_save_ + (i_ * 4)) - new_cfa_; \
474 } \
475 } \
476 /* Stick return address into %g0, same trick Alpha uses. */ \
477 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
478 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
479 (FS)->retaddr_column = 0; \
480 goto SUCCESS; \
481 } while (0)
482 #endif