2008-01-25 Douglas Gregor <doug.gregor@gmail.com>
[official-gcc.git] / gcc / config / sparc / linux.h
blobbd3b1f5ea7f7ee5dabd5e209937849afb14416c8
1 /* Definitions for SPARC running Linux-based GNU systems with ELF.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
3 2007 Free Software Foundation, Inc.
4 Contributed by Eddie C. Dost (ecd@skynet.be)
6 This file is part of GCC.
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 3, or (at your option)
11 any later version.
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.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #define TARGET_OS_CPP_BUILTINS() \
23 do \
24 { \
25 builtin_define_std ("unix"); \
26 builtin_define_std ("linux"); \
27 builtin_define ("__gnu_linux__"); \
28 builtin_assert ("system=linux"); \
29 builtin_assert ("system=unix"); \
30 builtin_assert ("system=posix"); \
31 if (TARGET_LONG_DOUBLE_128) \
32 builtin_define ("__LONG_DOUBLE_128__"); \
33 } \
34 while (0)
36 /* Don't assume anything about the header files. */
37 #define NO_IMPLICIT_EXTERN_C
39 #undef MD_EXEC_PREFIX
40 #undef MD_STARTFILE_PREFIX
42 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
43 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
44 provides part of the support for getting C++ file-scope static
45 object constructed before entering `main'. */
47 #undef STARTFILE_SPEC
48 #if defined HAVE_LD_PIE
49 #define STARTFILE_SPEC \
50 "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
51 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
52 #else
53 #define STARTFILE_SPEC \
54 "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
55 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
56 #endif
58 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
59 the GNU/Linux magical crtend.o file (see crtstuff.c) which
60 provides part of the support for getting C++ file-scope static
61 object constructed before entering `main', followed by a normal
62 GNU/Linux "finalizer" file, `crtn.o'. */
64 #undef ENDFILE_SPEC
65 #define ENDFILE_SPEC \
66 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
67 %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
69 /* This is for -profile to use -lc_p instead of -lc. */
70 #undef CC1_SPEC
71 #define CC1_SPEC "%{profile:-p} \
72 %{sun4:} %{target:} \
73 %{mcypress:-mcpu=cypress} \
74 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
75 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
78 /* The GNU C++ standard library requires that these macros be defined. */
79 #undef CPLUSPLUS_CPP_SPEC
80 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
82 #undef TARGET_VERSION
83 #define TARGET_VERSION fprintf (stderr, " (sparc GNU/Linux with ELF)");
85 #undef SIZE_TYPE
86 #define SIZE_TYPE "unsigned int"
88 #undef PTRDIFF_TYPE
89 #define PTRDIFF_TYPE "int"
91 #undef WCHAR_TYPE
92 #define WCHAR_TYPE "int"
94 #undef WCHAR_TYPE_SIZE
95 #define WCHAR_TYPE_SIZE 32
97 #undef CPP_SUBTARGET_SPEC
98 #define CPP_SUBTARGET_SPEC \
99 "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
101 #undef LIB_SPEC
102 #define LIB_SPEC \
103 "%{pthread:-lpthread} \
104 %{shared:-lc} \
105 %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
107 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
108 for the special GCC options -static and -shared, which allow us to
109 link things in one of these three modes by applying the appropriate
110 combinations of options at link-time. We like to support here for
111 as many of the other GNU linker options as possible. But I don't
112 have the time to search for those flags. I am sure how to add
113 support for -soname shared_object_name. H.J.
115 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
116 -Wl,-V.
118 When the -shared link option is used a final link is not being
119 done. */
121 /* If ELF is the default format, we should not use /lib/elf. */
123 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
124 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
125 #if UCLIBC_DEFAULT
126 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
127 #else
128 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
129 #endif
130 #define LINUX_DYNAMIC_LINKER \
131 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
134 #undef LINK_SPEC
135 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
136 %{!mno-relax:%{!r:-relax}} \
137 %{!shared: \
138 %{!ibcs: \
139 %{!static: \
140 %{rdynamic:-export-dynamic} \
141 %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER "}} \
142 %{static:-static}}}"
144 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
145 It's safe to pass -s always, even if -g is not used. */
146 #undef ASM_SPEC
147 #define ASM_SPEC \
148 "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
149 %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu) %(asm_relax)"
151 /* Same as sparc.h */
152 #undef DBX_REGISTER_NUMBER
153 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
155 #undef ASM_OUTPUT_ALIGNED_LOCAL
156 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
157 do { \
158 fputs ("\t.local\t", (FILE)); \
159 assemble_name ((FILE), (NAME)); \
160 putc ('\n', (FILE)); \
161 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
162 } while (0)
164 #undef COMMON_ASM_OP
165 #define COMMON_ASM_OP "\t.common\t"
167 #undef LOCAL_LABEL_PREFIX
168 #define LOCAL_LABEL_PREFIX "."
170 /* This is how to store into the string LABEL
171 the symbol_ref name of an internal numbered label where
172 PREFIX is the class of label and NUM is the number within the class.
173 This is suitable for output with `assemble_name'. */
175 #undef ASM_GENERATE_INTERNAL_LABEL
176 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
177 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
180 /* Define for support of TFmode long double.
181 SPARC ABI says that long double is 4 words. */
182 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
184 /* Define this to set long double type size to use in libgcc2.c, which can
185 not depend on target_flags. */
186 #ifdef __LONG_DOUBLE_128__
187 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
188 #else
189 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
190 #endif
192 #undef DITF_CONVERSION_LIBFUNCS
193 #define DITF_CONVERSION_LIBFUNCS 1
195 #if defined(HAVE_LD_EH_FRAME_HDR)
196 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
197 #endif
199 #ifdef HAVE_AS_TLS
200 #undef TARGET_SUN_TLS
201 #undef TARGET_GNU_TLS
202 #define TARGET_SUN_TLS 0
203 #define TARGET_GNU_TLS 1
204 #endif
206 /* Don't be different from other Linux platforms in this regard. */
207 #define HANDLE_PRAGMA_PACK_PUSH_POP
209 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
210 #undef CTORS_SECTION_ASM_OP
211 #undef DTORS_SECTION_ASM_OP
213 /* Determine whether the entire c99 runtime is present in the
214 runtime library. */
215 #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
217 /* Whether we have sincos that follows the GNU extension. */
218 #define TARGET_HAS_SINCOS (OPTION_GLIBC)
220 #define TARGET_POSIX_IO
222 #undef LINK_GCC_C_SEQUENCE_SPEC
223 #define LINK_GCC_C_SEQUENCE_SPEC \
224 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
226 /* Use --as-needed -lgcc_s for eh support. */
227 #ifdef HAVE_LD_AS_NEEDED
228 #define USE_LD_AS_NEEDED 1
229 #endif
231 #define MD_UNWIND_SUPPORT "config/sparc/linux-unwind.h"
233 /* Linux currently uses RMO in uniprocessor mode, which is equivalent to
234 TMO, and TMO in multiprocessor mode. But they reserve the right to
235 change their minds. */
236 #undef SPARC_RELAXED_ORDERING
237 #define SPARC_RELAXED_ORDERING true
239 #undef NEED_INDICATE_EXEC_STACK
240 #define NEED_INDICATE_EXEC_STACK 1
242 #ifdef TARGET_LIBC_PROVIDES_SSP
243 /* sparc glibc provides __stack_chk_guard in [%g7 + 0x14]. */
244 #define TARGET_THREAD_SSP_OFFSET 0x14
245 #endif
247 /* Define if long doubles should be mangled as 'g'. */
248 #define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING