]>
git.ipfire.org Git - thirdparty/gcc.git/blob - 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, 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 (alpha_cpu == PROCESSOR_EV6 ? "ev6" \
65 : TARGET_MAX ? "pca56" : "ev56")); \
69 extern void output_file_directive ();
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
76 #define IDENT_ASM_OP ".ident"
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)
84 #define ASM_FILE_END(FILE) \
87 fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \
88 IDENT_ASM_OP, version_string); \
92 /* Allow #sccs in preprocessor. */
93 #define SCCS_DIRECTIVE
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);
99 /* This is how to allocate empty space in some section. The .zero
100 pseudo-op is used for this on most svr4 assemblers. */
102 #define SKIP_ASM_OP ".zero"
104 #undef ASM_OUTPUT_SKIP
105 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
106 fprintf (FILE, "\t%s\t%u\n", SKIP_ASM_OP, (SIZE))
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. */
116 #define ALIGN_ASM_OP ".align"
118 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
119 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
120 ASM_OUTPUT_ALIGN ((FILE), 2);
123 #undef ASM_OUTPUT_CASE_LABEL
124 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE) \
126 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
127 ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \
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. */
134 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
135 ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
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. */
142 #define COMMON_ASM_OP ".comm"
144 #undef ASM_OUTPUT_ALIGNED_COMMON
145 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
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); \
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. */
157 #undef ASM_OUTPUT_ALIGNED_LOCAL
158 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
160 if ((SIZE) <= g_switch_value) \
164 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
165 assemble_name (FILE, NAME); \
167 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
169 if (!flag_inhibit_size_directive) \
171 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
172 assemble_name (FILE, NAME); \
173 fprintf (FILE, ",%d\n", (SIZE)); \
175 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
176 ASM_OUTPUT_LABEL(FILE, NAME); \
177 ASM_OUTPUT_SKIP((FILE), (SIZE)); \
180 /* This is the pseudo-op used to generate a 64-bit word of data with a
181 specific value in some section. */
183 #define INT_ASM_OP ".quad"
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'.
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. */
194 #define MAX_OFILE_ALIGNMENT \
195 (1 << (HOST_BITS_PER_INT < 64 ? HOST_BITS_PER_INT - 2 : 62))
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. */
201 #undef ASCII_DATA_ASM_OP
202 #define ASCII_DATA_ASM_OP ".ascii"
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. */
212 #define USE_CONST_SECTION 1
214 #define CONST_SECTION_ASM_OP ".section\t.rodata"
216 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
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.) */
231 #define CTORS_SECTION_ASM_OP ".section\t.ctors,\"aw\""
232 #define DTORS_SECTION_ASM_OP ".section\t.dtors,\"aw\""
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\""
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. */
245 #define INIT_SECTION_ASM_OP ".section\t.init"
246 #define FINI_SECTION_ASM_OP ".section\t.fini"
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. */
253 #undef EXTRA_SECTIONS
254 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_sbss, in_sdata
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. */
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)
268 #undef READONLY_DATA_SECTION
269 #define READONLY_DATA_SECTION() const_section ()
271 #define CONST_SECTION_FUNCTION \
275 if (!USE_CONST_SECTION) \
277 else if (in_section != in_const) \
279 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
280 in_section = in_const; \
284 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
285 void FN PARAMS ((void)); \
288 if (in_section != ENUM) \
290 fprintf (asm_out_file, "%s\n", OP); \
296 /* Switch into a generic section.
297 This is currently only used to support section attributes.
299 We make the section read-only and executable for a function decl,
300 read-only for a const data decl, and writable for a non-const data decl. */
301 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
302 fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
303 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
304 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
307 /* A C statement (sans semicolon) to output an element in the table of
308 global constructors. */
309 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
312 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
313 assemble_name (FILE, NAME); \
314 fprintf (FILE, "\n"); \
317 /* A C statement (sans semicolon) to output an element in the table of
318 global destructors. */
319 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
322 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
323 assemble_name (FILE, NAME); \
324 fprintf (FILE, "\n"); \
327 /* A C statement or statements to switch to the appropriate
328 section for output of DECL. DECL is either a `VAR_DECL' node
329 or a constant of some sort. RELOC indicates whether forming
330 the initial value of DECL requires link-time relocations. */
332 #define SELECT_SECTION(DECL,RELOC) \
334 if (TREE_CODE (DECL) == STRING_CST) \
336 if (! flag_writable_strings) \
341 else if (TREE_CODE (DECL) == VAR_DECL) \
343 if ((flag_pic && RELOC) \
344 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
345 || !DECL_INITIAL (DECL) \
346 || (DECL_INITIAL (DECL) != error_mark_node \
347 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
349 int size = int_size_in_bytes (TREE_TYPE (DECL)); \
350 if (size >= 0 && size <= g_switch_value) \
362 /* A C statement or statements to switch to the appropriate
363 section for output of RTX in mode MODE. RTX is some kind
364 of constant in RTL. The argument MODE is redundant except
365 in the case of a `const_int' rtx. Currently, these always
366 go into the const section. */
368 #undef SELECT_RTX_SECTION
369 #define SELECT_RTX_SECTION(MODE,RTX) const_section()
371 /* Define the strings used for the special svr4 .type and .size directives.
372 These strings generally do not vary from one system running svr4 to
373 another, but if a given system (e.g. m88k running svr) needs to use
374 different pseudo-op names for these, they may be overridden in the
375 file which includes this one. */
377 #define TYPE_ASM_OP ".type"
378 #define SIZE_ASM_OP ".size"
380 /* This is how we tell the assembler that a symbol is weak. */
382 #define ASM_WEAKEN_LABEL(FILE,NAME) \
383 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
384 fputc ('\n', FILE); } while (0)
386 /* This is how we tell the assembler that two symbols have the same value. */
388 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
389 do { assemble_name(FILE, NAME1); \
390 fputs(" = ", FILE); \
391 assemble_name(FILE, NAME2); \
392 fputc('\n', FILE); } while (0)
394 /* The following macro defines the format used to output the second
395 operand of the .type assembler directive. Different svr4 assemblers
396 expect various different forms for this operand. The one given here
397 is just a default. You may need to override it in your machine-
398 specific tm.h file (depending upon the particulars of your assembler). */
400 #define TYPE_OPERAND_FMT "@%s"
402 /* Write the extra assembler code needed to declare a function's result.
403 Most svr4 assemblers don't require any special declaration of the
404 result value, but there are exceptions. */
406 #ifndef ASM_DECLARE_RESULT
407 #define ASM_DECLARE_RESULT(FILE, RESULT)
410 /* These macros generate the special .type and .size directives which
411 are used to set the corresponding fields of the linker symbol table
412 entries in an ELF object file under SVR4. These macros also output
413 the starting labels for the relevant functions/objects. */
415 /* Write the extra assembler code needed to declare an object properly. */
417 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
419 HOST_WIDE_INT size; \
420 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
421 assemble_name (FILE, NAME); \
423 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
425 size_directive_output = 0; \
426 if (!flag_inhibit_size_directive \
427 && DECL_SIZE (DECL) \
428 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
430 size_directive_output = 1; \
431 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
432 assemble_name (FILE, NAME); \
434 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, size); \
435 fputc ('\n', FILE); \
437 ASM_OUTPUT_LABEL(FILE, NAME); \
440 /* Output the size directive for a decl in rest_of_decl_compilation
441 in the case where we did not do so before the initializer.
442 Once we find the error_mark_node, we know that the value of
443 size_directive_output was set
444 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
446 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
448 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
449 HOST_WIDE_INT size; \
450 if (!flag_inhibit_size_directive \
451 && DECL_SIZE (DECL) \
452 && ! AT_END && TOP_LEVEL \
453 && DECL_INITIAL (DECL) == error_mark_node \
454 && !size_directive_output \
455 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
457 size_directive_output = 1; \
458 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
459 assemble_name (FILE, name); \
461 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, size); \
462 fputc ('\n', FILE); \
466 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
467 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
468 corresponds to a particular byte value [0..255]. For any
469 given byte value, if the value in the corresponding table
470 position is zero, the given character can be output directly.
471 If the table value is 1, the byte must be output as a \ooo
472 octal escape. If the tables value is anything else, then the
473 byte value should be output as a \ followed by the value
474 in the table. Note that we can use standard UN*X escape
475 sequences for many control characters, but we don't use
476 \a to represent BEL because some svr4 assemblers (e.g. on
477 the i386) don't know about that. Also, we don't use \v
478 since some versions of gas, such as 2.2 did not accept it. */
481 "\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\
482 \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\
483 \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\
484 \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\
485 \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\
486 \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\
487 \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\
488 \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"
490 /* Some svr4 assemblers have a limit on the number of characters which
491 can appear in the operand of a .string directive. If your assembler
492 has such a limitation, you should define STRING_LIMIT to reflect that
493 limit. Note that at least some svr4 assemblers have a limit on the
494 actual number of bytes in the double-quoted string, and that they
495 count each character in an escape sequence as one byte. Thus, an
496 escape sequence like \377 would count as four bytes.
498 If your target assembler doesn't support the .string directive, you
499 should define this to zero. */
501 #define STRING_LIMIT ((unsigned) 256)
502 #define STRING_ASM_OP ".string"
504 /* GAS is the only Alpha/ELF assembler. */
506 #define TARGET_GAS (1)
508 /* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
509 (even more) magical crtbegin.o file which provides part of the
510 support for getting C++ file-scope static object constructed
511 before entering `main'.
513 Don't bother seeing crtstuff.c -- there is absolutely no hope
514 of getting that file to understand multiple GPs. We provide a
515 hand-coded assembly version. */
517 #undef STARTFILE_SPEC
518 #define STARTFILE_SPEC \
520 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
521 crti.o%s %{shared:crtbeginS.o%s}%{!shared:crtbegin.o%s}"
523 /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
524 magical crtend.o file which provides part of the support for
525 getting C++ file-scope static object constructed before entering
526 `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
529 #define ENDFILE_SPEC \
530 "%{shared:crtendS.o%s}%{!shared:crtend.o%s} crtn.o%s"
532 /* We support #pragma. */
533 #define HANDLE_SYSV_PRAGMA
535 /* Undo the auto-alignment stuff from alpha.h. ELF has unaligned data
537 #undef UNALIGNED_SHORT_ASM_OP
538 #undef UNALIGNED_INT_ASM_OP
539 #undef UNALIGNED_DOUBLE_INT_ASM_OP