1 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
2 Copyright (C) 1996, 1997 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 elf64alpha -G 8 %{O*:-O3} %{!O*:-O1} \
46 %{rdynamic:-export-dynamic} \
47 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
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 64-bit word of data with a
166 specific value in some section. */
168 #define INT_ASM_OP ".quad"
170 /* This is the pseudo-op used to generate a contiguous sequence of byte
171 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
172 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
174 #undef ASCII_DATA_ASM_OP
175 #define ASCII_DATA_ASM_OP ".ascii"
177 /* Support const sections and the ctors and dtors sections for g++.
178 Note that there appears to be two different ways to support const
179 sections at the moment. You can either #define the symbol
180 READONLY_DATA_SECTION (giving it some code which switches to the
181 readonly data section) or else you can #define the symbols
182 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
183 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
185 #define USE_CONST_SECTION 1
187 #define CONST_SECTION_ASM_OP ".section\t.rodata"
189 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
191 Note that we want to give these sections the SHF_WRITE attribute
192 because these sections will actually contain data (i.e. tables of
193 addresses of functions in the current root executable or shared library
194 file) and, in the case of a shared library, the relocatable addresses
195 will have to be properly resolved/relocated (and then written into) by
196 the dynamic linker when it actually attaches the given shared library
197 to the executing process. (Note that on SVR4, you may wish to use the
198 `-z text' option to the ELF linker, when building a shared library, as
199 an additional check that you are doing everything right. But if you do
200 use the `-z text' option when building a shared library, you will get
201 errors unless the .ctors and .dtors sections are marked as writable
202 via the SHF_WRITE attribute.) */
204 #define CTORS_SECTION_ASM_OP ".section\t.ctors,\"aw\""
205 #define DTORS_SECTION_ASM_OP ".section\t.dtors,\"aw\""
207 /* On svr4, we *do* have support for the .init and .fini sections, and we
208 can put stuff in there to be executed before and after `main'. We let
209 crtstuff.c and other files know this by defining the following symbols.
210 The definitions say how to change sections to the .init and .fini
211 sections. This is the same for all known svr4 assemblers. */
213 #define INIT_SECTION_ASM_OP ".section\t.init"
214 #define FINI_SECTION_ASM_OP ".section\t.fini"
216 /* A default list of other sections which we might be "in" at any given
217 time. For targets that use additional sections (e.g. .tdesc) you
218 should override this definition in the target-specific file which
219 includes this file. */
221 #undef EXTRA_SECTIONS
222 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors
224 /* A default list of extra section function definitions. For targets
225 that use additional sections (e.g. .tdesc) you should override this
226 definition in the target-specific file which includes this file. */
228 #undef EXTRA_SECTION_FUNCTIONS
229 #define EXTRA_SECTION_FUNCTIONS \
230 CONST_SECTION_FUNCTION \
231 CTORS_SECTION_FUNCTION \
232 DTORS_SECTION_FUNCTION
234 #undef READONLY_DATA_SECTION
235 #define READONLY_DATA_SECTION() const_section ()
237 extern void text_section ();
239 #define CONST_SECTION_FUNCTION \
243 if (!USE_CONST_SECTION) \
245 else if (in_section != in_const) \
247 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
248 in_section = in_const; \
252 #define CTORS_SECTION_FUNCTION \
256 if (in_section != in_ctors) \
258 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
259 in_section = in_ctors; \
263 #define DTORS_SECTION_FUNCTION \
267 if (in_section != in_dtors) \
269 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
270 in_section = in_dtors; \
274 /* Switch into a generic section.
275 This is currently only used to support section attributes.
277 We make the section read-only and executable for a function decl,
278 read-only for a const data decl, and writable for a non-const data decl. */
279 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
280 fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
281 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
282 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
285 /* A C statement (sans semicolon) to output an element in the table of
286 global constructors. */
287 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
290 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
291 assemble_name (FILE, NAME); \
292 fprintf (FILE, "\n"); \
295 /* A C statement (sans semicolon) to output an element in the table of
296 global destructors. */
297 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
300 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
301 assemble_name (FILE, NAME); \
302 fprintf (FILE, "\n"); \
305 /* A C statement or statements to switch to the appropriate
306 section for output of DECL. DECL is either a `VAR_DECL' node
307 or a constant of some sort. RELOC indicates whether forming
308 the initial value of DECL requires link-time relocations. */
310 #define SELECT_SECTION(DECL,RELOC) \
312 if (TREE_CODE (DECL) == STRING_CST) \
314 if (! flag_writable_strings) \
319 else if (TREE_CODE (DECL) == VAR_DECL) \
321 if ((flag_pic && RELOC) \
322 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
323 || !DECL_INITIAL (DECL) \
324 || (DECL_INITIAL (DECL) != error_mark_node \
325 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
334 /* A C statement or statements to switch to the appropriate
335 section for output of RTX in mode MODE. RTX is some kind
336 of constant in RTL. The argument MODE is redundant except
337 in the case of a `const_int' rtx. Currently, these always
338 go into the const section. */
340 #undef SELECT_RTX_SECTION
341 #define SELECT_RTX_SECTION(MODE,RTX) const_section()
343 /* Define the strings used for the special svr4 .type and .size directives.
344 These strings generally do not vary from one system running svr4 to
345 another, but if a given system (e.g. m88k running svr) needs to use
346 different pseudo-op names for these, they may be overridden in the
347 file which includes this one. */
349 #define TYPE_ASM_OP ".type"
350 #define SIZE_ASM_OP ".size"
352 /* This is how we tell the assembler that a symbol is weak. */
354 #define ASM_WEAKEN_LABEL(FILE,NAME) \
355 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
356 fputc ('\n', FILE); } while (0)
358 /* This is how we tell the assembler that two symbols have the same value. */
360 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
361 do { assemble_name(FILE, NAME1); \
362 fputs(" = ", FILE); \
363 assemble_name(FILE, NAME2); \
364 fputc('\n', FILE); } while (0)
366 /* The following macro defines the format used to output the second
367 operand of the .type assembler directive. Different svr4 assemblers
368 expect various different forms for this operand. The one given here
369 is just a default. You may need to override it in your machine-
370 specific tm.h file (depending upon the particulars of your assembler). */
372 #define TYPE_OPERAND_FMT "@%s"
374 /* Write the extra assembler code needed to declare a function's result.
375 Most svr4 assemblers don't require any special declaration of the
376 result value, but there are exceptions. */
378 #ifndef ASM_DECLARE_RESULT
379 #define ASM_DECLARE_RESULT(FILE, RESULT)
382 /* These macros generate the special .type and .size directives which
383 are used to set the corresponding fields of the linker symbol table
384 entries in an ELF object file under SVR4. These macros also output
385 the starting labels for the relevant functions/objects. */
387 /* Write the extra assembler code needed to declare an object properly. */
389 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
391 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
392 assemble_name (FILE, NAME); \
394 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
396 size_directive_output = 0; \
397 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
399 size_directive_output = 1; \
400 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
401 assemble_name (FILE, NAME); \
402 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
404 ASM_OUTPUT_LABEL(FILE, NAME); \
407 /* Output the size directive for a decl in rest_of_decl_compilation
408 in the case where we did not do so before the initializer.
409 Once we find the error_mark_node, we know that the value of
410 size_directive_output was set
411 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
413 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
415 char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
416 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
417 && ! AT_END && TOP_LEVEL \
418 && DECL_INITIAL (DECL) == error_mark_node \
419 && !size_directive_output) \
421 size_directive_output = 1; \
422 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
423 assemble_name (FILE, name); \
424 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
428 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
429 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
430 corresponds to a particular byte value [0..255]. For any
431 given byte value, if the value in the corresponding table
432 position is zero, the given character can be output directly.
433 If the table value is 1, the byte must be output as a \ooo
434 octal escape. If the tables value is anything else, then the
435 byte value should be output as a \ followed by the value
436 in the table. Note that we can use standard UN*X escape
437 sequences for many control characters, but we don't use
438 \a to represent BEL because some svr4 assemblers (e.g. on
439 the i386) don't know about that. Also, we don't use \v
440 since some versions of gas, such as 2.2 did not accept it. */
443 "\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\
444 \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\
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\1\
447 \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\
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"
452 /* Some svr4 assemblers have a limit on the number of characters which
453 can appear in the operand of a .string directive. If your assembler
454 has such a limitation, you should define STRING_LIMIT to reflect that
455 limit. Note that at least some svr4 assemblers have a limit on the
456 actual number of bytes in the double-quoted string, and that they
457 count each character in an escape sequence as one byte. Thus, an
458 escape sequence like \377 would count as four bytes.
460 If your target assembler doesn't support the .string directive, you
461 should define this to zero.
464 #define STRING_LIMIT ((unsigned) 256)
466 #define STRING_ASM_OP ".string"
469 * We always use gas here, so we don't worry about ECOFF assembler problems.
472 #define TARGET_GAS (1)
474 #undef PREFERRED_DEBUGGING_TYPE
475 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
477 /* Provide a STARTFILE_SPEC appropriate for Linux. Here we add
478 the Linux magical crtbegin.o file (see crtstuff.c) which
479 provides part of the support for getting C++ file-scope static
480 object constructed before entering `main'. */
482 #undef STARTFILE_SPEC
483 #define STARTFILE_SPEC \
485 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
486 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
488 /* Provide a ENDFILE_SPEC appropriate for Linux. Here we tack on
489 the Linux magical crtend.o file (see crtstuff.c) which
490 provides part of the support for getting C++ file-scope static
491 object constructed before entering `main', followed by a normal
492 Linux "finalizer" file, `crtn.o'. */
495 #define ENDFILE_SPEC \
496 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"