OSDN Git Service

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