tm.texi: Remove DEFAULT_VTABLE_THUNKS.
[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 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 /* Don't assume anything about the header files. */
25 #define NO_IMPLICIT_EXTERN_C
26
27 /* GNU/Linux uses ctype from glibc.a. I am not sure how complete it is.
28 For now, we play safe. It may change later. */
29
30 #if 0
31 #undef MULTIBYTE_CHARS
32 #define MULTIBYTE_CHARS 1
33 #endif
34
35 /* Use stabs instead of DWARF debug format. */
36 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
37
38 #include <sparc/sysv4.h>
39
40 #undef MD_EXEC_PREFIX
41 #undef MD_STARTFILE_PREFIX
42
43 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
44 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
45 provides part of the support for getting C++ file-scope static
46 object constructed before entering `main'. */
47
48 #undef STARTFILE_SPEC
49 #define STARTFILE_SPEC \
50 "%{!shared: \
51 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
52 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
53
54 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
55 the GNU/Linux magical crtend.o file (see crtstuff.c) which
56 provides part of the support for getting C++ file-scope static
57 object constructed before entering `main', followed by a normal
58 GNU/Linux "finalizer" file, `crtn.o'. */
59
60 #undef ENDFILE_SPEC
61 #define ENDFILE_SPEC \
62 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
63
64 /* This is for -profile to use -lc_p instead of -lc. */
65 #undef CC1_SPEC
66 #define CC1_SPEC "%{profile:-p} \
67 %{sun4:} %{target:} \
68 %{mcypress:-mcpu=cypress} \
69 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
70 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
71 "
72
73 #undef TARGET_VERSION
74 #define TARGET_VERSION fprintf (stderr, " (sparc GNU/Linux with ELF)");
75
76 #undef SUBTARGET_SWITCHES
77 #define SUBTARGET_SWITCHES \
78 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") }, \
79 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
80
81 #undef SIZE_TYPE
82 #define SIZE_TYPE "unsigned int"
83
84 #undef PTRDIFF_TYPE
85 #define PTRDIFF_TYPE "int"
86
87 #undef WCHAR_TYPE
88 #define WCHAR_TYPE "int"
89
90 #undef WCHAR_TYPE_SIZE
91 #define WCHAR_TYPE_SIZE 32
92
93 #undef MAX_WCHAR_TYPE_SIZE
94
95 #undef CPP_PREDEFINES
96 #define CPP_PREDEFINES "-D__ELF__ -Dunix -D__sparc__ -Dlinux -Asystem=unix -Asystem=posix"
97
98 #undef CPP_SUBTARGET_SPEC
99 #ifdef USE_GNULIBC_1
100 #define CPP_SUBTARGET_SPEC \
101 "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
102 %{mlong-double-128:-D__LONG_DOUBLE_128__}"
103 #else
104 #define CPP_SUBTARGET_SPEC \
105 "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
106 %{pthread:-D_REENTRANT} %{mlong-double-128:-D__LONG_DOUBLE_128__}"
107 #endif
108
109 #undef LIB_SPEC
110 /* We no longer link with libc_p.a or libg.a by default. If you
111 want to profile or debug the GNU/Linux C library, please add
112 -lc_p or -ggdb to LDFLAGS at the link time, respectively. */
113 #if 1
114 #ifdef USE_GNULIBC_1
115 #define LIB_SPEC \
116 "%{!shared: %{p:-lgmon} %{pg:-lgmon} %{profile:-lgmon -lc_p} \
117 %{!profile:%{!ggdb:-lc} %{ggdb:-lg}}}"
118 #else
119 #define LIB_SPEC \
120 "%{shared: -lc} \
121 %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
122 %{profile:-lc_p} %{!profile: -lc}}"
123 #endif
124 #else
125 #define LIB_SPEC \
126 "%{!shared: \
127 %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
128 %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
129 #endif
130
131 /* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
132 for the special GCC options -static and -shared, which allow us to
133 link things in one of these three modes by applying the appropriate
134 combinations of options at link-time. We like to support here for
135 as many of the other GNU linker options as possible. But I don't
136 have the time to search for those flags. I am sure how to add
137 support for -soname shared_object_name. H.J.
138
139 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
140 -Wl,-V.
141
142 When the -shared link option is used a final link is not being
143 done. */
144
145 /* If ELF is the default format, we should not use /lib/elf. */
146
147 #undef LINK_SPEC
148 #ifdef USE_GNULIBC_1
149 #ifndef LINUX_DEFAULT_ELF
150 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
151 %{!shared: \
152 %{!ibcs: \
153 %{!static: \
154 %{rdynamic:-export-dynamic} \
155 %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \
156 %{!rpath:-rpath /lib/elf/}} %{static:-static}}}"
157 #else
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/ld-linux.so.1}} \
164 %{static:-static}}}"
165 #endif
166 #else
167 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
168 %{!mno-relax:%{!r:-relax}} \
169 %{!shared: \
170 %{!ibcs: \
171 %{!static: \
172 %{rdynamic:-export-dynamic} \
173 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
174 %{static:-static}}}"
175 #endif
176
177 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
178 It's safe to pass -s always, even if -g is not used. */
179 #undef ASM_SPEC
180 #define ASM_SPEC \
181 "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} \
182 %{fPIC:-K PIC} %(asm_relax)"
183
184 /* Same as sparc.h */
185 #undef DBX_REGISTER_NUMBER
186 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
187
188 /* We use stabs-in-elf for debugging, because that is what the native
189 toolchain uses. XXX */
190 #undef PREFERRED_DEBUGGING_TYPE
191 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
192
193 #undef ASM_OUTPUT_ALIGNED_LOCAL
194 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
195 do { \
196 fputs ("\t.local\t", (FILE)); \
197 assemble_name ((FILE), (NAME)); \
198 putc ('\n', (FILE)); \
199 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
200 } while (0)
201
202 #undef COMMON_ASM_OP
203 #define COMMON_ASM_OP "\t.common\t"
204
205 /* This is how to output a definition of an internal numbered label where
206 PREFIX is the class of label and NUM is the number within the class. */
207
208 #undef ASM_OUTPUT_INTERNAL_LABEL
209 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
210 fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
211
212 /* This is how to output a reference to an internal numbered label where
213 PREFIX is the class of label and NUM is the number within the class. */
214
215 #undef ASM_OUTPUT_INTERNAL_LABELREF
216 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
217 fprintf (FILE, ".L%s%d", PREFIX, NUM)
218
219 /* This is how to store into the string LABEL
220 the symbol_ref name of an internal numbered label where
221 PREFIX is the class of label and NUM is the number within the class.
222 This is suitable for output with `assemble_name'. */
223
224 #undef ASM_GENERATE_INTERNAL_LABEL
225 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
226 sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
227
228 \f
229 /* Define for support of TFmode long double and REAL_ARITHMETIC.
230 Sparc ABI says that long double is 4 words. */
231 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
232
233 /* Constant which presents upper bound of the above value. */
234 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
235
236 /* Define this to set long double type size to use in libgcc2.c, which can
237 not depend on target_flags. */
238 #ifdef __LONG_DOUBLE_128__
239 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
240 #else
241 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
242 #endif
243 \f
244 /* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
245 traps available which can get and set the condition codes
246 reliably. */
247 #undef MACHINE_STATE_SAVE
248 #define MACHINE_STATE_SAVE(ID) \
249 unsigned long int ms_flags, ms_saveret; \
250 asm volatile("ta 0x20\n\t" \
251 "mov %%g1, %0\n\t" \
252 "mov %%g2, %1\n\t" \
253 : "=r" (ms_flags), "=r" (ms_saveret));
254
255 #undef MACHINE_STATE_RESTORE
256 #define MACHINE_STATE_RESTORE(ID) \
257 asm volatile("mov %0, %%g1\n\t" \
258 "mov %1, %%g2\n\t" \
259 "ta 0x21\n\t" \
260 : /* no outputs */ \
261 : "r" (ms_flags), "r" (ms_saveret));