1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2 Copyright 1996, 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
3 Contributed by David S. Miller (davem@caip.rutgers.edu)
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #define TARGET_OS_CPP_BUILTINS() \
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"); \
35 /* Don't assume anything about the header files. */
36 #define NO_IMPLICIT_EXTERN_C
39 #undef MD_STARTFILE_PREFIX
41 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
42 /* A 64 bit v9 compiler with stack-bias,
43 in a Medium/Low code model environment. */
46 #define TARGET_DEFAULT \
47 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
48 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
51 #undef ASM_CPU_DEFAULT_SPEC
52 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
56 #undef CPP_ARCH32_SPEC
57 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__}"
61 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
62 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
63 provides part of the support for getting C++ file-scope static
64 object constructed before entering `main'. */
69 #define STARTFILE_SPEC \
70 "%{!shared:%{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
71 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
73 #define STARTFILE_SPEC \
74 "%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\
75 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
78 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
79 the GNU/Linux magical crtend.o file (see crtstuff.c) which
80 provides part of the support for getting C++ file-scope static
81 object constructed before entering `main', followed by a normal
82 GNU/Linux "finalizer" file, `crtn.o'. */
86 #define ENDFILE_SPEC \
87 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
88 %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
90 /* The GNU C++ standard library requires that these macros be defined. */
91 #undef CPLUSPLUS_CPP_SPEC
92 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
95 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
97 /* The default code model. */
98 #undef SPARC_DEFAULT_CMODEL
99 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
101 #undef SUBTARGET_SWITCHES
102 #define SUBTARGET_SWITCHES \
103 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
104 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
107 #define WCHAR_TYPE "int"
109 #undef WCHAR_TYPE_SIZE
110 #define WCHAR_TYPE_SIZE 32
112 /* Define for support of TFmode long double.
113 SPARC ABI says that long double is 4 words. */
114 #undef LONG_DOUBLE_TYPE_SIZE
115 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
117 /* Define this to set long double type size to use in libgcc2.c, which can
118 not depend on target_flags. */
119 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
120 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
122 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
125 #undef CPP_SUBTARGET_SPEC
126 #define CPP_SUBTARGET_SPEC "\
127 %{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \
128 %{posix:-D_POSIX_SOURCE} \
129 %{pthread:-D_REENTRANT} \
134 "%{pthread:-lpthread} \
136 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
138 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
139 for the special GCC options -static and -shared, which allow us to
140 link things in one of these three modes by applying the appropriate
141 combinations of options at link-time. We like to support here for
142 as many of the other GNU linker options as possible. But I don't
143 have the time to search for those flags. I am sure how to add
144 support for -soname shared_object_name. H.J.
146 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
149 When the -shared link option is used a final link is not being
152 /* If ELF is the default format, we should not use /lib/elf. */
156 #undef SUBTARGET_EXTRA_SPECS
157 #define SUBTARGET_EXTRA_SPECS \
158 { "link_arch32", LINK_ARCH32_SPEC }, \
159 { "link_arch64", LINK_ARCH64_SPEC }, \
160 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
161 { "link_arch", LINK_ARCH_SPEC },
163 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
167 %{rdynamic:-export-dynamic} \
168 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
169 %{static:-static}}} \
172 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
176 %{rdynamic:-export-dynamic} \
177 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
178 %{static:-static}}} \
181 #define LINK_ARCH_SPEC "\
182 %{m32:%(link_arch32)} \
183 %{m64:%(link_arch64)} \
184 %{!m32:%{!m64:%(link_arch_default)}} \
187 #define LINK_ARCH_DEFAULT_SPEC \
188 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
193 %{mlittle-endian:-EL} \
194 %{!mno-relax:%{!r:-relax}} \
200 %{sun4:} %{target:} \
201 %{mcypress:-mcpu=cypress} \
202 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
203 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
204 %{m32:%{m64:%emay not use both -m32 and -m64}} \
205 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
206 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
207 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
211 %{sun4:} %{target:} \
212 %{mcypress:-mcpu=cypress} \
213 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
214 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
215 %{m32:%{m64:%emay not use both -m32 and -m64}} \
216 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
217 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
218 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
219 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
224 #define MULTILIB_DEFAULTS { "m32" }
226 #define MULTILIB_DEFAULTS { "m64" }
229 #else /* !SPARC_BI_ARCH */
232 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
236 %{rdynamic:-export-dynamic} \
237 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
238 %{static:-static}}} \
239 %{mlittle-endian:-EL} \
240 %{!mno-relax:%{!r:-relax}} \
243 #endif /* !SPARC_BI_ARCH */
245 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
246 It's safe to pass -s always, even if -g is not used. */
256 -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
257 %{mlittle-endian:-EL} \
258 %(asm_cpu) %(asm_arch) %(asm_relax)"
260 /* Same as sparc.h */
261 #undef DBX_REGISTER_NUMBER
262 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
264 #define DWARF2_DEBUGGING_INFO 1
265 #define DBX_DEBUGGING_INFO 1
267 #undef ASM_OUTPUT_ALIGNED_LOCAL
268 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
270 fputs ("\t.local\t", (FILE)); \
271 assemble_name ((FILE), (NAME)); \
272 putc ('\n', (FILE)); \
273 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
277 #define COMMON_ASM_OP "\t.common\t"
279 #undef LOCAL_LABEL_PREFIX
280 #define LOCAL_LABEL_PREFIX "."
282 /* This is how to output a reference to an internal numbered label where
283 PREFIX is the class of label and NUM is the number within the class. */
285 #undef ASM_OUTPUT_INTERNAL_LABELREF
286 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
287 fprintf (FILE, ".L%s%d", PREFIX, NUM)
289 /* This is how to store into the string LABEL
290 the symbol_ref name of an internal numbered label where
291 PREFIX is the class of label and NUM is the number within the class.
292 This is suitable for output with `assemble_name'. */
294 #undef ASM_GENERATE_INTERNAL_LABEL
295 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
296 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
300 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
301 Obviously the Dwarf2 folks haven't tried to actually build systems
302 with their spec. On a 64-bit system, only 64-bit relocs become
303 RELATIVE relocations. */
305 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
307 #if defined(HAVE_LD_EH_FRAME_HDR)
308 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
312 #undef TARGET_SUN_TLS
313 #undef TARGET_GNU_TLS
314 #define TARGET_SUN_TLS 0
315 #define TARGET_GNU_TLS 1
318 /* Don't be different from other Linux platforms in this regard. */
319 #define HANDLE_PRAGMA_PACK_PUSH_POP
321 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
322 #undef CTORS_SECTION_ASM_OP
323 #undef DTORS_SECTION_ASM_OP
325 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
327 #undef LINK_GCC_C_SEQUENCE_SPEC
328 #define LINK_GCC_C_SEQUENCE_SPEC \
329 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
331 /* Do code reading to identify a signal frame, and set the frame
332 state data appropriately. See unwind-dw2.c for the structs. */
334 /* Handle multilib correctly. */
335 #if defined(__arch64__)
336 /* 64-bit SPARC version */
337 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
339 unsigned int *pc_ = (CONTEXT)->ra; \
341 long regs_off_, fpu_save_off_; \
342 long this_cfa_, fpu_save_; \
344 if (pc_[0] != 0x82102065 /* mov NR_rt_sigreturn, %g1 */ \
345 || pc_[1] != 0x91d0206d) /* ta 0x6d */ \
347 regs_off_ = 192 + 128; \
348 fpu_save_off_ = regs_off_ + (16 * 8) + (3 * 8) + (2 * 4); \
349 this_cfa_ = (long) (CONTEXT)->cfa; \
350 new_cfa_ = *(long *)(((CONTEXT)->cfa) + (regs_off_ + (14 * 8))); \
351 new_cfa_ += 2047; /* Stack bias */ \
352 fpu_save_ = *(long *)((this_cfa_) + (fpu_save_off_)); \
353 (FS)->cfa_how = CFA_REG_OFFSET; \
354 (FS)->cfa_reg = 14; \
355 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
356 for (i_ = 1; i_ < 16; ++i_) \
358 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
359 (FS)->regs.reg[i_].loc.offset = \
360 this_cfa_ + (regs_off_ + (i_ * 8)) - new_cfa_; \
362 for (i_ = 0; i_ < 16; ++i_) \
364 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
365 (FS)->regs.reg[i_ + 16].loc.offset = \
366 this_cfa_ + (i_ * 8) - new_cfa_; \
370 for (i_ = 0; i_ < 64; ++i_) \
372 if (i_ > 32 && (i_ & 0x1)) \
374 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
375 (FS)->regs.reg[i_ + 32].loc.offset = \
376 (fpu_save_ + (i_ * 4)) - new_cfa_; \
379 /* Stick return address into %g0, same trick Alpha uses. */ \
380 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
381 (FS)->regs.reg[0].loc.offset = \
382 this_cfa_ + (regs_off_ + (16 * 8) + 8) - new_cfa_; \
383 (FS)->retaddr_column = 0; \
387 /* 32-bit SPARC version */
388 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
390 unsigned int *pc_ = (CONTEXT)->ra; \
391 int new_cfa_, i_, oldstyle_; \
392 int regs_off_, fpu_save_off_; \
393 int fpu_save_, this_cfa_; \
395 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
397 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
399 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
406 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
410 regs_off_ = 96 + 128; \
411 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
413 this_cfa_ = (int) (CONTEXT)->cfa; \
414 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
415 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
416 (FS)->cfa_how = CFA_REG_OFFSET; \
417 (FS)->cfa_reg = 14; \
418 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
419 for (i_ = 1; i_ < 16; ++i_) \
423 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
424 (FS)->regs.reg[i_].loc.offset = \
425 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
427 for (i_ = 0; i_ < 16; ++i_) \
429 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
430 (FS)->regs.reg[i_ + 16].loc.offset = \
431 this_cfa_ + (i_ * 4) - new_cfa_; \
435 for (i_ = 0; i_ < 32; ++i_) \
437 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
438 (FS)->regs.reg[i_ + 32].loc.offset = \
439 (fpu_save_ + (i_ * 4)) - new_cfa_; \
442 /* Stick return address into %g0, same trick Alpha uses. */ \
443 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
444 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
445 (FS)->retaddr_column = 0; \