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