]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/sparc/linux.h
linux.h (LINK_GCC_C_SEQUENCE_SPEC): Define.
[thirdparty/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
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=unix"); \
30 builtin_assert ("system=posix"); \
31 } \
32 while (0)
33
34 /* Don't assume anything about the header files. */
35 #define NO_IMPLICIT_EXTERN_C
36
37 #undef MD_EXEC_PREFIX
38 #undef MD_STARTFILE_PREFIX
39
40 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
41 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
42 provides part of the support for getting C++ file-scope static
43 object constructed before entering `main'. */
44
45 #undef STARTFILE_SPEC
46 #ifdef USE_GNULIBC_1
47 #define STARTFILE_SPEC \
48 "%{!shared: \
49 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
50 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
51 #elif defined HAVE_LD_PIE
52 #define STARTFILE_SPEC \
53 "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
54 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
55 #else
56 #define STARTFILE_SPEC \
57 "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
58 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
59 #endif
60
61 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
62 the GNU/Linux magical crtend.o file (see crtstuff.c) which
63 provides part of the support for getting C++ file-scope static
64 object constructed before entering `main', followed by a normal
65 GNU/Linux "finalizer" file, `crtn.o'. */
66
67 #undef ENDFILE_SPEC
68 #define ENDFILE_SPEC \
69 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
70 %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
71
72 /* This is for -profile to use -lc_p instead of -lc. */
73 #undef CC1_SPEC
74 #define CC1_SPEC "%{profile:-p} \
75 %{sun4:} %{target:} \
76 %{mcypress:-mcpu=cypress} \
77 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
78 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
79 "
80
81 /* The GNU C++ standard library requires that these macros be defined. */
82 #undef CPLUSPLUS_CPP_SPEC
83 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
84
85 #undef TARGET_VERSION
86 #define TARGET_VERSION fprintf (stderr, " (sparc GNU/Linux with ELF)");
87
88 #undef SUBTARGET_SWITCHES
89 #define SUBTARGET_SWITCHES \
90 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
91 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
92
93 #undef SIZE_TYPE
94 #define SIZE_TYPE "unsigned int"
95
96 #undef PTRDIFF_TYPE
97 #define PTRDIFF_TYPE "int"
98
99 #undef WCHAR_TYPE
100 #define WCHAR_TYPE "int"
101
102 #undef WCHAR_TYPE_SIZE
103 #define WCHAR_TYPE_SIZE 32
104
105 #undef CPP_SUBTARGET_SPEC
106 #ifdef USE_GNULIBC_1
107 #define CPP_SUBTARGET_SPEC \
108 "%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
109 %{mlong-double-128:-D__LONG_DOUBLE_128__}"
110 #else
111 #define CPP_SUBTARGET_SPEC \
112 "%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
113 %{pthread:-D_REENTRANT} %{mlong-double-128:-D__LONG_DOUBLE_128__}"
114 #endif
115
116 #undef LIB_SPEC
117 /* We no longer link with libc_p.a or libg.a by default. If you
118 want to profile or debug the GNU/Linux C library, please add
119 -lc_p or -ggdb to LDFLAGS at the link time, respectively. */
120 #if 1
121 #ifdef USE_GNULIBC_1
122 #define LIB_SPEC \
123 "%{!shared: %{p:-lgmon} %{pg:-lgmon} %{profile:-lgmon -lc_p} \
124 %{!profile:%{!ggdb:-lc} %{ggdb:-lg}}}"
125 #else
126 #define LIB_SPEC \
127 "%{pthread:-lpthread} \
128 %{shared:-lc} \
129 %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
130 #endif
131 #else
132 #define LIB_SPEC \
133 "%{!shared: \
134 %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
135 %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
136 #endif
137
138 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
139 for the special GCC options -static and -shared, which allow us to
140 link things in one of these three modes by applying the appropriate
141 combinations of options at link-time. We like to support here for
142 as many of the other GNU linker options as possible. But I don't
143 have the time to search for those flags. I am sure how to add
144 support for -soname shared_object_name. H.J.
145
146 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
147 -Wl,-V.
148
149 When the -shared link option is used a final link is not being
150 done. */
151
152 /* If ELF is the default format, we should not use /lib/elf. */
153
154 #undef LINK_SPEC
155 #ifdef USE_GNULIBC_1
156 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
157 %{!shared: \
158 %{!ibcs: \
159 %{!static: \
160 %{rdynamic:-export-dynamic} \
161 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
162 %{static:-static}}}"
163 #else
164 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
165 %{!mno-relax:%{!r:-relax}} \
166 %{!shared: \
167 %{!ibcs: \
168 %{!static: \
169 %{rdynamic:-export-dynamic} \
170 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
171 %{static:-static}}}"
172 #endif
173
174 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
175 It's safe to pass -s always, even if -g is not used. */
176 #undef ASM_SPEC
177 #define ASM_SPEC \
178 "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
179 %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu) %(asm_relax)"
180
181 /* Same as sparc.h */
182 #undef DBX_REGISTER_NUMBER
183 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
184
185 #undef ASM_OUTPUT_ALIGNED_LOCAL
186 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
187 do { \
188 fputs ("\t.local\t", (FILE)); \
189 assemble_name ((FILE), (NAME)); \
190 putc ('\n', (FILE)); \
191 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
192 } while (0)
193
194 #undef COMMON_ASM_OP
195 #define COMMON_ASM_OP "\t.common\t"
196
197 #undef LOCAL_LABEL_PREFIX
198 #define LOCAL_LABEL_PREFIX "."
199
200 /* This is how to output a reference to an internal numbered label where
201 PREFIX is the class of label and NUM is the number within the class. */
202
203 #undef ASM_OUTPUT_INTERNAL_LABELREF
204 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
205 fprintf (FILE, ".L%s%d", PREFIX, NUM)
206
207 /* This is how to store into the string LABEL
208 the symbol_ref name of an internal numbered label where
209 PREFIX is the class of label and NUM is the number within the class.
210 This is suitable for output with `assemble_name'. */
211
212 #undef ASM_GENERATE_INTERNAL_LABEL
213 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
214 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
215
216 \f
217 /* Define for support of TFmode long double.
218 SPARC ABI says that long double is 4 words. */
219 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
220
221 /* Constant which presents upper bound of the above value. */
222 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
223
224 /* Define this to set long double type size to use in libgcc2.c, which can
225 not depend on target_flags. */
226 #ifdef __LONG_DOUBLE_128__
227 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
228 #else
229 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
230 #endif
231
232 #if !defined(USE_GNULIBC_1) && defined(HAVE_LD_EH_FRAME_HDR)
233 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
234 #endif
235 \f
236 #ifdef HAVE_AS_TLS
237 #undef TARGET_SUN_TLS
238 #undef TARGET_GNU_TLS
239 #define TARGET_SUN_TLS 0
240 #define TARGET_GNU_TLS 1
241 #endif
242 \f
243 /* Don't be different from other Linux platforms in this regard. */
244 #define HANDLE_PRAGMA_PACK_PUSH_POP
245
246 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
247 #undef CTORS_SECTION_ASM_OP
248 #undef DTORS_SECTION_ASM_OP
249
250 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
251
252 #define LINK_GCC_C_SEQUENCE_SPEC \
253 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
254
255 /* Do code reading to identify a signal frame, and set the frame
256 state data appropriately. See unwind-dw2.c for the structs. */
257
258 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
259 do { \
260 unsigned int *pc_ = (CONTEXT)->ra; \
261 int new_cfa_, i_, oldstyle_; \
262 int regs_off_, fpu_save_off_; \
263 int fpu_save_, this_cfa_; \
264 \
265 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
266 break; \
267 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
268 oldstyle_ = 1; \
269 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
270 oldstyle_ = 0; \
271 else \
272 break; \
273 if (oldstyle_) \
274 { \
275 regs_off_ = 96; \
276 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
277 } \
278 else \
279 { \
280 regs_off_ = 96 + 128; \
281 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
282 } \
283 this_cfa_ = (int) (CONTEXT)->cfa; \
284 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
285 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
286 (FS)->cfa_how = CFA_REG_OFFSET; \
287 (FS)->cfa_reg = 14; \
288 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
289 for (i_ = 1; i_ < 16; ++i_) \
290 { \
291 if (i_ == 14) \
292 continue; \
293 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
294 (FS)->regs.reg[i_].loc.offset = \
295 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
296 } \
297 for (i_ = 0; i_ < 16; ++i_) \
298 { \
299 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
300 (FS)->regs.reg[i_ + 16].loc.offset = \
301 this_cfa_ + (i_ * 4) - new_cfa_; \
302 } \
303 if (fpu_save_) \
304 { \
305 for (i_ = 0; i_ < 32; ++i_) \
306 { \
307 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
308 (FS)->regs.reg[i_ + 32].loc.offset = \
309 (fpu_save_ + (i_ * 4)) - new_cfa_; \
310 } \
311 } \
312 /* Stick return address into %g0, same trick Alpha uses. */ \
313 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
314 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
315 (FS)->retaddr_column = 0; \
316 goto SUCCESS; \
317 } while (0)