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