1 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
2 Copyright (C) 1996 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 /* This is used on Alpha platforms that use the ELF format.
23 Currently only Linux uses this. */
26 #define TARGET_VERSION fprintf (stderr, " (Alpha Linux/ELF)");
28 #undef OBJECT_FORMAT_COFF
30 #define OBJECT_FORMAT_ELF
32 #define SDB_DEBUGGING_INFO
37 #define CPP_PREDEFINES "\
38 -D__alpha -D__alpha__ -D__linux__ -D__linux -D_LONGLONG -Dlinux -Dunix \
39 -Asystem(linux) -Acpu(alpha) -Amachine(alpha) -D__ELF__"
42 #define LINK_SPEC "-m elf64_alpha -G 8 %{O*:-O3} %{!O*:-O1} \
46 %{rdynamic:-export-dynamic} \
47 %{!dynamic-linker:-dynamic-linker /lib/ld-gnu.so.1}} \
50 /* Output at beginning of assembler file. */
53 #define ASM_FILE_START(FILE) \
55 alpha_write_verstamp (FILE); \
56 output_file_directive (FILE, main_input_filename); \
57 fprintf (FILE, "\t.version\t\"01.01\"\n"); \
58 fprintf (FILE, "\t.set noat\n"); \
61 #define ASM_OUTPUT_SOURCE_LINE(STREAM, LINE) \
62 alpha_output_lineno (STREAM, LINE)
63 extern void alpha_output_lineno ();
65 extern void output_file_directive ();
67 /* Attach a special .ident directive to the end of the file to identify
68 the version of GCC which compiled this code. The format of the
69 .ident string is patterned after the ones produced by native svr4
72 #define IDENT_ASM_OP ".ident"
74 #ifdef IDENTIFY_WITH_IDENT
75 #define ASM_IDENTIFY_GCC(FILE) /* nothing */
76 #define ASM_IDENTIFY_LANGUAGE(FILE) \
77 fprintf(FILE, "\t%s \"GCC (%s) %s\"\n", IDENT_ASM_OP, \
78 lang_identify(), version_string)
80 #define ASM_FILE_END(FILE) \
82 fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \
83 IDENT_ASM_OP, version_string); \
87 /* Allow #sccs in preprocessor. */
89 #define SCCS_DIRECTIVE
91 /* Output #ident as a .ident. */
93 #define ASM_OUTPUT_IDENT(FILE, NAME) \
94 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
96 /* This is how to allocate empty space in some section. The .zero
97 pseudo-op is used for this on most svr4 assemblers. */
99 #define SKIP_ASM_OP ".zero"
101 #undef ASM_OUTPUT_SKIP
102 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
103 fprintf (FILE, "\t%s\t%u\n", SKIP_ASM_OP, (SIZE))
105 /* Output the label which precedes a jumptable. Note that for all svr4
106 systems where we actually generate jumptables (which is to say every
107 svr4 target except i386, where we use casesi instead) we put the jump-
108 tables into the .rodata section and since other stuff could have been
109 put into the .rodata section prior to any given jumptable, we have to
110 make sure that the location counter for the .rodata section gets pro-
111 perly re-aligned prior to the actual beginning of the jump table. */
113 #define ALIGN_ASM_OP ".align"
115 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
116 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
117 ASM_OUTPUT_ALIGN ((FILE), 2);
120 #undef ASM_OUTPUT_CASE_LABEL
121 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE) \
123 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
124 ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \
127 /* The standard SVR4 assembler seems to require that certain builtin
128 library routines (e.g. .udiv) be explicitly declared as .globl
129 in each assembly file where they are referenced. */
131 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
132 ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
134 /* This says how to output assembler code to declare an
135 uninitialized external linkage data object. Under SVR4,
136 the linker seems to want the alignment of data objects
137 to depend on their types. We do exactly that here. */
139 #define COMMON_ASM_OP ".comm"
141 #undef ASM_OUTPUT_ALIGNED_COMMON
142 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
144 fprintf ((FILE), "\t%s\t", COMMON_ASM_OP); \
145 assemble_name ((FILE), (NAME)); \
146 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
149 /* This says how to output assembler code to declare an
150 uninitialized internal linkage data object. Under SVR4,
151 the linker seems to want the alignment of data objects
152 to depend on their types. We do exactly that here. */
154 #define LOCAL_ASM_OP ".local"
156 #undef ASM_OUTPUT_ALIGNED_LOCAL
157 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
159 fprintf ((FILE), "\t%s\t", LOCAL_ASM_OP); \
160 assemble_name ((FILE), (NAME)); \
161 fprintf ((FILE), "\n"); \
162 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
165 /* This is the pseudo-op used to generate a 32-bit word of data with a
166 specific value in some section. This is the same for all known svr4
169 #define INT_ASM_OP ".long"
171 /* This is the pseudo-op used to generate a contiguous sequence of byte
172 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
173 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
175 #undef ASCII_DATA_ASM_OP
176 #define ASCII_DATA_ASM_OP ".ascii"
178 /* Support const sections and the ctors and dtors sections for g++.
179 Note that there appears to be two different ways to support const
180 sections at the moment. You can either #define the symbol
181 READONLY_DATA_SECTION (giving it some code which switches to the
182 readonly data section) or else you can #define the symbols
183 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
184 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
186 #define USE_CONST_SECTION 1
188 #define CONST_SECTION_ASM_OP ".section\t.rodata"
190 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
192 Note that we want to give these sections the SHF_WRITE attribute
193 because these sections will actually contain data (i.e. tables of
194 addresses of functions in the current root executable or shared library
195 file) and, in the case of a shared library, the relocatable addresses
196 will have to be properly resolved/relocated (and then written into) by
197 the dynamic linker when it actually attaches the given shared library
198 to the executing process. (Note that on SVR4, you may wish to use the
199 `-z text' option to the ELF linker, when building a shared library, as
200 an additional check that you are doing everything right. But if you do
201 use the `-z text' option when building a shared library, you will get
202 errors unless the .ctors and .dtors sections are marked as writable
203 via the SHF_WRITE attribute.) */
205 #define CTORS_SECTION_ASM_OP ".section\t.ctors,\"aw\""
206 #define DTORS_SECTION_ASM_OP ".section\t.dtors,\"aw\""
208 /* On svr4, we *do* have support for the .init and .fini sections, and we
209 can put stuff in there to be executed before and after `main'. We let
210 crtstuff.c and other files know this by defining the following symbols.
211 The definitions say how to change sections to the .init and .fini
212 sections. This is the same for all known svr4 assemblers. */
214 #define INIT_SECTION_ASM_OP ".section\t.init"
215 #define FINI_SECTION_ASM_OP ".section\t.fini"
217 /* A default list of other sections which we might be "in" at any given
218 time. For targets that use additional sections (e.g. .tdesc) you
219 should override this definition in the target-specific file which
220 includes this file. */
222 #undef EXTRA_SECTIONS
223 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors
225 /* A default list of extra section function definitions. For targets
226 that use additional sections (e.g. .tdesc) you should override this
227 definition in the target-specific file which includes this file. */
229 #undef EXTRA_SECTION_FUNCTIONS
230 #define EXTRA_SECTION_FUNCTIONS \
231 CONST_SECTION_FUNCTION \
232 CTORS_SECTION_FUNCTION \
233 DTORS_SECTION_FUNCTION
235 #undef READONLY_DATA_SECTION
236 #define READONLY_DATA_SECTION() const_section ()
238 extern void text_section ();
240 #define CONST_SECTION_FUNCTION \
244 if (!USE_CONST_SECTION) \
246 else if (in_section != in_const) \
248 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
249 in_section = in_const; \
253 #define CTORS_SECTION_FUNCTION \
257 if (in_section != in_ctors) \
259 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
260 in_section = in_ctors; \
264 #define DTORS_SECTION_FUNCTION \
268 if (in_section != in_dtors) \
270 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
271 in_section = in_dtors; \
275 /* Switch into a generic section.
276 This is currently only used to support section attributes.
278 We make the section read-only and executable for a function decl,
279 read-only for a const data decl, and writable for a non-const data decl. */
280 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
281 fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
282 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
283 (DECL) && TREE_READONLY (DECL) ? "a" : "aw")
286 /* A C statement (sans semicolon) to output an element in the table of
287 global constructors. */
288 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
291 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
292 assemble_name (FILE, NAME); \
293 fprintf (FILE, "\n"); \
296 /* A C statement (sans semicolon) to output an element in the table of
297 global destructors. */
298 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
301 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
302 assemble_name (FILE, NAME); \
303 fprintf (FILE, "\n"); \
306 /* A C statement or statements to switch to the appropriate
307 section for output of DECL. DECL is either a `VAR_DECL' node
308 or a constant of some sort. RELOC indicates whether forming
309 the initial value of DECL requires link-time relocations. */
311 #define SELECT_SECTION(DECL,RELOC) \
313 if (TREE_CODE (DECL) == STRING_CST) \
315 if (! flag_writable_strings) \
320 else if (TREE_CODE (DECL) == VAR_DECL) \
322 if ((flag_pic && RELOC) \
323 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
324 || !DECL_INITIAL (DECL) \
325 || (DECL_INITIAL (DECL) != error_mark_node \
326 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
335 /* A C statement or statements to switch to the appropriate
336 section for output of RTX in mode MODE. RTX is some kind
337 of constant in RTL. The argument MODE is redundant except
338 in the case of a `const_int' rtx. Currently, these always
339 go into the const section. */
341 #undef SELECT_RTX_SECTION
342 #define SELECT_RTX_SECTION(MODE,RTX) const_section()
344 /* Define the strings used for the special svr4 .type and .size directives.
345 These strings generally do not vary from one system running svr4 to
346 another, but if a given system (e.g. m88k running svr) needs to use
347 different pseudo-op names for these, they may be overridden in the
348 file which includes this one. */
350 #define TYPE_ASM_OP ".type"
351 #define SIZE_ASM_OP ".size"
353 /* This is how we tell the assembler that a symbol is weak. */
355 #define ASM_WEAKEN_LABEL(FILE,NAME) \
356 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
357 fputc ('\n', FILE); } while (0)
359 /* This is how we tell the assembler that two symbols have the same value. */
361 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
362 do { assemble_name(FILE, NAME1); \
363 fputs(" = ", FILE); \
364 assemble_name(FILE, NAME2); \
365 fputc('\n', FILE); } while (0)
367 /* The following macro defines the format used to output the second
368 operand of the .type assembler directive. Different svr4 assemblers
369 expect various different forms for this operand. The one given here
370 is just a default. You may need to override it in your machine-
371 specific tm.h file (depending upon the particulars of your assembler). */
373 #define TYPE_OPERAND_FMT "@%s"
375 /* Write the extra assembler code needed to declare a function's result.
376 Most svr4 assemblers don't require any special declaration of the
377 result value, but there are exceptions. */
379 #ifndef ASM_DECLARE_RESULT
380 #define ASM_DECLARE_RESULT(FILE, RESULT)
383 /* These macros generate the special .type and .size directives which
384 are used to set the corresponding fields of the linker symbol table
385 entries in an ELF object file under SVR4. These macros also output
386 the starting labels for the relevant functions/objects. */
388 /* Write the extra assembler code needed to declare an object properly. */
390 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
392 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
393 assemble_name (FILE, NAME); \
395 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
397 size_directive_output = 0; \
398 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
400 size_directive_output = 1; \
401 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
402 assemble_name (FILE, NAME); \
403 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
405 ASM_OUTPUT_LABEL(FILE, NAME); \
408 /* Output the size directive for a decl in rest_of_decl_compilation
409 in the case where we did not do so before the initializer.
410 Once we find the error_mark_node, we know that the value of
411 size_directive_output was set
412 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
414 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
416 char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
417 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
418 && ! AT_END && TOP_LEVEL \
419 && DECL_INITIAL (DECL) == error_mark_node \
420 && !size_directive_output) \
422 size_directive_output = 1; \
423 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
424 assemble_name (FILE, name); \
425 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
429 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
430 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
431 corresponds to a particular byte value [0..255]. For any
432 given byte value, if the value in the corresponding table
433 position is zero, the given character can be output directly.
434 If the table value is 1, the byte must be output as a \ooo
435 octal escape. If the tables value is anything else, then the
436 byte value should be output as a \ followed by the value
437 in the table. Note that we can use standard UN*X escape
438 sequences for many control characters, but we don't use
439 \a to represent BEL because some svr4 assemblers (e.g. on
440 the i386) don't know about that. Also, we don't use \v
441 since some versions of gas, such as 2.2 did not accept it. */
444 "\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\
445 \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\
446 \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\
447 \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\
448 \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\
449 \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\
450 \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\
451 \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"
453 /* Some svr4 assemblers have a limit on the number of characters which
454 can appear in the operand of a .string directive. If your assembler
455 has such a limitation, you should define STRING_LIMIT to reflect that
456 limit. Note that at least some svr4 assemblers have a limit on the
457 actual number of bytes in the double-quoted string, and that they
458 count each character in an escape sequence as one byte. Thus, an
459 escape sequence like \377 would count as four bytes.
461 If your target assembler doesn't support the .string directive, you
462 should define this to zero.
465 #define STRING_LIMIT ((unsigned) 256)
467 #define STRING_ASM_OP ".string"
470 * We always use gas here, so we don't worry about ECOFF assembler problems.
473 #define TARGET_GAS (1)
475 #undef PREFERRED_DEBUGGING_TYPE
476 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
478 /* Provide a STARTFILE_SPEC appropriate for Linux. Here we add
479 the Linux magical crtbegin.o file (see crtstuff.c) which
480 provides part of the support for getting C++ file-scope static
481 object constructed before entering `main'. */
483 #undef STARTFILE_SPEC
484 #define STARTFILE_SPEC \
486 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
487 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
489 /* Provide a ENDFILE_SPEC appropriate for Linux. Here we tack on
490 the Linux magical crtend.o file (see crtstuff.c) which
491 provides part of the support for getting C++ file-scope static
492 object constructed before entering `main', followed by a normal
493 Linux "finalizer" file, `crtn.o'. */
496 #define ENDFILE_SPEC \
497 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"