]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/sparc/linux64.h
Merge basic-improvements-branch to trunk
[thirdparty/gcc.git] / gcc / config / sparc / linux64.h
1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2 Copyright 1996, 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
3 Contributed by David S. Miller (davem@caip.rutgers.edu)
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #define LINUX_DEFAULT_ELF
23
24 /* Don't assume anything about the header files. */
25 #define NO_IMPLICIT_EXTERN_C
26
27 #undef MD_EXEC_PREFIX
28 #undef MD_STARTFILE_PREFIX
29
30 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
31 /* A 64 bit v9 compiler with stack-bias,
32 in a Medium/Low code model environment. */
33
34 #undef TARGET_DEFAULT
35 #define TARGET_DEFAULT \
36 (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
37 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
38 #endif
39
40 #undef ASM_CPU_DEFAULT_SPEC
41 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
42
43 #ifdef SPARC_BI_ARCH
44
45 #undef CPP_ARCH32_SPEC
46 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__} \
47 -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc"
48
49 #endif
50
51 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
52 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
53 provides part of the support for getting C++ file-scope static
54 object constructed before entering `main'. */
55
56 #undef STARTFILE_SPEC
57
58 #define STARTFILE_SPEC \
59 "%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
60 crti.o%s %{static:crtbeginT.o%s}\
61 %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
62
63 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
64 the GNU/Linux magical crtend.o file (see crtstuff.c) which
65 provides part of the support for getting C++ file-scope static
66 object constructed before entering `main', followed by a normal
67 GNU/Linux "finalizer" file, `crtn.o'. */
68
69 #undef ENDFILE_SPEC
70
71 #define ENDFILE_SPEC \
72 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s\
73 %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
74
75 /* The GNU C++ standard library requires that these macros be defined. */
76 #undef CPLUSPLUS_CPP_SPEC
77 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
78
79 #undef TARGET_VERSION
80 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
81
82 /* The default code model. */
83 #undef SPARC_DEFAULT_CMODEL
84 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
85
86 #undef SUBTARGET_SWITCHES
87 #define SUBTARGET_SWITCHES \
88 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
89 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
90
91 #undef WCHAR_TYPE
92 #define WCHAR_TYPE "int"
93
94 #undef WCHAR_TYPE_SIZE
95 #define WCHAR_TYPE_SIZE 32
96
97 /* Define for support of TFmode long double.
98 SPARC ABI says that long double is 4 words. */
99 #undef LONG_DOUBLE_TYPE_SIZE
100 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
101
102 /* Constant which presents upper bound of the above value. */
103 #undef MAX_LONG_DOUBLE_TYPE_SIZE
104 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
105
106 /* Define this to set long double type size to use in libgcc2.c, which can
107 not depend on target_flags. */
108 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
109 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
110 #else
111 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
112 #endif
113
114 #undef CPP_PREDEFINES
115 #define CPP_PREDEFINES "-D__ELF__ -Dunix -D_LONGLONG -D__sparc__ -D__gnu_linux__ -Dlinux -Asystem=unix -Asystem=posix"
116
117 #undef CPP_SUBTARGET_SPEC
118 #define CPP_SUBTARGET_SPEC "\
119 %{fPIC:-D__PIC__ -D__pic__} \
120 %{fpic:-D__PIC__ -D__pic__} \
121 %{posix:-D_POSIX_SOURCE} \
122 %{pthread:-D_REENTRANT} \
123 "
124
125 #undef LIB_SPEC
126 #define LIB_SPEC \
127 "%{pthread:-lpthread} \
128 %{shared:-lc} \
129 %{!shared: %{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
130
131 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
132 for the special GCC options -static and -shared, which allow us to
133 link things in one of these three modes by applying the appropriate
134 combinations of options at link-time. We like to support here for
135 as many of the other GNU linker options as possible. But I don't
136 have the time to search for those flags. I am sure how to add
137 support for -soname shared_object_name. H.J.
138
139 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
140 -Wl,-V.
141
142 When the -shared link option is used a final link is not being
143 done. */
144
145 /* If ELF is the default format, we should not use /lib/elf. */
146
147 #ifdef SPARC_BI_ARCH
148
149 #undef SUBTARGET_EXTRA_SPECS
150 #define SUBTARGET_EXTRA_SPECS \
151 { "link_arch32", LINK_ARCH32_SPEC }, \
152 { "link_arch64", LINK_ARCH64_SPEC }, \
153 { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
154 { "link_arch", LINK_ARCH_SPEC },
155
156 #define LINK_ARCH32_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.2}} \
162 %{static:-static}}} \
163 "
164
165 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
166 %{!shared: \
167 %{!ibcs: \
168 %{!static: \
169 %{rdynamic:-export-dynamic} \
170 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
171 %{static:-static}}} \
172 "
173
174 #define LINK_ARCH_SPEC "\
175 %{m32:%(link_arch32)} \
176 %{m64:%(link_arch64)} \
177 %{!m32:%{!m64:%(link_arch_default)}} \
178 "
179
180 #define LINK_ARCH_DEFAULT_SPEC \
181 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
182
183 #undef LINK_SPEC
184 #define LINK_SPEC "\
185 %(link_arch) \
186 %{mlittle-endian:-EL} \
187 %{!mno-relax:%{!r:-relax}} \
188 "
189
190 #undef CC1_SPEC
191 #if DEFAULT_ARCH32_P
192 #define CC1_SPEC "\
193 %{sun4:} %{target:} \
194 %{mcypress:-mcpu=cypress} \
195 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
196 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
197 %{m32:%{m64:%emay not use both -m32 and -m64}} \
198 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
199 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
200 %{!mno-vis:%{!mcpu=v9:-mvis}}} \
201 "
202 #else
203 #define CC1_SPEC "\
204 %{sun4:} %{target:} \
205 %{mcypress:-mcpu=cypress} \
206 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
207 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
208 %{m32:%{m64:%emay not use both -m32 and -m64}} \
209 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
210 %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}}} \
211 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
212 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
213 "
214 #endif
215
216 #if DEFAULT_ARCH32_P
217 #define MULTILIB_DEFAULTS { "m32" }
218 #else
219 #define MULTILIB_DEFAULTS { "m64" }
220 #endif
221
222 #else /* !SPARC_BI_ARCH */
223
224 #undef LINK_SPEC
225 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
226 %{!shared: \
227 %{!ibcs: \
228 %{!static: \
229 %{rdynamic:-export-dynamic} \
230 %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
231 %{static:-static}}} \
232 %{mlittle-endian:-EL} \
233 %{!mno-relax:%{!r:-relax}} \
234 "
235
236 #endif /* !SPARC_BI_ARCH */
237
238 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
239 It's safe to pass -s always, even if -g is not used. */
240 #undef ASM_SPEC
241 #define ASM_SPEC "\
242 %{V} \
243 %{v:%{!V:-V}} \
244 %{!Qn:-Qy} \
245 %{n} \
246 %{T} \
247 %{Ym,*} \
248 %{Wa,*:%*} \
249 -s %{fpic:-K PIC} %{fPIC:-K PIC} \
250 %{mlittle-endian:-EL} \
251 %(asm_cpu) %(asm_arch) %(asm_relax)"
252
253 /* Same as sparc.h */
254 #undef DBX_REGISTER_NUMBER
255 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
256
257 /* System V Release 4 uses DWARF debugging info. Buf DWARF1 doesn't do
258 64-bit anything, so we use DWARF2. */
259
260 #undef DWARF_DEBUGGING_INFO
261 #define DWARF2_DEBUGGING_INFO 1
262 #define DBX_DEBUGGING_INFO 1
263
264 #undef ASM_OUTPUT_ALIGNED_LOCAL
265 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
266 do { \
267 fputs ("\t.local\t", (FILE)); \
268 assemble_name ((FILE), (NAME)); \
269 putc ('\n', (FILE)); \
270 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
271 } while (0)
272
273 #undef COMMON_ASM_OP
274 #define COMMON_ASM_OP "\t.common\t"
275
276 #undef LOCAL_LABEL_PREFIX
277 #define LOCAL_LABEL_PREFIX "."
278
279 /* This is how to output a reference to an internal numbered label where
280 PREFIX is the class of label and NUM is the number within the class. */
281
282 #undef ASM_OUTPUT_INTERNAL_LABELREF
283 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
284 fprintf (FILE, ".L%s%d", PREFIX, NUM)
285
286 /* This is how to store into the string LABEL
287 the symbol_ref name of an internal numbered label where
288 PREFIX is the class of label and NUM is the number within the class.
289 This is suitable for output with `assemble_name'. */
290
291 #undef ASM_GENERATE_INTERNAL_LABEL
292 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
293 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
294
295 /* DWARF bits. */
296
297 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
298 Obviously the Dwarf2 folks haven't tried to actually build systems
299 with their spec. On a 64-bit system, only 64-bit relocs become
300 RELATIVE relocations. */
301
302 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
303
304 #if defined(HAVE_LD_EH_FRAME_HDR)
305 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
306 #endif
307 \f
308 /* Don't be different from other Linux platforms in this regard. */
309 #define HANDLE_PRAGMA_PACK_PUSH_POP
310
311 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
312 #undef CTORS_SECTION_ASM_OP
313 #undef DTORS_SECTION_ASM_OP
314
315 /* Do code reading to identify a signal frame, and set the frame
316 state data appropriately. See unwind-dw2.c for the structs. */
317
318 /* Handle multilib correctly. */
319 #if defined(__arch64__)
320 /* 64-bit SPARC version */
321 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
322 do { \
323 unsigned int *pc_ = (CONTEXT)->ra; \
324 long new_cfa_, i_; \
325 long regs_off_, fpu_save_off_; \
326 long this_cfa_, fpu_save_; \
327 \
328 if (pc_[0] != 0x82102065 /* mov NR_rt_sigreturn, %g1 */ \
329 || pc_[1] != 0x91d0206d) /* ta 0x6d */ \
330 break; \
331 regs_off_ = 192 + 128; \
332 fpu_save_off_ = regs_off_ + (16 * 8) + (3 * 8) + (2 * 4); \
333 this_cfa_ = (long) (CONTEXT)->cfa; \
334 new_cfa_ = *(long *)(((CONTEXT)->cfa) + (regs_off_ + (14 * 8))); \
335 new_cfa_ += 2047; /* Stack bias */ \
336 fpu_save_ = *(long *)((this_cfa_) + (fpu_save_off_)); \
337 (FS)->cfa_how = CFA_REG_OFFSET; \
338 (FS)->cfa_reg = 14; \
339 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
340 for (i_ = 1; i_ < 16; ++i_) \
341 { \
342 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
343 (FS)->regs.reg[i_].loc.offset = \
344 this_cfa_ + (regs_off_ + (i_ * 8)) - new_cfa_; \
345 } \
346 for (i_ = 0; i_ < 16; ++i_) \
347 { \
348 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
349 (FS)->regs.reg[i_ + 16].loc.offset = \
350 this_cfa_ + (i_ * 8) - new_cfa_; \
351 } \
352 if (fpu_save_) \
353 { \
354 for (i_ = 0; i_ < 64; ++i_) \
355 { \
356 if (i_ > 32 && (i_ & 0x1)) \
357 continue; \
358 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
359 (FS)->regs.reg[i_ + 32].loc.offset = \
360 (fpu_save_ + (i_ * 4)) - new_cfa_; \
361 } \
362 } \
363 /* Stick return address into %g0, same trick Alpha uses. */ \
364 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
365 (FS)->regs.reg[0].loc.offset = \
366 this_cfa_ + (regs_off_ + (16 * 8) + 8) - new_cfa_; \
367 (FS)->retaddr_column = 0; \
368 goto SUCCESS; \
369 } while (0)
370 #else
371 /* 32-bit SPARC version */
372 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
373 do { \
374 unsigned int *pc_ = (CONTEXT)->ra; \
375 int new_cfa_, i_, oldstyle_; \
376 int regs_off_, fpu_save_off_; \
377 int fpu_save_, this_cfa_; \
378 \
379 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
380 break; \
381 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
382 oldstyle_ = 1; \
383 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
384 oldstyle_ = 0; \
385 else \
386 break; \
387 if (oldstyle_) \
388 { \
389 regs_off_ = 96; \
390 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
391 } \
392 else \
393 { \
394 regs_off_ = 96 + 128; \
395 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
396 } \
397 this_cfa_ = (int) (CONTEXT)->cfa; \
398 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
399 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
400 (FS)->cfa_how = CFA_REG_OFFSET; \
401 (FS)->cfa_reg = 14; \
402 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
403 for (i_ = 1; i_ < 16; ++i_) \
404 { \
405 if (i_ == 14) \
406 continue; \
407 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
408 (FS)->regs.reg[i_].loc.offset = \
409 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
410 } \
411 for (i_ = 0; i_ < 16; ++i_) \
412 { \
413 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
414 (FS)->regs.reg[i_ + 16].loc.offset = \
415 this_cfa_ + (i_ * 4) - new_cfa_; \
416 } \
417 if (fpu_save_) \
418 { \
419 for (i_ = 0; i_ < 32; ++i_) \
420 { \
421 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
422 (FS)->regs.reg[i_ + 32].loc.offset = \
423 (fpu_save_ + (i_ * 4)) - new_cfa_; \
424 } \
425 } \
426 /* Stick return address into %g0, same trick Alpha uses. */ \
427 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
428 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
429 (FS)->retaddr_column = 0; \
430 goto SUCCESS; \
431 } while (0)
432 #endif