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