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)
6 This file is part of GCC.
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)
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.
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. */
23 #define TARGET_OS_CPP_BUILTINS() \
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"); \
35 /* Don't assume anything about the header files. */
36 #define NO_IMPLICIT_EXTERN_C
39 #undef MD_STARTFILE_PREFIX
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'. */
48 #define STARTFILE_SPEC \
50 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
51 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
52 #elif defined HAVE_LD_PIE
53 #define STARTFILE_SPEC \
54 "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
55 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
57 #define STARTFILE_SPEC \
58 "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
59 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
62 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
63 the GNU/Linux magical crtend.o file (see crtstuff.c) which
64 provides part of the support for getting C++ file-scope static
65 object constructed before entering `main', followed by a normal
66 GNU/Linux "finalizer" file, `crtn.o'. */
69 #define ENDFILE_SPEC \
70 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
71 %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
73 /* This is for -profile to use -lc_p instead of -lc. */
75 #define CC1_SPEC "%{profile:-p} \
77 %{mcypress:-mcpu=cypress} \
78 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
79 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
82 /* The GNU C++ standard library requires that these macros be defined. */
83 #undef CPLUSPLUS_CPP_SPEC
84 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
87 #define TARGET_VERSION fprintf (stderr, " (sparc GNU/Linux with ELF)");
89 #undef SUBTARGET_SWITCHES
90 #define SUBTARGET_SWITCHES \
91 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
92 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
95 #define SIZE_TYPE "unsigned int"
98 #define PTRDIFF_TYPE "int"
101 #define WCHAR_TYPE "int"
103 #undef WCHAR_TYPE_SIZE
104 #define WCHAR_TYPE_SIZE 32
106 #undef CPP_SUBTARGET_SPEC
108 #define CPP_SUBTARGET_SPEC \
109 "%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
110 %{mlong-double-128:-D__LONG_DOUBLE_128__}"
112 #define CPP_SUBTARGET_SPEC \
113 "%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
114 %{pthread:-D_REENTRANT} %{mlong-double-128:-D__LONG_DOUBLE_128__}"
118 /* We no longer link with libc_p.a or libg.a by default. If you
119 want to profile or debug the GNU/Linux C library, please add
120 -lc_p or -ggdb to LDFLAGS at the link time, respectively. */
124 "%{!shared: %{p:-lgmon} %{pg:-lgmon} %{profile:-lgmon -lc_p} \
125 %{!profile:%{!ggdb:-lc} %{ggdb:-lg}}}"
128 "%{pthread:-lpthread} \
130 %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
135 %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
136 %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
139 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
140 for the special GCC options -static and -shared, which allow us to
141 link things in one of these three modes by applying the appropriate
142 combinations of options at link-time. We like to support here for
143 as many of the other GNU linker options as possible. But I don't
144 have the time to search for those flags. I am sure how to add
145 support for -soname shared_object_name. H.J.
147 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
150 When the -shared link option is used a final link is not being
153 /* If ELF is the default format, we should not use /lib/elf. */
157 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
161 %{rdynamic:-export-dynamic} \
162 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
165 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
166 %{!mno-relax:%{!r:-relax}} \
170 %{rdynamic:-export-dynamic} \
171 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
175 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
176 It's safe to pass -s always, even if -g is not used. */
179 "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
180 %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu) %(asm_relax)"
182 /* Same as sparc.h */
183 #undef DBX_REGISTER_NUMBER
184 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
186 #undef ASM_OUTPUT_ALIGNED_LOCAL
187 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
189 fputs ("\t.local\t", (FILE)); \
190 assemble_name ((FILE), (NAME)); \
191 putc ('\n', (FILE)); \
192 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
196 #define COMMON_ASM_OP "\t.common\t"
198 #undef LOCAL_LABEL_PREFIX
199 #define LOCAL_LABEL_PREFIX "."
201 /* This is how to output a reference to an internal numbered label where
202 PREFIX is the class of label and NUM is the number within the class. */
204 #undef ASM_OUTPUT_INTERNAL_LABELREF
205 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
206 fprintf (FILE, ".L%s%d", PREFIX, NUM)
208 /* This is how to store into the string LABEL
209 the symbol_ref name of an internal numbered label where
210 PREFIX is the class of label and NUM is the number within the class.
211 This is suitable for output with `assemble_name'. */
213 #undef ASM_GENERATE_INTERNAL_LABEL
214 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
215 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
218 /* Define for support of TFmode long double.
219 SPARC ABI says that long double is 4 words. */
220 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
222 /* Constant which presents upper bound of the above value. */
223 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
225 /* Define this to set long double type size to use in libgcc2.c, which can
226 not depend on target_flags. */
227 #ifdef __LONG_DOUBLE_128__
228 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
230 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
233 #undef DITF_CONVERSION_LIBFUNCS
234 #define DITF_CONVERSION_LIBFUNCS 1
236 #if !defined(USE_GNULIBC_1) && defined(HAVE_LD_EH_FRAME_HDR)
237 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
241 #undef TARGET_SUN_TLS
242 #undef TARGET_GNU_TLS
243 #define TARGET_SUN_TLS 0
244 #define TARGET_GNU_TLS 1
247 /* Don't be different from other Linux platforms in this regard. */
248 #define HANDLE_PRAGMA_PACK_PUSH_POP
250 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
251 #undef CTORS_SECTION_ASM_OP
252 #undef DTORS_SECTION_ASM_OP
254 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
256 /* Determine whether the the entire c99 runtime is present in the
258 #define TARGET_C99_FUNCTIONS 1
260 #define TARGET_HAS_F_SETLKW
262 #undef LINK_GCC_C_SEQUENCE_SPEC
263 #define LINK_GCC_C_SEQUENCE_SPEC \
264 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
266 /* Do code reading to identify a signal frame, and set the frame
267 state data appropriately. See unwind-dw2.c for the structs. */
269 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
271 unsigned int *pc_ = (CONTEXT)->ra; \
272 int new_cfa_, i_, oldstyle_; \
273 int regs_off_, fpu_save_off_; \
274 int fpu_save_, this_cfa_; \
276 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
278 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
280 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
287 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
291 regs_off_ = 96 + 128; \
292 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
294 this_cfa_ = (int) (CONTEXT)->cfa; \
295 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
296 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
297 (FS)->cfa_how = CFA_REG_OFFSET; \
298 (FS)->cfa_reg = 14; \
299 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
300 for (i_ = 1; i_ < 16; ++i_) \
304 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
305 (FS)->regs.reg[i_].loc.offset = \
306 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
308 for (i_ = 0; i_ < 16; ++i_) \
310 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
311 (FS)->regs.reg[i_ + 16].loc.offset = \
312 this_cfa_ + (i_ * 4) - new_cfa_; \
316 for (i_ = 0; i_ < 32; ++i_) \
318 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
319 (FS)->regs.reg[i_ + 32].loc.offset = \
320 (fpu_save_ + (i_ * 4)) - new_cfa_; \
323 /* Stick return address into %g0, same trick Alpha uses. */ \
324 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
325 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
326 (FS)->retaddr_column = 0; \