1 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000 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 #undef OBJECT_FORMAT_COFF
24 #define OBJECT_FORMAT_ELF
26 #define DBX_DEBUGGING_INFO
27 #define DWARF2_DEBUGGING_INFO
29 #undef PREFERRED_DEBUGGING_TYPE
30 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
35 #define CC1_SPEC "%{G*}"
38 #define ASM_SPEC "%{G*} %{relax:-relax} %{gdwarf*:-no-mdebug}"
41 #define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \
42 %{O*:-O3} %{!O*:-O1} \
46 %{rdynamic:-export-dynamic} \
47 %{!dynamic-linker:-dynamic-linker %(elf_dynamic_linker)}} \
50 /* Output at beginning of assembler file. */
52 #define ASM_FILE_START(FILE) \
54 if (write_symbols != DWARF2_DEBUG) \
56 alpha_write_verstamp (FILE); \
57 output_file_directive (FILE, main_input_filename); \
59 fprintf (FILE, "\t.set noat\n"); \
60 fprintf (FILE, "\t.set noreorder\n"); \
61 if (TARGET_BWX | TARGET_MAX | TARGET_FIX | TARGET_CIX) \
63 fprintf (FILE, "\t.arch %s\n", \
64 (TARGET_CPU_EV6 ? "ev6" \
65 : TARGET_MAX ? "pca56" : "ev56")); \
69 /* Attach a special .ident directive to the end of the file to identify
70 the version of GCC which compiled this code. The format of the
71 .ident string is patterned after the ones produced by native svr4
74 #define IDENT_ASM_OP "\t.ident\t"
76 #ifdef IDENTIFY_WITH_IDENT
77 #define ASM_IDENTIFY_GCC(FILE) /* nothing */
78 #define ASM_IDENTIFY_LANGUAGE(FILE) \
79 fprintf(FILE, "%s\"GCC (%s) %s\"\n", IDENT_ASM_OP, \
80 lang_identify(), version_string)
82 #define ASM_FILE_END(FILE) \
85 fprintf ((FILE), "%s\"GCC: (GNU) %s\"\n", \
86 IDENT_ASM_OP, version_string); \
90 /* Allow #sccs in preprocessor. */
91 #define SCCS_DIRECTIVE
93 /* Output #ident as a .ident. */
94 #define ASM_OUTPUT_IDENT(FILE, NAME) \
95 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
97 /* This is how to allocate empty space in some section. The .zero
98 pseudo-op is used for this on most svr4 assemblers. */
100 #define SKIP_ASM_OP "\t.zero\t"
102 #undef ASM_OUTPUT_SKIP
103 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
104 fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
106 /* Output the label which precedes a jumptable. Note that for all svr4
107 systems where we actually generate jumptables (which is to say every
108 svr4 target except i386, where we use casesi instead) we put the jump-
109 tables into the .rodata section and since other stuff could have been
110 put into the .rodata section prior to any given jumptable, we have to
111 make sure that the location counter for the .rodata section gets pro-
112 perly re-aligned prior to the actual beginning of the jump table. */
114 #define ALIGN_ASM_OP "\t.align\t"
116 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
117 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
118 ASM_OUTPUT_ALIGN ((FILE), 2);
121 #undef ASM_OUTPUT_CASE_LABEL
122 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE) \
124 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
125 ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \
128 /* The standard SVR4 assembler seems to require that certain builtin
129 library routines (e.g. .udiv) be explicitly declared as .globl
130 in each assembly file where they are referenced. */
132 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
133 ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
135 /* This says how to output assembler code to declare an
136 uninitialized external linkage data object. Under SVR4,
137 the linker seems to want the alignment of data objects
138 to depend on their types. We do exactly that here. */
140 #define COMMON_ASM_OP "\t.comm\t"
142 #undef ASM_OUTPUT_ALIGNED_COMMON
143 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
145 fprintf ((FILE), "%s", COMMON_ASM_OP); \
146 assemble_name ((FILE), (NAME)); \
147 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
150 /* This says how to output assembler code to declare an
151 uninitialized internal linkage data object. Under SVR4,
152 the linker seems to want the alignment of data objects
153 to depend on their types. We do exactly that here. */
155 #undef ASM_OUTPUT_ALIGNED_LOCAL
156 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
158 if ((SIZE) <= g_switch_value) \
162 fprintf (FILE, "%s", TYPE_ASM_OP); \
163 assemble_name (FILE, NAME); \
165 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
167 if (!flag_inhibit_size_directive) \
169 fprintf (FILE, "%s", SIZE_ASM_OP); \
170 assemble_name (FILE, NAME); \
171 fprintf (FILE, ",%d\n", (SIZE)); \
173 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
174 ASM_OUTPUT_LABEL(FILE, NAME); \
175 ASM_OUTPUT_SKIP((FILE), (SIZE)); \
178 /* This is the pseudo-op used to generate a 64-bit word of data with a
179 specific value in some section. */
181 #define INT_ASM_OP "\t.quad\t"
183 /* Biggest alignment supported by the object file format of this
184 machine. Use this macro to limit the alignment which can be
185 specified using the `__attribute__ ((aligned (N)))' construct. If
186 not defined, the default value is `BIGGEST_ALIGNMENT'.
188 This value is really 2^63. Since gcc figures the alignment in bits,
189 we could only potentially get to 2^60 on suitible hosts. Due to other
190 considerations in varasm, we must restrict this to what fits in an int. */
192 #define MAX_OFILE_ALIGNMENT \
193 (1 << (HOST_BITS_PER_INT < 64 ? HOST_BITS_PER_INT - 2 : 62))
195 /* This is the pseudo-op used to generate a contiguous sequence of byte
196 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
197 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
199 #undef ASCII_DATA_ASM_OP
200 #define ASCII_DATA_ASM_OP "\t.ascii\t"
202 /* Support const sections and the ctors and dtors sections for g++.
203 Note that there appears to be two different ways to support const
204 sections at the moment. You can either #define the symbol
205 READONLY_DATA_SECTION (giving it some code which switches to the
206 readonly data section) or else you can #define the symbols
207 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
208 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
210 #define USE_CONST_SECTION 1
212 #define CONST_SECTION_ASM_OP "\t.section\t.rodata"
214 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
216 Note that we want to give these sections the SHF_WRITE attribute
217 because these sections will actually contain data (i.e. tables of
218 addresses of functions in the current root executable or shared library
219 file) and, in the case of a shared library, the relocatable addresses
220 will have to be properly resolved/relocated (and then written into) by
221 the dynamic linker when it actually attaches the given shared library
222 to the executing process. (Note that on SVR4, you may wish to use the
223 `-z text' option to the ELF linker, when building a shared library, as
224 an additional check that you are doing everything right. But if you do
225 use the `-z text' option when building a shared library, you will get
226 errors unless the .ctors and .dtors sections are marked as writable
227 via the SHF_WRITE attribute.) */
229 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
230 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
232 /* Handle the small data sections. */
233 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
234 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
235 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
237 /* On svr4, we *do* have support for the .init and .fini sections, and we
238 can put stuff in there to be executed before and after `main'. We let
239 crtstuff.c and other files know this by defining the following symbols.
240 The definitions say how to change sections to the .init and .fini
241 sections. This is the same for all known svr4 assemblers. */
243 #define INIT_SECTION_ASM_OP "\t.section\t.init"
244 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
246 /* A default list of other sections which we might be "in" at any given
247 time. For targets that use additional sections (e.g. .tdesc) you
248 should override this definition in the target-specific file which
249 includes this file. */
251 #undef EXTRA_SECTIONS
252 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_sbss, in_sdata
254 /* A default list of extra section function definitions. For targets
255 that use additional sections (e.g. .tdesc) you should override this
256 definition in the target-specific file which includes this file. */
258 #undef EXTRA_SECTION_FUNCTIONS
259 #define EXTRA_SECTION_FUNCTIONS \
260 CONST_SECTION_FUNCTION \
261 SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
262 SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP) \
263 SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
264 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP)
266 extern void ctors_section PARAMS ((void));
267 extern void dtors_section PARAMS ((void));
268 extern void sbss_section PARAMS ((void));
269 extern void sdata_section PARAMS ((void));
271 #undef READONLY_DATA_SECTION
272 #define READONLY_DATA_SECTION() const_section ()
274 #define CONST_SECTION_FUNCTION \
278 if (!USE_CONST_SECTION) \
280 else if (in_section != in_const) \
282 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
283 in_section = in_const; \
287 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
290 if (in_section != ENUM) \
292 fprintf (asm_out_file, "%s\n", OP); \
298 /* Switch into a generic section.
299 This is currently only used to support section attributes.
301 We make the section read-only and executable for a function decl,
302 read-only for a const data decl, and writable for a non-const data decl. */
303 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
304 fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
305 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
306 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
309 /* A C statement (sans semicolon) to output an element in the table of
310 global constructors. */
311 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
314 fprintf (FILE, "%s", INT_ASM_OP); \
315 assemble_name (FILE, NAME); \
316 fprintf (FILE, "\n"); \
319 /* A C statement (sans semicolon) to output an element in the table of
320 global destructors. */
321 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
324 fprintf (FILE, "%s", INT_ASM_OP); \
325 assemble_name (FILE, NAME); \
326 fprintf (FILE, "\n"); \
329 /* A C statement or statements to switch to the appropriate
330 section for output of DECL. DECL is either a `VAR_DECL' node
331 or a constant of some sort. RELOC indicates whether forming
332 the initial value of DECL requires link-time relocations. */
334 #define SELECT_SECTION(DECL,RELOC) \
336 if (TREE_CODE (DECL) == STRING_CST) \
338 if (! flag_writable_strings) \
343 else if (TREE_CODE (DECL) == VAR_DECL) \
345 if ((flag_pic && RELOC) \
346 || ! TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
347 || ! DECL_INITIAL (DECL) \
348 || (DECL_INITIAL (DECL) != error_mark_node \
349 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
351 int size = int_size_in_bytes (TREE_TYPE (DECL)); \
352 if (size >= 0 && size <= g_switch_value) \
360 else if (TREE_CODE (DECL) == CONSTRUCTOR) \
362 if ((flag_pic && RELOC) \
363 || ! TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
364 || ! TREE_CONSTANT (DECL)) \
366 int size = int_size_in_bytes (TREE_TYPE (DECL)); \
367 if (size >= 0 && size <= g_switch_value) \
379 /* A C statement or statements to switch to the appropriate
380 section for output of RTX in mode MODE. RTX is some kind
381 of constant in RTL. The argument MODE is redundant except
382 in the case of a `const_int' rtx. Currently, these always
383 go into the const section. */
385 #undef SELECT_RTX_SECTION
386 #define SELECT_RTX_SECTION(MODE,RTX) const_section()
388 /* Define the strings used for the special svr4 .type and .size directives.
389 These strings generally do not vary from one system running svr4 to
390 another, but if a given system (e.g. m88k running svr) needs to use
391 different pseudo-op names for these, they may be overridden in the
392 file which includes this one. */
394 #define TYPE_ASM_OP "\t.type\t"
395 #define SIZE_ASM_OP "\t.size\t"
397 /* This is how we tell the assembler that a symbol is weak. */
399 #define ASM_WEAKEN_LABEL(FILE,NAME) \
400 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
401 fputc ('\n', FILE); } while (0)
403 /* This is how we tell the assembler that two symbols have the same value. */
405 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
406 do { assemble_name(FILE, NAME1); \
407 fputs(" = ", FILE); \
408 assemble_name(FILE, NAME2); \
409 fputc('\n', FILE); } while (0)
411 /* The following macro defines the format used to output the second
412 operand of the .type assembler directive. Different svr4 assemblers
413 expect various different forms for this operand. The one given here
414 is just a default. You may need to override it in your machine-
415 specific tm.h file (depending upon the particulars of your assembler). */
417 #define TYPE_OPERAND_FMT "@%s"
419 /* Write the extra assembler code needed to declare a function's result.
420 Most svr4 assemblers don't require any special declaration of the
421 result value, but there are exceptions. */
423 #ifndef ASM_DECLARE_RESULT
424 #define ASM_DECLARE_RESULT(FILE, RESULT)
427 /* These macros generate the special .type and .size directives which
428 are used to set the corresponding fields of the linker symbol table
429 entries in an ELF object file under SVR4. These macros also output
430 the starting labels for the relevant functions/objects. */
432 /* Write the extra assembler code needed to declare an object properly. */
434 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
436 HOST_WIDE_INT size; \
437 fprintf (FILE, "%s", TYPE_ASM_OP); \
438 assemble_name (FILE, NAME); \
440 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
442 size_directive_output = 0; \
443 if (!flag_inhibit_size_directive \
444 && DECL_SIZE (DECL) \
445 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
447 size_directive_output = 1; \
448 fprintf (FILE, "%s", SIZE_ASM_OP); \
449 assemble_name (FILE, NAME); \
451 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, size); \
452 fputc ('\n', FILE); \
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 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
465 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
466 HOST_WIDE_INT size; \
467 if (!flag_inhibit_size_directive \
468 && DECL_SIZE (DECL) \
469 && ! AT_END && TOP_LEVEL \
470 && DECL_INITIAL (DECL) == error_mark_node \
471 && !size_directive_output \
472 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
474 size_directive_output = 1; \
475 fprintf (FILE, "%s", SIZE_ASM_OP); \
476 assemble_name (FILE, name); \
478 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, size); \
479 fputc ('\n', FILE); \
483 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
484 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
485 corresponds to a particular byte value [0..255]. For any
486 given byte value, if the value in the corresponding table
487 position is zero, the given character can be output directly.
488 If the table value is 1, the byte must be output as a \ooo
489 octal escape. If the tables value is anything else, then the
490 byte value should be output as a \ followed by the value
491 in the table. Note that we can use standard UN*X escape
492 sequences for many control characters, but we don't use
493 \a to represent BEL because some svr4 assemblers (e.g. on
494 the i386) don't know about that. Also, we don't use \v
495 since some versions of gas, such as 2.2 did not accept it. */
498 "\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\
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\
501 \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\
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\
505 \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"
507 /* Some svr4 assemblers have a limit on the number of characters which
508 can appear in the operand of a .string directive. If your assembler
509 has such a limitation, you should define STRING_LIMIT to reflect that
510 limit. Note that at least some svr4 assemblers have a limit on the
511 actual number of bytes in the double-quoted string, and that they
512 count each character in an escape sequence as one byte. Thus, an
513 escape sequence like \377 would count as four bytes.
515 If your target assembler doesn't support the .string directive, you
516 should define this to zero. */
518 #define STRING_LIMIT ((unsigned) 256)
519 #define STRING_ASM_OP "\t.string\t"
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
528 before entering `main'.
530 Don't bother seeing crtstuff.c -- there is absolutely no hope
531 of getting that file to understand multiple GPs. We provide a
532 hand-coded assembly version. */
534 #undef STARTFILE_SPEC
535 #define STARTFILE_SPEC \
537 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
538 crti.o%s %{shared:crtbeginS.o%s}%{!shared:crtbegin.o%s}"
540 /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
541 magical crtend.o file which provides part of the support for
542 getting C++ file-scope static object constructed before entering
543 `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
546 #define ENDFILE_SPEC \
547 "%{shared:crtendS.o%s}%{!shared:crtend.o%s} crtn.o%s"
549 /* We support #pragma. */
550 #define HANDLE_SYSV_PRAGMA
552 /* Undo the auto-alignment stuff from alpha.h. ELF has unaligned data
554 #undef UNALIGNED_SHORT_ASM_OP
555 #undef UNALIGNED_INT_ASM_OP
556 #undef UNALIGNED_DOUBLE_INT_ASM_OP