]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/alpha/elf.h
alpha.h (MASK_FIX, TARGET_FIX): New.
[thirdparty/gcc.git] / gcc / config / alpha / elf.h
1 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
2 Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
3 Contributed by Richard Henderson (rth@tamu.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 #undef OBJECT_FORMAT_COFF
23 #undef EXTENDED_COFF
24 #define OBJECT_FORMAT_ELF
25
26 #define DBX_DEBUGGING_INFO
27 #define DWARF2_DEBUGGING_INFO
28
29 #undef PREFERRED_DEBUGGING_TYPE
30 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
31
32 #undef ASM_FINAL_SPEC
33
34 #undef CC1_SPEC
35 #define CC1_SPEC "%{G*}"
36
37 #undef ASM_SPEC
38 #define ASM_SPEC "%{G*} %{relax:-relax} %{gdwarf*:-no-mdebug}"
39
40 #undef LINK_SPEC
41 #define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \
42 %{O*:-O3} %{!O*:-O1} \
43 %{shared:-shared} \
44 %{!shared: \
45 %{!static: \
46 %{rdynamic:-export-dynamic} \
47 %{!dynamic-linker:-dynamic-linker %(elf_dynamic_linker)}} \
48 %{static:-static}}"
49
50 /* Output at beginning of assembler file. */
51 #undef ASM_FILE_START
52 #define ASM_FILE_START(FILE) \
53 do { \
54 if (write_symbols != DWARF2_DEBUG) \
55 { \
56 alpha_write_verstamp (FILE); \
57 output_file_directive (FILE, main_input_filename); \
58 } \
59 fprintf (FILE, "\t.set noat\n"); \
60 fprintf (FILE, "\t.set noreorder\n"); \
61 if (TARGET_BWX | TARGET_MAX | TARGET_FIX | TARGET_CIX) \
62 { \
63 fprintf (FILE, "\t.arch %s\n", \
64 (alpha_cpu == PROCESSOR_EV6 ? "ev6" \
65 : TARGET_MAX ? "pca56" : "ev56")); \
66 } \
67 } while (0)
68
69 extern void output_file_directive ();
70
71 /* Attach a special .ident directive to the end of the file to identify
72 the version of GCC which compiled this code. The format of the
73 .ident string is patterned after the ones produced by native svr4
74 C compilers. */
75
76 #define IDENT_ASM_OP ".ident"
77
78 #ifdef IDENTIFY_WITH_IDENT
79 #define ASM_IDENTIFY_GCC(FILE) /* nothing */
80 #define ASM_IDENTIFY_LANGUAGE(FILE) \
81 fprintf(FILE, "\t%s \"GCC (%s) %s\"\n", IDENT_ASM_OP, \
82 lang_identify(), version_string)
83 #else
84 #define ASM_FILE_END(FILE) \
85 do { \
86 if (!flag_no_ident) \
87 fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \
88 IDENT_ASM_OP, version_string); \
89 } while (0)
90 #endif
91
92 /* Allow #sccs in preprocessor. */
93 #define SCCS_DIRECTIVE
94
95 /* Output #ident as a .ident. */
96 #define ASM_OUTPUT_IDENT(FILE, NAME) \
97 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
98
99 /* This is how to allocate empty space in some section. The .zero
100 pseudo-op is used for this on most svr4 assemblers. */
101
102 #define SKIP_ASM_OP ".zero"
103
104 #undef ASM_OUTPUT_SKIP
105 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
106 fprintf (FILE, "\t%s\t%u\n", SKIP_ASM_OP, (SIZE))
107
108 /* Output the label which precedes a jumptable. Note that for all svr4
109 systems where we actually generate jumptables (which is to say every
110 svr4 target except i386, where we use casesi instead) we put the jump-
111 tables into the .rodata section and since other stuff could have been
112 put into the .rodata section prior to any given jumptable, we have to
113 make sure that the location counter for the .rodata section gets pro-
114 perly re-aligned prior to the actual beginning of the jump table. */
115
116 #define ALIGN_ASM_OP ".align"
117
118 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
119 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
120 ASM_OUTPUT_ALIGN ((FILE), 2);
121 #endif
122
123 #undef ASM_OUTPUT_CASE_LABEL
124 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE) \
125 do { \
126 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
127 ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \
128 } while (0)
129
130 /* The standard SVR4 assembler seems to require that certain builtin
131 library routines (e.g. .udiv) be explicitly declared as .globl
132 in each assembly file where they are referenced. */
133
134 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
135 ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
136
137 /* This says how to output assembler code to declare an
138 uninitialized external linkage data object. Under SVR4,
139 the linker seems to want the alignment of data objects
140 to depend on their types. We do exactly that here. */
141
142 #define COMMON_ASM_OP ".comm"
143
144 #undef ASM_OUTPUT_ALIGNED_COMMON
145 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
146 do { \
147 fprintf ((FILE), "\t%s\t", COMMON_ASM_OP); \
148 assemble_name ((FILE), (NAME)); \
149 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
150 } while (0)
151
152 /* This says how to output assembler code to declare an
153 uninitialized internal linkage data object. Under SVR4,
154 the linker seems to want the alignment of data objects
155 to depend on their types. We do exactly that here. */
156
157 #undef ASM_OUTPUT_ALIGNED_LOCAL
158 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
159 do { \
160 if ((SIZE) <= g_switch_value) \
161 sbss_section(); \
162 else \
163 bss_section(); \
164 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
165 assemble_name (FILE, NAME); \
166 putc (',', FILE); \
167 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
168 putc ('\n', FILE); \
169 if (!flag_inhibit_size_directive) \
170 { \
171 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
172 assemble_name (FILE, NAME); \
173 fprintf (FILE, ",%d\n", (SIZE)); \
174 } \
175 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
176 ASM_OUTPUT_LABEL(FILE, NAME); \
177 ASM_OUTPUT_SKIP((FILE), (SIZE)); \
178 } while (0)
179
180 /* This is the pseudo-op used to generate a 64-bit word of data with a
181 specific value in some section. */
182
183 #define INT_ASM_OP ".quad"
184
185 /* Biggest alignment supported by the object file format of this
186 machine. Use this macro to limit the alignment which can be
187 specified using the `__attribute__ ((aligned (N)))' construct. If
188 not defined, the default value is `BIGGEST_ALIGNMENT'.
189
190 This value is really 2^63. Since gcc figures the alignment in bits,
191 we could only potentially get to 2^60 on suitible hosts. Due to other
192 considerations in varasm, we must restrict this to what fits in an int. */
193
194 #define MAX_OFILE_ALIGNMENT \
195 (1 << (HOST_BITS_PER_INT < 64 ? HOST_BITS_PER_INT - 2 : 62))
196
197 /* This is the pseudo-op used to generate a contiguous sequence of byte
198 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
199 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
200
201 #undef ASCII_DATA_ASM_OP
202 #define ASCII_DATA_ASM_OP ".ascii"
203
204 /* Support const sections and the ctors and dtors sections for g++.
205 Note that there appears to be two different ways to support const
206 sections at the moment. You can either #define the symbol
207 READONLY_DATA_SECTION (giving it some code which switches to the
208 readonly data section) or else you can #define the symbols
209 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
210 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
211
212 #define USE_CONST_SECTION 1
213
214 #define CONST_SECTION_ASM_OP ".section\t.rodata"
215
216 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
217
218 Note that we want to give these sections the SHF_WRITE attribute
219 because these sections will actually contain data (i.e. tables of
220 addresses of functions in the current root executable or shared library
221 file) and, in the case of a shared library, the relocatable addresses
222 will have to be properly resolved/relocated (and then written into) by
223 the dynamic linker when it actually attaches the given shared library
224 to the executing process. (Note that on SVR4, you may wish to use the
225 `-z text' option to the ELF linker, when building a shared library, as
226 an additional check that you are doing everything right. But if you do
227 use the `-z text' option when building a shared library, you will get
228 errors unless the .ctors and .dtors sections are marked as writable
229 via the SHF_WRITE attribute.) */
230
231 #define CTORS_SECTION_ASM_OP ".section\t.ctors,\"aw\""
232 #define DTORS_SECTION_ASM_OP ".section\t.dtors,\"aw\""
233
234 /* Handle the small data sections. */
235 #define BSS_SECTION_ASM_OP ".section\t.bss"
236 #define SBSS_SECTION_ASM_OP ".section\t.sbss,\"aw\""
237 #define SDATA_SECTION_ASM_OP ".section\t.sdata,\"aw\""
238
239 /* On svr4, we *do* have support for the .init and .fini sections, and we
240 can put stuff in there to be executed before and after `main'. We let
241 crtstuff.c and other files know this by defining the following symbols.
242 The definitions say how to change sections to the .init and .fini
243 sections. This is the same for all known svr4 assemblers. */
244
245 #define INIT_SECTION_ASM_OP ".section\t.init"
246 #define FINI_SECTION_ASM_OP ".section\t.fini"
247
248 /* A default list of other sections which we might be "in" at any given
249 time. For targets that use additional sections (e.g. .tdesc) you
250 should override this definition in the target-specific file which
251 includes this file. */
252
253 #undef EXTRA_SECTIONS
254 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_sbss, in_sdata
255
256 /* A default list of extra section function definitions. For targets
257 that use additional sections (e.g. .tdesc) you should override this
258 definition in the target-specific file which includes this file. */
259
260 #undef EXTRA_SECTION_FUNCTIONS
261 #define EXTRA_SECTION_FUNCTIONS \
262 CONST_SECTION_FUNCTION \
263 SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
264 SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP) \
265 SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
266 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP)
267
268 #undef READONLY_DATA_SECTION
269 #define READONLY_DATA_SECTION() const_section ()
270
271 extern void text_section ();
272
273 #define CONST_SECTION_FUNCTION \
274 void \
275 const_section () \
276 { \
277 if (!USE_CONST_SECTION) \
278 text_section(); \
279 else if (in_section != in_const) \
280 { \
281 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
282 in_section = in_const; \
283 } \
284 }
285
286 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
287 void FN () \
288 { \
289 if (in_section != ENUM) \
290 { \
291 fprintf (asm_out_file, "%s\n", OP); \
292 in_section = ENUM; \
293 } \
294 }
295
296
297 /* Switch into a generic section.
298 This is currently only used to support section attributes.
299
300 We make the section read-only and executable for a function decl,
301 read-only for a const data decl, and writable for a non-const data decl. */
302 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
303 fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
304 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
305 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
306
307
308 /* A C statement (sans semicolon) to output an element in the table of
309 global constructors. */
310 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
311 do { \
312 ctors_section (); \
313 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
314 assemble_name (FILE, NAME); \
315 fprintf (FILE, "\n"); \
316 } while (0)
317
318 /* A C statement (sans semicolon) to output an element in the table of
319 global destructors. */
320 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
321 do { \
322 dtors_section (); \
323 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
324 assemble_name (FILE, NAME); \
325 fprintf (FILE, "\n"); \
326 } while (0)
327
328 /* A C statement or statements to switch to the appropriate
329 section for output of DECL. DECL is either a `VAR_DECL' node
330 or a constant of some sort. RELOC indicates whether forming
331 the initial value of DECL requires link-time relocations. */
332
333 #define SELECT_SECTION(DECL,RELOC) \
334 { \
335 if (TREE_CODE (DECL) == STRING_CST) \
336 { \
337 if (! flag_writable_strings) \
338 const_section (); \
339 else \
340 data_section (); \
341 } \
342 else if (TREE_CODE (DECL) == VAR_DECL) \
343 { \
344 if ((flag_pic && RELOC) \
345 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
346 || !DECL_INITIAL (DECL) \
347 || (DECL_INITIAL (DECL) != error_mark_node \
348 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
349 { \
350 int size = int_size_in_bytes (TREE_TYPE (DECL)); \
351 if (size >= 0 && size <= g_switch_value) \
352 sdata_section (); \
353 else \
354 data_section (); \
355 } \
356 else \
357 const_section (); \
358 } \
359 else \
360 const_section (); \
361 }
362
363 /* A C statement or statements to switch to the appropriate
364 section for output of RTX in mode MODE. RTX is some kind
365 of constant in RTL. The argument MODE is redundant except
366 in the case of a `const_int' rtx. Currently, these always
367 go into the const section. */
368
369 #undef SELECT_RTX_SECTION
370 #define SELECT_RTX_SECTION(MODE,RTX) const_section()
371
372 /* Define the strings used for the special svr4 .type and .size directives.
373 These strings generally do not vary from one system running svr4 to
374 another, but if a given system (e.g. m88k running svr) needs to use
375 different pseudo-op names for these, they may be overridden in the
376 file which includes this one. */
377
378 #define TYPE_ASM_OP ".type"
379 #define SIZE_ASM_OP ".size"
380
381 /* This is how we tell the assembler that a symbol is weak. */
382
383 #define ASM_WEAKEN_LABEL(FILE,NAME) \
384 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
385 fputc ('\n', FILE); } while (0)
386
387 /* This is how we tell the assembler that two symbols have the same value. */
388
389 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
390 do { assemble_name(FILE, NAME1); \
391 fputs(" = ", FILE); \
392 assemble_name(FILE, NAME2); \
393 fputc('\n', FILE); } while (0)
394
395 /* The following macro defines the format used to output the second
396 operand of the .type assembler directive. Different svr4 assemblers
397 expect various different forms for this operand. The one given here
398 is just a default. You may need to override it in your machine-
399 specific tm.h file (depending upon the particulars of your assembler). */
400
401 #define TYPE_OPERAND_FMT "@%s"
402
403 /* Write the extra assembler code needed to declare a function's result.
404 Most svr4 assemblers don't require any special declaration of the
405 result value, but there are exceptions. */
406
407 #ifndef ASM_DECLARE_RESULT
408 #define ASM_DECLARE_RESULT(FILE, RESULT)
409 #endif
410
411 /* These macros generate the special .type and .size directives which
412 are used to set the corresponding fields of the linker symbol table
413 entries in an ELF object file under SVR4. These macros also output
414 the starting labels for the relevant functions/objects. */
415
416 /* Write the extra assembler code needed to declare an object properly. */
417
418 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
419 do { \
420 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
421 assemble_name (FILE, NAME); \
422 putc (',', FILE); \
423 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
424 putc ('\n', FILE); \
425 size_directive_output = 0; \
426 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
427 { \
428 size_directive_output = 1; \
429 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
430 assemble_name (FILE, NAME); \
431 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
432 } \
433 ASM_OUTPUT_LABEL(FILE, NAME); \
434 } while (0)
435
436 /* Output the size directive for a decl in rest_of_decl_compilation
437 in the case where we did not do so before the initializer.
438 Once we find the error_mark_node, we know that the value of
439 size_directive_output was set
440 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
441
442 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
443 do { \
444 char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
445 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
446 && ! AT_END && TOP_LEVEL \
447 && DECL_INITIAL (DECL) == error_mark_node \
448 && !size_directive_output) \
449 { \
450 size_directive_output = 1; \
451 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
452 assemble_name (FILE, name); \
453 putc (',', FILE); \
454 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
455 int_size_in_bytes (TREE_TYPE (DECL))); \
456 putc ('\n', FILE); \
457 } \
458 } while (0)
459
460 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
461 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
462 corresponds to a particular byte value [0..255]. For any
463 given byte value, if the value in the corresponding table
464 position is zero, the given character can be output directly.
465 If the table value is 1, the byte must be output as a \ooo
466 octal escape. If the tables value is anything else, then the
467 byte value should be output as a \ followed by the value
468 in the table. Note that we can use standard UN*X escape
469 sequences for many control characters, but we don't use
470 \a to represent BEL because some svr4 assemblers (e.g. on
471 the i386) don't know about that. Also, we don't use \v
472 since some versions of gas, such as 2.2 did not accept it. */
473
474 #define ESCAPES \
475 "\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
476 \0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
477 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\
478 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\
479 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
480 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
481 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
482 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"
483
484 /* Some svr4 assemblers have a limit on the number of characters which
485 can appear in the operand of a .string directive. If your assembler
486 has such a limitation, you should define STRING_LIMIT to reflect that
487 limit. Note that at least some svr4 assemblers have a limit on the
488 actual number of bytes in the double-quoted string, and that they
489 count each character in an escape sequence as one byte. Thus, an
490 escape sequence like \377 would count as four bytes.
491
492 If your target assembler doesn't support the .string directive, you
493 should define this to zero. */
494
495 #define STRING_LIMIT ((unsigned) 256)
496 #define STRING_ASM_OP ".string"
497
498 /* GAS is the only Alpha/ELF assembler. */
499 #undef TARGET_GAS
500 #define TARGET_GAS (1)
501
502 /* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
503 (even more) magical crtbegin.o file which provides part of the
504 support for getting C++ file-scope static object constructed before
505 entering `main'.
506
507 Don't bother seeing crtstuff.c -- there is absolutely no hope of
508 getting that file to understand multiple GPs. GNU Libc provides a
509 hand-coded version that is used on Linux; it could be copied here
510 if there is ever a need. */
511
512 #undef STARTFILE_SPEC
513 #define STARTFILE_SPEC \
514 "%{!shared: \
515 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
516 crti.o%s crtbegin.o%s"
517
518 /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
519 magical crtend.o file which provides part of the support for
520 getting C++ file-scope static object constructed before entering
521 `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
522
523 #undef ENDFILE_SPEC
524 #define ENDFILE_SPEC \
525 "crtend.o%s crtn.o%s"
526
527 /* We support #pragma. */
528 #define HANDLE_SYSV_PRAGMA