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