150397Sobrien/* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF. 2169689Skan Copyright 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006 3132718Skan Free Software Foundation, Inc. 450397Sobrien Contributed by David S. Miller (davem@caip.rutgers.edu) 550397Sobrien 6132718SkanThis file is part of GCC. 750397Sobrien 8132718SkanGCC is free software; you can redistribute it and/or modify 950397Sobrienit under the terms of the GNU General Public License as published by 1050397Sobrienthe Free Software Foundation; either version 2, or (at your option) 1150397Sobrienany later version. 1250397Sobrien 13132718SkanGCC is distributed in the hope that it will be useful, 1450397Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 1550397SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1650397SobrienGNU General Public License for more details. 1750397Sobrien 1850397SobrienYou should have received a copy of the GNU General Public License 19132718Skanalong with GCC; see the file COPYING. If not, write to 20169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 21169689SkanBoston, MA 02110-1301, USA. */ 2250397Sobrien 23169689Skan#define TARGET_OS_CPP_BUILTINS() \ 24169689Skan do \ 25169689Skan { \ 26169689Skan builtin_define_std ("unix"); \ 27169689Skan builtin_define_std ("linux"); \ 28169689Skan builtin_define ("_LONGLONG"); \ 29169689Skan builtin_define ("__gnu_linux__"); \ 30169689Skan builtin_assert ("system=linux"); \ 31169689Skan builtin_assert ("system=unix"); \ 32169689Skan builtin_assert ("system=posix"); \ 33169689Skan if (TARGET_ARCH32 && TARGET_LONG_DOUBLE_128) \ 34169689Skan builtin_define ("__LONG_DOUBLE_128__"); \ 35169689Skan } \ 36132718Skan while (0) 3750397Sobrien 3890075Sobrien/* Don't assume anything about the header files. */ 3950397Sobrien#define NO_IMPLICIT_EXTERN_C 4050397Sobrien 4150397Sobrien#undef MD_EXEC_PREFIX 4250397Sobrien#undef MD_STARTFILE_PREFIX 4350397Sobrien 44132718Skan#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \ 45132718Skan || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc \ 46169689Skan || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3 \ 47169689Skan || TARGET_CPU_DEFAULT == TARGET_CPU_niagara 4852284Sobrien/* A 64 bit v9 compiler with stack-bias, 4952284Sobrien in a Medium/Low code model environment. */ 5052284Sobrien 5152284Sobrien#undef TARGET_DEFAULT 5252284Sobrien#define TARGET_DEFAULT \ 5352284Sobrien (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \ 5496263Sobrien + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128) 5552284Sobrien#endif 5652284Sobrien 5750397Sobrien#undef ASM_CPU_DEFAULT_SPEC 5850397Sobrien#define ASM_CPU_DEFAULT_SPEC "-Av9a" 5950397Sobrien 6050397Sobrien/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add 6150397Sobrien the GNU/Linux magical crtbegin.o file (see crtstuff.c) which 6250397Sobrien provides part of the support for getting C++ file-scope static 6390075Sobrien object constructed before entering `main'. */ 6450397Sobrien 6550397Sobrien#undef STARTFILE_SPEC 6652284Sobrien 67132718Skan#ifdef HAVE_LD_PIE 68104752Skan#define STARTFILE_SPEC \ 69132718Skan "%{!shared:%{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\ 70132718Skan crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}" 71132718Skan#else 72132718Skan#define STARTFILE_SPEC \ 73132718Skan "%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\ 74132718Skan crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}" 75132718Skan#endif 7650397Sobrien 7750397Sobrien/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on 7850397Sobrien the GNU/Linux magical crtend.o file (see crtstuff.c) which 7950397Sobrien provides part of the support for getting C++ file-scope static 8050397Sobrien object constructed before entering `main', followed by a normal 8150397Sobrien GNU/Linux "finalizer" file, `crtn.o'. */ 8250397Sobrien 8350397Sobrien#undef ENDFILE_SPEC 8452284Sobrien 85104752Skan#define ENDFILE_SPEC \ 86132718Skan "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\ 87104752Skan %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" 8850397Sobrien 8990075Sobrien/* The GNU C++ standard library requires that these macros be defined. */ 9090075Sobrien#undef CPLUSPLUS_CPP_SPEC 9190075Sobrien#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)" 9290075Sobrien 9350397Sobrien#undef TARGET_VERSION 9450397Sobrien#define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)"); 9550397Sobrien 9650397Sobrien/* The default code model. */ 9750397Sobrien#undef SPARC_DEFAULT_CMODEL 9852284Sobrien#define SPARC_DEFAULT_CMODEL CM_MEDLOW 9950397Sobrien 10050397Sobrien#undef WCHAR_TYPE 10190075Sobrien#define WCHAR_TYPE "int" 10290075Sobrien 10350397Sobrien#undef WCHAR_TYPE_SIZE 10490075Sobrien#define WCHAR_TYPE_SIZE 32 10550397Sobrien 106117395Skan/* Define for support of TFmode long double. 107117395Skan SPARC ABI says that long double is 4 words. */ 10850397Sobrien#undef LONG_DOUBLE_TYPE_SIZE 10990075Sobrien#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64) 11052284Sobrien 11190075Sobrien/* Define this to set long double type size to use in libgcc2.c, which can 11290075Sobrien not depend on target_flags. */ 11390075Sobrien#if defined(__arch64__) || defined(__LONG_DOUBLE_128__) 11490075Sobrien#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128 11590075Sobrien#else 11690075Sobrien#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64 11790075Sobrien#endif 11890075Sobrien 11950397Sobrien#undef CPP_SUBTARGET_SPEC 12050397Sobrien#define CPP_SUBTARGET_SPEC "\ 12150397Sobrien%{posix:-D_POSIX_SOURCE} \ 12250397Sobrien%{pthread:-D_REENTRANT} \ 12350397Sobrien" 12450397Sobrien 12550397Sobrien#undef LIB_SPEC 12650397Sobrien#define LIB_SPEC \ 127117395Skan "%{pthread:-lpthread} \ 128117395Skan %{shared:-lc} \ 129117395Skan %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}" 13050397Sobrien 13150397Sobrien/* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support 13250397Sobrien for the special GCC options -static and -shared, which allow us to 13350397Sobrien link things in one of these three modes by applying the appropriate 13450397Sobrien combinations of options at link-time. We like to support here for 13550397Sobrien as many of the other GNU linker options as possible. But I don't 13650397Sobrien have the time to search for those flags. I am sure how to add 13750397Sobrien support for -soname shared_object_name. H.J. 13850397Sobrien 13950397Sobrien I took out %{v:%{!V:-V}}. It is too much :-(. They can use 14050397Sobrien -Wl,-V. 14150397Sobrien 14250397Sobrien When the -shared link option is used a final link is not being 14350397Sobrien done. */ 14450397Sobrien 14590075Sobrien/* If ELF is the default format, we should not use /lib/elf. */ 14650397Sobrien 147169689Skan#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" 148169689Skan#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2" 149169689Skan#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" 150169689Skan#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" 151169689Skan#if UCLIBC_DEFAULT 152169689Skan#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}" 153169689Skan#else 154169689Skan#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}" 155169689Skan#endif 156169689Skan#define LINUX_DYNAMIC_LINKER32 \ 157169689Skan CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32) 158169689Skan#define LINUX_DYNAMIC_LINKER64 \ 159169689Skan CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64) 160169689Skan 16152284Sobrien#ifdef SPARC_BI_ARCH 16252284Sobrien 16352284Sobrien#undef SUBTARGET_EXTRA_SPECS 16452284Sobrien#define SUBTARGET_EXTRA_SPECS \ 16552284Sobrien { "link_arch32", LINK_ARCH32_SPEC }, \ 16652284Sobrien { "link_arch64", LINK_ARCH64_SPEC }, \ 16752284Sobrien { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \ 16852284Sobrien { "link_arch", LINK_ARCH_SPEC }, 169169689Skan 17052284Sobrien#define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \ 17152284Sobrien %{!shared: \ 17252284Sobrien %{!ibcs: \ 17352284Sobrien %{!static: \ 17452284Sobrien %{rdynamic:-export-dynamic} \ 175169689Skan %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER32 "}} \ 17652284Sobrien %{static:-static}}} \ 17752284Sobrien" 17852284Sobrien 17952284Sobrien#define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \ 18052284Sobrien %{!shared: \ 18152284Sobrien %{!ibcs: \ 18252284Sobrien %{!static: \ 18352284Sobrien %{rdynamic:-export-dynamic} \ 184169689Skan %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}} \ 18552284Sobrien %{static:-static}}} \ 18652284Sobrien" 18752284Sobrien 18852284Sobrien#define LINK_ARCH_SPEC "\ 18952284Sobrien%{m32:%(link_arch32)} \ 19052284Sobrien%{m64:%(link_arch64)} \ 19152284Sobrien%{!m32:%{!m64:%(link_arch_default)}} \ 19252284Sobrien" 19352284Sobrien 19452284Sobrien#define LINK_ARCH_DEFAULT_SPEC \ 19552284Sobrien(DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC) 19652284Sobrien 19750397Sobrien#undef LINK_SPEC 19852284Sobrien#define LINK_SPEC "\ 19952284Sobrien%(link_arch) \ 20052284Sobrien%{mlittle-endian:-EL} \ 20190075Sobrien%{!mno-relax:%{!r:-relax}} \ 20252284Sobrien" 20352284Sobrien 20452284Sobrien#undef CC1_SPEC 20552284Sobrien#if DEFAULT_ARCH32_P 20652284Sobrien#define CC1_SPEC "\ 20752284Sobrien%{sun4:} %{target:} \ 20852284Sobrien%{mcypress:-mcpu=cypress} \ 20952284Sobrien%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \ 21052284Sobrien%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \ 21196263Sobrien%{m32:%{m64:%emay not use both -m32 and -m64}} \ 21290075Sobrien%{m64:-mptr64 -mstack-bias -mlong-double-128 \ 21390075Sobrien %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \ 21490075Sobrien %{!mno-vis:%{!mcpu=v9:-mvis}}} \ 21552284Sobrien" 21652284Sobrien#else 21752284Sobrien#define CC1_SPEC "\ 21852284Sobrien%{sun4:} %{target:} \ 21952284Sobrien%{mcypress:-mcpu=cypress} \ 22052284Sobrien%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \ 22152284Sobrien%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \ 22296263Sobrien%{m32:%{m64:%emay not use both -m32 and -m64}} \ 22390075Sobrien%{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \ 22490075Sobrien %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \ 22590075Sobrien%{!m32:%{!mcpu*:-mcpu=ultrasparc}} \ 22690075Sobrien%{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \ 22752284Sobrien" 22852284Sobrien#endif 22952284Sobrien 230132718Skan/* Support for a compile-time default CPU, et cetera. The rules are: 231132718Skan --with-cpu is ignored if -mcpu is specified. 232132718Skan --with-tune is ignored if -mtune is specified. 233132718Skan --with-float is ignored if -mhard-float, -msoft-float, -mfpu, or -mno-fpu 234132718Skan are specified. 235132718Skan In the SPARC_BI_ARCH compiler we cannot pass %{!mcpu=*:-mcpu=%(VALUE)} 236132718Skan here, otherwise say -mcpu=v7 would be passed even when -m64. 237132718Skan CC1_SPEC above takes care of this instead. */ 238132718Skan#undef OPTION_DEFAULT_SPECS 23952284Sobrien#if DEFAULT_ARCH32_P 240132718Skan#define OPTION_DEFAULT_SPECS \ 241132718Skan {"cpu", "%{!m64:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \ 242132718Skan {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \ 243132718Skan {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" } 244132718Skan#else 245132718Skan#define OPTION_DEFAULT_SPECS \ 246132718Skan {"cpu", "%{!m32:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \ 247132718Skan {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \ 248132718Skan {"float", "%{!msoft-float:%{!mhard-float:%{!fpu:%{!no-fpu:-m%(VALUE)-float}}}}" } 249132718Skan#endif 250132718Skan 251132718Skan#if DEFAULT_ARCH32_P 25252284Sobrien#define MULTILIB_DEFAULTS { "m32" } 25352284Sobrien#else 25452284Sobrien#define MULTILIB_DEFAULTS { "m64" } 25552284Sobrien#endif 25652284Sobrien 25752284Sobrien#else /* !SPARC_BI_ARCH */ 25852284Sobrien 25952284Sobrien#undef LINK_SPEC 26090075Sobrien#define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \ 26150397Sobrien %{!shared: \ 26250397Sobrien %{!ibcs: \ 26350397Sobrien %{!static: \ 26450397Sobrien %{rdynamic:-export-dynamic} \ 265169689Skan %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}} \ 26650397Sobrien %{static:-static}}} \ 26750397Sobrien%{mlittle-endian:-EL} \ 26890075Sobrien%{!mno-relax:%{!r:-relax}} \ 26950397Sobrien" 27050397Sobrien 27152284Sobrien#endif /* !SPARC_BI_ARCH */ 27252284Sobrien 27350397Sobrien/* The sun bundled assembler doesn't accept -Yd, (and neither does gas). 27490075Sobrien It's safe to pass -s always, even if -g is not used. */ 27550397Sobrien#undef ASM_SPEC 27650397Sobrien#define ASM_SPEC "\ 27750397Sobrien%{V} \ 27850397Sobrien%{v:%{!V:-V}} \ 27950397Sobrien%{!Qn:-Qy} \ 28050397Sobrien%{n} \ 28150397Sobrien%{T} \ 28250397Sobrien%{Ym,*} \ 28350397Sobrien%{Wa,*:%*} \ 284132718Skan-s %{fpic|fPIC|fpie|fPIE:-K PIC} \ 28550397Sobrien%{mlittle-endian:-EL} \ 28690075Sobrien%(asm_cpu) %(asm_arch) %(asm_relax)" 28750397Sobrien 28850397Sobrien/* Same as sparc.h */ 28950397Sobrien#undef DBX_REGISTER_NUMBER 29050397Sobrien#define DBX_REGISTER_NUMBER(REGNO) (REGNO) 29150397Sobrien 29250397Sobrien#undef ASM_OUTPUT_ALIGNED_LOCAL 29350397Sobrien#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \ 29450397Sobriendo { \ 29550397Sobrien fputs ("\t.local\t", (FILE)); \ 29650397Sobrien assemble_name ((FILE), (NAME)); \ 29750397Sobrien putc ('\n', (FILE)); \ 29850397Sobrien ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \ 29950397Sobrien} while (0) 30050397Sobrien 30150397Sobrien#undef COMMON_ASM_OP 30290075Sobrien#define COMMON_ASM_OP "\t.common\t" 30350397Sobrien 30496263Sobrien#undef LOCAL_LABEL_PREFIX 30596263Sobrien#define LOCAL_LABEL_PREFIX "." 30696263Sobrien 30750397Sobrien/* This is how to store into the string LABEL 30850397Sobrien the symbol_ref name of an internal numbered label where 30950397Sobrien PREFIX is the class of label and NUM is the number within the class. 31050397Sobrien This is suitable for output with `assemble_name'. */ 31150397Sobrien 31250397Sobrien#undef ASM_GENERATE_INTERNAL_LABEL 31350397Sobrien#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ 31490075Sobrien sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM)) 31550397Sobrien 31650397Sobrien/* DWARF bits. */ 31750397Sobrien 31850397Sobrien/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets. 31990075Sobrien Obviously the Dwarf2 folks haven't tried to actually build systems 32050397Sobrien with their spec. On a 64-bit system, only 64-bit relocs become 32150397Sobrien RELATIVE relocations. */ 32250397Sobrien 32350397Sobrien/* #define DWARF_OFFSET_SIZE PTR_SIZE */ 32490075Sobrien 325132718Skan#undef DITF_CONVERSION_LIBFUNCS 326132718Skan#define DITF_CONVERSION_LIBFUNCS 1 327132718Skan 32890075Sobrien#if defined(HAVE_LD_EH_FRAME_HDR) 32990075Sobrien#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " 33090075Sobrien#endif 33150397Sobrien 332132718Skan#ifdef HAVE_AS_TLS 333132718Skan#undef TARGET_SUN_TLS 334132718Skan#undef TARGET_GNU_TLS 335132718Skan#define TARGET_SUN_TLS 0 336132718Skan#define TARGET_GNU_TLS 1 337132718Skan#endif 338132718Skan 33996263Sobrien/* Don't be different from other Linux platforms in this regard. */ 34096263Sobrien#define HANDLE_PRAGMA_PACK_PUSH_POP 34196263Sobrien 34296263Sobrien/* We use GNU ld so undefine this so that attribute((init_priority)) works. */ 34396263Sobrien#undef CTORS_SECTION_ASM_OP 34496263Sobrien#undef DTORS_SECTION_ASM_OP 34596263Sobrien 346169689Skan/* Determine whether the entire c99 runtime is present in the 347132718Skan runtime library. */ 348169689Skan#define TARGET_C99_FUNCTIONS (OPTION_GLIBC) 349132718Skan 350169689Skan#define TARGET_POSIX_IO 351132718Skan 352122180Skan#undef LINK_GCC_C_SEQUENCE_SPEC 353122180Skan#define LINK_GCC_C_SEQUENCE_SPEC \ 354122180Skan "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}" 355122180Skan 356169689Skan/* Use --as-needed -lgcc_s for eh support. */ 357169689Skan#ifdef HAVE_LD_AS_NEEDED 358169689Skan#define USE_LD_AS_NEEDED 1 359169689Skan#endif 36096263Sobrien 361169689Skan#define MD_UNWIND_SUPPORT "config/sparc/linux-unwind.h" 362169689Skan 363169689Skan/* Linux currently uses RMO in uniprocessor mode, which is equivalent to 364169689Skan TMO, and TMO in multiprocessor mode. But they reserve the right to 365169689Skan change their minds. */ 366169689Skan#undef SPARC_RELAXED_ORDERING 367169689Skan#define SPARC_RELAXED_ORDERING true 368169689Skan 369169689Skan#undef NEED_INDICATE_EXEC_STACK 370169689Skan#define NEED_INDICATE_EXEC_STACK 1 371169689Skan 372169689Skan#ifdef TARGET_LIBC_PROVIDES_SSP 373169689Skan/* sparc glibc provides __stack_chk_guard in [%g7 + 0x14], 374169689Skan sparc64 glibc provides it at [%g7 + 0x28]. */ 375169689Skan#define TARGET_THREAD_SSP_OFFSET (TARGET_ARCH64 ? 0x28 : 0x14) 37696263Sobrien#endif 377169689Skan 378169689Skan/* Define if long doubles should be mangled as 'g'. */ 379169689Skan#define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING 380