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