OSDN Git Service

62f0c742160bc8aea5967501c0b3a7df0edc1801
[pf3gnuchains/gcc-fork.git] / gcc / config / sparc / linux64.h
1 /* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
2    Copyright 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
3    Contributed by David S. Miller (davem@caip.rutgers.edu)
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 #undef MD_EXEC_PREFIX
28 #undef MD_STARTFILE_PREFIX
29
30 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
31 /* A 64 bit v9 compiler with stack-bias,
32    in a Medium/Low code model environment.  */
33
34 #undef TARGET_DEFAULT
35 #define TARGET_DEFAULT \
36   (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
37    + MASK_STACK_BIAS + MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU + MASK_LONG_DOUBLE_128)
38 #endif
39
40 #undef ASM_CPU_DEFAULT_SPEC
41 #define ASM_CPU_DEFAULT_SPEC "-Av9a"
42
43 #ifdef SPARC_BI_ARCH
44
45 #undef CPP_ARCH32_SPEC
46 #define CPP_ARCH32_SPEC "%{mlong-double-128:-D__LONG_DOUBLE_128__} \
47 -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
48 -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc"
49
50 #endif
51
52 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
53    the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
54    provides part of the support for getting C++ file-scope static
55    object constructed before entering `main'.  */
56    
57 #undef  STARTFILE_SPEC
58
59 #define STARTFILE_SPEC32 \
60   "%{!shared: \
61      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
62    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
63
64 #define STARTFILE_SPEC64 \
65   "%{!shared: \
66      %{pg:/usr/lib64/gcrt1.o%s} %{!pg:%{p:/usr/lib64/gcrt1.o%s} %{!p:/usr/lib64/crt1.o%s}}}\
67    /usr/lib64/crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
68    
69 #ifdef SPARC_BI_ARCH
70
71 #if DEFAULT_ARCH32_P
72 #define STARTFILE_SPEC "\
73 %{m32:" STARTFILE_SPEC32 "} \
74 %{m64:" STARTFILE_SPEC64 "} \
75 %{!m32:%{!m64:" STARTFILE_SPEC32 "}}"
76 #else
77 #define STARTFILE_SPEC "\
78 %{m32:" STARTFILE_SPEC32 "} \
79 %{m64:" STARTFILE_SPEC64 "} \
80 %{!m32:%{!m64:" STARTFILE_SPEC64 "}}"
81 #endif
82
83 #else
84
85 #define STARTFILE_SPEC STARTFILE_SPEC64
86
87 #endif
88
89 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
90    the GNU/Linux magical crtend.o file (see crtstuff.c) which
91    provides part of the support for getting C++ file-scope static
92    object constructed before entering `main', followed by a normal
93    GNU/Linux "finalizer" file, `crtn.o'.  */
94
95 #undef  ENDFILE_SPEC
96
97 #define ENDFILE_SPEC32 \
98   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
99
100 #define ENDFILE_SPEC64 \
101   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} /usr/lib64/crtn.o%s"
102   
103 #ifdef SPARC_BI_ARCH
104
105 #if DEFAULT_ARCH32_P
106 #define ENDFILE_SPEC "\
107 %{m32:" ENDFILE_SPEC32 "} \
108 %{m64:" ENDFILE_SPEC64 "} \
109 %{!m32:%{!m64:" ENDFILE_SPEC32 "}}"
110 #else
111 #define ENDFILE_SPEC "\
112 %{m32:" ENDFILE_SPEC32 "} \
113 %{m64:" ENDFILE_SPEC64 "} \
114 %{!m32:%{!m64:" ENDFILE_SPEC64 "}}"
115 #endif
116
117 #else
118
119 #define ENDFILE_SPEC ENDFILE_SPEC64
120
121 #endif
122
123 /* The GNU C++ standard library requires that these macros be defined.  */
124 #undef CPLUSPLUS_CPP_SPEC
125 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
126
127 #undef TARGET_VERSION
128 #define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
129
130 /* The default code model.  */
131 #undef SPARC_DEFAULT_CMODEL
132 #define SPARC_DEFAULT_CMODEL CM_MEDLOW
133
134 #undef SUBTARGET_SWITCHES
135 #define SUBTARGET_SWITCHES                                                  \
136 {"long-double-64", -MASK_LONG_DOUBLE_128, N_("Use 64 bit long doubles") },  \
137 {"long-double-128", MASK_LONG_DOUBLE_128, N_("Use 128 bit long doubles") },
138
139 #undef WCHAR_TYPE
140 #define WCHAR_TYPE "int"
141
142 #undef WCHAR_TYPE_SIZE
143 #define WCHAR_TYPE_SIZE 32
144
145 #undef MAX_WCHAR_TYPE_SIZE
146
147 /* Define for support of TFmode long double and REAL_ARITHMETIC.
148    Sparc ABI says that long double is 4 words.  */
149 #undef LONG_DOUBLE_TYPE_SIZE
150 #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
151
152 /* Constant which presents upper bound of the above value.  */
153 #undef MAX_LONG_DOUBLE_TYPE_SIZE
154 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
155
156 /* Define this to set long double type size to use in libgcc2.c, which can
157    not depend on target_flags.  */
158 #if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
159 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
160 #else
161 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
162 #endif
163
164 #undef CPP_PREDEFINES
165 #define CPP_PREDEFINES "-D__ELF__ -Dunix -D_LONGLONG -D__sparc__ -Dlinux -Asystem=unix -Asystem=posix"
166
167 #undef CPP_SUBTARGET_SPEC
168 #define CPP_SUBTARGET_SPEC "\
169 %{fPIC:-D__PIC__ -D__pic__} \
170 %{fpic:-D__PIC__ -D__pic__} \
171 %{posix:-D_POSIX_SOURCE} \
172 %{pthread:-D_REENTRANT} \
173 "
174
175 #undef LIB_SPEC
176 #define LIB_SPEC \
177   "%{shared: -lc} \
178    %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
179      %{profile:-lc_p} %{!profile: -lc}}"
180
181 /* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
182    for the special GCC options -static and -shared, which allow us to
183    link things in one of these three modes by applying the appropriate
184    combinations of options at link-time. We like to support here for
185    as many of the other GNU linker options as possible. But I don't
186    have the time to search for those flags. I am sure how to add
187    support for -soname shared_object_name. H.J.
188
189    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
190    -Wl,-V.
191
192    When the -shared link option is used a final link is not being
193    done.  */
194
195 /* If ELF is the default format, we should not use /lib/elf.  */
196
197 #ifdef SPARC_BI_ARCH
198
199 #undef SUBTARGET_EXTRA_SPECS
200 #define SUBTARGET_EXTRA_SPECS \
201   { "link_arch32",       LINK_ARCH32_SPEC },              \
202   { "link_arch64",       LINK_ARCH64_SPEC },              \
203   { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },        \
204   { "link_arch",         LINK_ARCH_SPEC },
205     
206 #define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
207   %{!shared: \
208     %{!ibcs: \
209       %{!static: \
210         %{rdynamic:-export-dynamic} \
211         %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
212         %{static:-static}}} \
213 "
214
215 #define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
216   %{!shared: \
217     %{!ibcs: \
218       %{!static: \
219         %{rdynamic:-export-dynamic} \
220         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
221         %{static:-static}}} \
222 "
223
224 #define LINK_ARCH_SPEC "\
225 %{m32:%(link_arch32)} \
226 %{m64:%(link_arch64)} \
227 %{!m32:%{!m64:%(link_arch_default)}} \
228 "
229
230 #define LINK_ARCH_DEFAULT_SPEC \
231 (DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
232
233 #undef  LINK_SPEC
234 #define LINK_SPEC "\
235 %(link_arch) \
236 %{mlittle-endian:-EL} \
237 %{!mno-relax:%{!r:-relax}} \
238 "
239
240 #undef  CC1_SPEC
241 #if DEFAULT_ARCH32_P
242 #define CC1_SPEC "\
243 %{sun4:} %{target:} \
244 %{mcypress:-mcpu=cypress} \
245 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
246 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
247 %{m64:-mptr64 -mstack-bias -mlong-double-128 \
248   %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=ultrasparc}}}}}}} \
249   %{!mno-vis:%{!mcpu=v9:-mvis}}} \
250 %{!m64:%{g*:%{!gs*:%{!gd*:%{!gx*:%{!gc*:-gstabs+}}}}}} \
251 "
252 #else
253 #define CC1_SPEC "\
254 %{sun4:} %{target:} \
255 %{mcypress:-mcpu=cypress} \
256 %{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
257 %{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
258 %{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
259   %{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:-mcpu=cypress}}}}}}} \
260   %{g*:%{!gs*:%{!gd*:%{!gx*:%{!gc*:-gstabs+}}}}}} \
261 %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
262 %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}} \
263 "
264 #endif
265
266 #if DEFAULT_ARCH32_P
267 #define MULTILIB_DEFAULTS { "m32" }
268 #else
269 #define MULTILIB_DEFAULTS { "m64" }
270 #endif
271
272 #else /* !SPARC_BI_ARCH */
273
274 #undef LINK_SPEC
275 #define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
276   %{!shared: \
277     %{!ibcs: \
278       %{!static: \
279         %{rdynamic:-export-dynamic} \
280         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
281         %{static:-static}}} \
282 %{mlittle-endian:-EL} \
283 %{!mno-relax:%{!r:-relax}} \
284 "
285
286 #endif /* !SPARC_BI_ARCH */
287
288 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
289    It's safe to pass -s always, even if -g is not used.  */
290 #undef ASM_SPEC
291 #define ASM_SPEC "\
292 %{V} \
293 %{v:%{!V:-V}} \
294 %{!Qn:-Qy} \
295 %{n} \
296 %{T} \
297 %{Ym,*} \
298 %{Wa,*:%*} \
299 -s %{fpic:-K PIC} %{fPIC:-K PIC} \
300 %{mlittle-endian:-EL} \
301 %(asm_cpu) %(asm_arch) %(asm_relax)"
302
303 /* Same as sparc.h */
304 #undef DBX_REGISTER_NUMBER
305 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
306
307 /* System V Release 4 uses DWARF debugging info.  Buf DWARF1 doesn't do
308    64-bit anything, so we use DWARF2.  */
309
310 #undef DWARF2_DEBUGGING_INFO
311 #undef DWARF_DEBUGGING_INFO
312 #undef DBX_DEBUGGING_INFO
313 #define DWARF2_DEBUGGING_INFO
314 #define DBX_DEBUGGING_INFO
315
316 #undef PREFERRED_DEBUGGING_TYPE
317 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
318
319 #undef ASM_OUTPUT_ALIGNED_LOCAL
320 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
321 do {                                                                    \
322   fputs ("\t.local\t", (FILE));         \
323   assemble_name ((FILE), (NAME));                                       \
324   putc ('\n', (FILE));                                                  \
325   ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);                  \
326 } while (0)
327
328 #undef COMMON_ASM_OP
329 #define COMMON_ASM_OP "\t.common\t"
330
331 /* This is how to output a definition of an internal numbered label where
332    PREFIX is the class of label and NUM is the number within the class.  */
333
334 #undef  ASM_OUTPUT_INTERNAL_LABEL
335 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)      \
336   fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
337
338 /* This is how to output a reference to an internal numbered label where
339    PREFIX is the class of label and NUM is the number within the class.  */
340
341 #undef  ASM_OUTPUT_INTERNAL_LABELREF
342 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)   \
343   fprintf (FILE, ".L%s%d", PREFIX, NUM)
344
345 /* This is how to store into the string LABEL
346    the symbol_ref name of an internal numbered label where
347    PREFIX is the class of label and NUM is the number within the class.
348    This is suitable for output with `assemble_name'.  */
349
350 #undef  ASM_GENERATE_INTERNAL_LABEL
351 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
352   sprintf (LABEL, "*.L%s%ld", PREFIX, (long)(NUM))
353
354 /* Define the names of various pseudo-ops used by the Sparc/svr4 assembler.
355    ??? If ints are 64 bits then UNALIGNED_INT_ASM_OP (defined elsewhere) is
356    misnamed.  These should all refer to explicit sizes (half/word/xword?),
357    anything other than short/int/long/etc.  */
358
359 #undef  UNALIGNED_DOUBLE_INT_ASM_OP
360 #define UNALIGNED_DOUBLE_INT_ASM_OP     "\t.uaxword\t"
361
362 /* DWARF bits.  */
363
364 /* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets. 
365    Obviously the Dwarf2 folks havn't tried to actually build systems
366    with their spec.  On a 64-bit system, only 64-bit relocs become
367    RELATIVE relocations.  */
368
369 /* #define DWARF_OFFSET_SIZE PTR_SIZE */
370 \f