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