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