1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2 Copyright 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
3 Contributed by David S. Miller (davem@caip.rutgers.edu)
5 This file is part of GNU CC.
7 GNU CC 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 GNU CC 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 GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #define LINUX_DEFAULT_ELF
26 /* Don't assume anything about the header files. */
27 #define NO_IMPLICIT_EXTERN_C
29 #undef DEFAULT_VTABLE_THUNKS
30 #define DEFAULT_VTABLE_THUNKS 1
32 #include <sparc/sysv4.h>
35 #undef MD_STARTFILE_PREFIX
37 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
38 /* A 64 bit v9 compiler with stack-bias,
39 in a Medium/Low code model environment. */
42 #define TARGET_DEFAULT \
43 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
44 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU + MASK_LONG_DOUBLE_128)
47 #undef ASM_CPU_DEFAULT_SPEC
48 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
52 #undef CPP_ARCH32_SPEC
53 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__} \
54 -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
55 -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc"
59 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
60 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
61 provides part of the support for getting C++ file-scope static
62 object constructed before entering `main'. */
66 #define STARTFILE_SPEC32 \
68 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
69 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
71 #define STARTFILE_SPEC64 \
73 %{pg:/usr/lib64/gcrt1.o%s} %{!pg:%{p:/usr/lib64/gcrt1.o%s} %{!p:/usr/lib64/crt1.o%s}}}\
74 /usr/lib64/crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
79 #define STARTFILE_SPEC "\
80 %{m32:" STARTFILE_SPEC32 "} \
81 %{m64:" STARTFILE_SPEC64 "} \
82 %{!m32:%{!m64:" STARTFILE_SPEC32 "}}"
84 #define STARTFILE_SPEC "\
85 %{m32:" STARTFILE_SPEC32 "} \
86 %{m64:" STARTFILE_SPEC64 "} \
87 %{!m32:%{!m64:" STARTFILE_SPEC64 "}}"
92 #define STARTFILE_SPEC STARTFILE_SPEC64
96 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
97 the GNU/Linux magical crtend.o file (see crtstuff.c) which
98 provides part of the support for getting C++ file-scope static
99 object constructed before entering `main', followed by a normal
100 GNU/Linux "finalizer" file, `crtn.o'. */
104 #define ENDFILE_SPEC32 \
105 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
107 #define ENDFILE_SPEC64 \
108 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} /usr/lib64/crtn.o%s"
113 #define ENDFILE_SPEC "\
114 %{m32:" ENDFILE_SPEC32 "} \
115 %{m64:" ENDFILE_SPEC64 "} \
116 %{!m32:%{!m64:" ENDFILE_SPEC32 "}}"
118 #define ENDFILE_SPEC "\
119 %{m32:" ENDFILE_SPEC32 "} \
120 %{m64:" ENDFILE_SPEC64 "} \
121 %{!m32:%{!m64:" ENDFILE_SPEC64 "}}"
126 #define ENDFILE_SPEC ENDFILE_SPEC64
130 #undef TARGET_VERSION
131 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
133 /* The default code model. */
134 #undef SPARC_DEFAULT_CMODEL
135 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
137 #undef SUBTARGET_SWITCHES
138 #define SUBTARGET_SWITCHES \
139 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
140 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
143 #define WCHAR_TYPE "int"
145 #undef WCHAR_TYPE_SIZE
146 #define WCHAR_TYPE_SIZE 32
148 #undef MAX_WCHAR_TYPE_SIZE
150 /* Define for support of TFmode long double and REAL_ARITHMETIC.
151 Sparc ABI says that long double is 4 words. */
152 #undef LONG_DOUBLE_TYPE_SIZE
153 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
155 /* Constant which presents upper bound of the above value. */
156 #undef MAX_LONG_DOUBLE_TYPE_SIZE
157 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
159 /* Define this to set long double type size to use in libgcc2.c, which can
160 not depend on target_flags. */
161 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
162 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
164 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
167 #undef CPP_PREDEFINES
168 #define CPP_PREDEFINES "-D__ELF__ -Dunix -D_LONGLONG -D__sparc__ -Dlinux -Asystem=unix -Asystem=posix"
170 #undef CPP_SUBTARGET_SPEC
171 #define CPP_SUBTARGET_SPEC "\
172 %{fPIC:-D__PIC__ -D__pic__} \
173 %{fpic:-D__PIC__ -D__pic__} \
174 %{posix:-D_POSIX_SOURCE} \
175 %{pthread:-D_REENTRANT} \
181 %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
182 %{profile:-lc_p} %{!profile: -lc}}"
184 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
185 for the special GCC options -static and -shared, which allow us to
186 link things in one of these three modes by applying the appropriate
187 combinations of options at link-time. We like to support here for
188 as many of the other GNU linker options as possible. But I don't
189 have the time to search for those flags. I am sure how to add
190 support for -soname shared_object_name. H.J.
192 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
195 When the -shared link option is used a final link is not being
198 /* If ELF is the default format, we should not use /lib/elf. */
202 #undef SUBTARGET_EXTRA_SPECS
203 #define SUBTARGET_EXTRA_SPECS \
204 { "link_arch32", LINK_ARCH32_SPEC }, \
205 { "link_arch64", LINK_ARCH64_SPEC }, \
206 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
207 { "link_arch", LINK_ARCH_SPEC },
209 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
213 %{rdynamic:-export-dynamic} \
214 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
215 %{static:-static}}} \
218 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
222 %{rdynamic:-export-dynamic} \
223 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
224 %{static:-static}}} \
227 #define LINK_ARCH_SPEC "\
228 %{m32:%(link_arch32)} \
229 %{m64:%(link_arch64)} \
230 %{!m32:%{!m64:%(link_arch_default)}} \
233 #define LINK_ARCH_DEFAULT_SPEC \
234 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
239 %{mlittle-endian:-EL} \
240 %{!mno-relax:%{!r:-relax}} \
246 %{sun4:} %{target:} \
247 %{mcypress:-mcpu=cypress} \
248 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
249 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
250 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
251 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
252 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
253 %{!m64:%{g*:%{!gs*:%{!gd*:%{!gx*:%{!gc*:-gstabs+}}}}}} \
257 %{sun4:} %{target:} \
258 %{mcypress:-mcpu=cypress} \
259 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
260 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
261 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
262 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}} \
263 %{g*:%{!gs*:%{!gd*:%{!gx*:%{!gc*:-gstabs+}}}}}} \
264 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
265 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
270 #define MULTILIB_DEFAULTS { "m32" }
272 #define MULTILIB_DEFAULTS { "m64" }
275 #else /* !SPARC_BI_ARCH */
278 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
282 %{rdynamic:-export-dynamic} \
283 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
284 %{static:-static}}} \
285 %{mlittle-endian:-EL} \
286 %{!mno-relax:%{!r:-relax}} \
289 #endif /* !SPARC_BI_ARCH */
291 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
292 It's safe to pass -s always, even if -g is not used. */
302 -s %{fpic:-K PIC} %{fPIC:-K PIC} \
303 %{mlittle-endian:-EL} \
304 %(asm_cpu) %(asm_arch) %(asm_relax)"
306 /* Same as sparc.h */
307 #undef DBX_REGISTER_NUMBER
308 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
310 /* System V Release 4 uses DWARF debugging info. Buf DWARF1 doesn't do
311 64-bit anything, so we use DWARF2. */
313 #undef DWARF2_DEBUGGING_INFO
314 #undef DWARF_DEBUGGING_INFO
315 #undef DBX_DEBUGGING_INFO
316 #define DWARF2_DEBUGGING_INFO
317 #define DBX_DEBUGGING_INFO
319 #undef PREFERRED_DEBUGGING_TYPE
320 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
322 #undef ASM_OUTPUT_ALIGNED_LOCAL
323 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
325 fputs ("\t.local\t", (FILE)); \
326 assemble_name ((FILE), (NAME)); \
327 putc ('\n', (FILE)); \
328 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
332 #define COMMON_ASM_OP "\t.common\t"
334 /* This is how to output a definition of an internal numbered label where
335 PREFIX is the class of label and NUM is the number within the class. */
337 #undef ASM_OUTPUT_INTERNAL_LABEL
338 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
339 fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
341 /* This is how to output a reference to an internal numbered label where
342 PREFIX is the class of label and NUM is the number within the class. */
344 #undef ASM_OUTPUT_INTERNAL_LABELREF
345 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
346 fprintf (FILE, ".L%s%d", PREFIX, NUM)
348 /* This is how to store into the string LABEL
349 the symbol_ref name of an internal numbered label where
350 PREFIX is the class of label and NUM is the number within the class.
351 This is suitable for output with `assemble_name'. */
353 #undef ASM_GENERATE_INTERNAL_LABEL
354 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
355 sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
357 /* Define the names of various pseudo-ops used by the Sparc/svr4 assembler.
358 ??? If ints are 64 bits then UNALIGNED_INT_ASM_OP (defined elsewhere) is
359 misnamed. These should all refer to explicit sizes (half/word/xword?),
360 anything other than short/int/long/etc. */
362 #define UNALIGNED_DOUBLE_INT_ASM_OP "\t.uaxword\t"
366 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
367 Obviously the Dwarf2 folks havn't tried to actually build systems
368 with their spec. On a 64-bit system, only 64-bit relocs become
369 RELATIVE relocations. */
371 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
374 /* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
375 traps available which can get and set the condition codes
377 #undef MACHINE_STATE_SAVE
378 #define MACHINE_STATE_SAVE(ID) \
379 unsigned long int ms_flags, ms_saveret; \
380 asm volatile("ta 0x20\n\t" \
383 : "=r" (ms_flags), "=r" (ms_saveret));
385 #undef MACHINE_STATE_RESTORE
386 #define MACHINE_STATE_RESTORE(ID) \
387 asm volatile("mov %0, %%g1\n\t" \
391 : "r" (ms_flags), "r" (ms_saveret));
394 /* A C statement (sans semicolon) to output an element in the table of
395 global constructors. */
396 #undef ASM_OUTPUT_CONSTRUCTOR
397 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
401 fprintf (FILE, "\t%s\t ", ASM_LONGLONG); \
403 fprintf (FILE, "%s", INT_ASM_OP); \
404 assemble_name (FILE, NAME); \
405 fprintf (FILE, "\n"); \
408 /* A C statement (sans semicolon) to output an element in the table of
409 global destructors. */
410 #undef ASM_OUTPUT_DESTRUCTOR
411 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
415 fprintf (FILE, "\t%s\t ", ASM_LONGLONG); \
417 fprintf (FILE, "%s", INT_ASM_OP); \
418 assemble_name (FILE, NAME); \
419 fprintf (FILE, "\n"); \