1 /* Definitions for SPARC running Linux-based GNU systems with ELF.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
3 Contributed by Eddie C. Dost (ecd@skynet.be)
5 This file is part of GCC.
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)
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.
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. */
22 #define TARGET_OS_CPP_BUILTINS() \
25 builtin_define_std ("unix"); \
26 builtin_define_std ("linux"); \
27 builtin_define ("__gnu_linux__"); \
28 builtin_assert ("system=unix"); \
29 builtin_assert ("system=posix"); \
33 /* Don't assume anything about the header files. */
34 #define NO_IMPLICIT_EXTERN_C
37 #undef MD_STARTFILE_PREFIX
39 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
40 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
41 provides part of the support for getting C++ file-scope static
42 object constructed before entering `main'. */
46 #define STARTFILE_SPEC \
48 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
49 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
50 #elif defined HAVE_LD_PIE
51 #define STARTFILE_SPEC \
52 "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
53 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
55 #define STARTFILE_SPEC \
56 "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
57 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
60 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
61 the GNU/Linux magical crtend.o file (see crtstuff.c) which
62 provides part of the support for getting C++ file-scope static
63 object constructed before entering `main', followed by a normal
64 GNU/Linux "finalizer" file, `crtn.o'. */
67 #define ENDFILE_SPEC \
68 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
69 %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
71 /* This is for -profile to use -lc_p instead of -lc. */
73 #define CC1_SPEC "%{profile:-p} \
75 %{mcypress:-mcpu=cypress} \
76 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
77 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
80 /* The GNU C++ standard library requires that these macros be defined. */
81 #undef CPLUSPLUS_CPP_SPEC
82 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
85 #define TARGET_VERSION fprintf (stderr, " (sparc GNU/Linux with ELF)");
87 #undef SUBTARGET_SWITCHES
88 #define SUBTARGET_SWITCHES \
89 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
90 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
93 #define SIZE_TYPE "unsigned int"
96 #define PTRDIFF_TYPE "int"
99 #define WCHAR_TYPE "int"
101 #undef WCHAR_TYPE_SIZE
102 #define WCHAR_TYPE_SIZE 32
104 #undef CPP_SUBTARGET_SPEC
106 #define CPP_SUBTARGET_SPEC \
107 "%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
108 %{mlong-double-128:-D__LONG_DOUBLE_128__}"
110 #define CPP_SUBTARGET_SPEC \
111 "%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
112 %{pthread:-D_REENTRANT} %{mlong-double-128:-D__LONG_DOUBLE_128__}"
116 /* We no longer link with libc_p.a or libg.a by default. If you
117 want to profile or debug the GNU/Linux C library, please add
118 -lc_p or -ggdb to LDFLAGS at the link time, respectively. */
122 "%{!shared: %{p:-lgmon} %{pg:-lgmon} %{profile:-lgmon -lc_p} \
123 %{!profile:%{!ggdb:-lc} %{ggdb:-lg}}}"
126 "%{pthread:-lpthread} \
128 %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
133 %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
134 %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
137 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
138 for the special GCC options -static and -shared, which allow us to
139 link things in one of these three modes by applying the appropriate
140 combinations of options at link-time. We like to support here for
141 as many of the other GNU linker options as possible. But I don't
142 have the time to search for those flags. I am sure how to add
143 support for -soname shared_object_name. H.J.
145 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
148 When the -shared link option is used a final link is not being
151 /* If ELF is the default format, we should not use /lib/elf. */
155 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
159 %{rdynamic:-export-dynamic} \
160 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
163 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
164 %{!mno-relax:%{!r:-relax}} \
168 %{rdynamic:-export-dynamic} \
169 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
173 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
174 It's safe to pass -s always, even if -g is not used. */
177 "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
178 %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu) %(asm_relax)"
180 /* Same as sparc.h */
181 #undef DBX_REGISTER_NUMBER
182 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
184 #undef ASM_OUTPUT_ALIGNED_LOCAL
185 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
187 fputs ("\t.local\t", (FILE)); \
188 assemble_name ((FILE), (NAME)); \
189 putc ('\n', (FILE)); \
190 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
194 #define COMMON_ASM_OP "\t.common\t"
196 #undef LOCAL_LABEL_PREFIX
197 #define LOCAL_LABEL_PREFIX "."
199 /* This is how to output a reference to an internal numbered label where
200 PREFIX is the class of label and NUM is the number within the class. */
202 #undef ASM_OUTPUT_INTERNAL_LABELREF
203 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
204 fprintf (FILE, ".L%s%d", PREFIX, NUM)
206 /* This is how to store into the string LABEL
207 the symbol_ref name of an internal numbered label where
208 PREFIX is the class of label and NUM is the number within the class.
209 This is suitable for output with `assemble_name'. */
211 #undef ASM_GENERATE_INTERNAL_LABEL
212 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
213 sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
216 /* Define for support of TFmode long double.
217 SPARC ABI says that long double is 4 words. */
218 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
220 /* Constant which presents upper bound of the above value. */
221 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
223 /* Define this to set long double type size to use in libgcc2.c, which can
224 not depend on target_flags. */
225 #ifdef __LONG_DOUBLE_128__
226 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
228 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
231 #if !defined(USE_GNULIBC_1) && defined(HAVE_LD_EH_FRAME_HDR)
232 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
236 #undef TARGET_SUN_TLS
237 #undef TARGET_GNU_TLS
238 #define TARGET_SUN_TLS 0
239 #define TARGET_GNU_TLS 1
242 /* Don't be different from other Linux platforms in this regard. */
243 #define HANDLE_PRAGMA_PACK_PUSH_POP
245 /* We use GNU ld so undefine this so that attribute((init_priority)) works. */
246 #undef CTORS_SECTION_ASM_OP
247 #undef DTORS_SECTION_ASM_OP
249 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
251 /* Do code reading to identify a signal frame, and set the frame
252 state data appropriately. See unwind-dw2.c for the structs. */
254 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
256 unsigned int *pc_ = (CONTEXT)->ra; \
257 int new_cfa_, i_, oldstyle_; \
258 int regs_off_, fpu_save_off_; \
259 int fpu_save_, this_cfa_; \
261 if (pc_[1] != 0x91d02010) /* ta 0x10 */ \
263 if (pc_[0] == 0x821020d8) /* mov NR_sigreturn, %g1 */ \
265 else if (pc_[0] == 0x82102065) /* mov NR_rt_sigreturn, %g1 */ \
272 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4); \
276 regs_off_ = 96 + 128; \
277 fpu_save_off_ = regs_off_ + (4 * 4) + (16 * 4) + (2 * 4); \
279 this_cfa_ = (int) (CONTEXT)->cfa; \
280 new_cfa_ = *(int *)(((CONTEXT)->cfa) + (regs_off_+(4*4)+(14 * 4))); \
281 fpu_save_ = *(int *)((this_cfa_) + (fpu_save_off_)); \
282 (FS)->cfa_how = CFA_REG_OFFSET; \
283 (FS)->cfa_reg = 14; \
284 (FS)->cfa_offset = new_cfa_ - (int) (CONTEXT)->cfa; \
285 for (i_ = 1; i_ < 16; ++i_) \
289 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
290 (FS)->regs.reg[i_].loc.offset = \
291 this_cfa_ + (regs_off_+(4 * 4)+(i_ * 4)) - new_cfa_; \
293 for (i_ = 0; i_ < 16; ++i_) \
295 (FS)->regs.reg[i_ + 16].how = REG_SAVED_OFFSET; \
296 (FS)->regs.reg[i_ + 16].loc.offset = \
297 this_cfa_ + (i_ * 4) - new_cfa_; \
301 for (i_ = 0; i_ < 32; ++i_) \
303 (FS)->regs.reg[i_ + 32].how = REG_SAVED_OFFSET; \
304 (FS)->regs.reg[i_ + 32].loc.offset = \
305 (fpu_save_ + (i_ * 4)) - new_cfa_; \
308 /* Stick return address into %g0, same trick Alpha uses. */ \
309 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
310 (FS)->regs.reg[0].loc.offset = this_cfa_+(regs_off_+4)-new_cfa_; \
311 (FS)->retaddr_column = 0; \