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__"
43 #define LINK_SPEC "-m elf64alpha -G 8 %{O*:-O3} %{!O*:-O1} \
47 %{rdynamic:-export-dynamic} \
48 %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
51 #define LINK_SPEC "-m elf64alpha -G 8 %{O*:-O3} %{!O*:-O1} \
55 %{rdynamic:-export-dynamic} \
56 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
60 /* Output at beginning of assembler file. */
63 #define ASM_FILE_START(FILE) \
65 alpha_write_verstamp (FILE); \
66 output_file_directive (FILE, main_input_filename); \
67 fprintf (FILE, "\t.version\t\"01.01\"\n"); \
68 fprintf (FILE, "\t.set noat\n"); \
71 #define ASM_OUTPUT_SOURCE_LINE(STREAM, LINE) \
72 alpha_output_lineno (STREAM, LINE)
73 extern void alpha_output_lineno ();
75 extern void output_file_directive ();
77 /* Attach a special .ident directive to the end of the file to identify
78 the version of GCC which compiled this code. The format of the
79 .ident string is patterned after the ones produced by native svr4
82 #define IDENT_ASM_OP ".ident"
84 #ifdef IDENTIFY_WITH_IDENT
85 #define ASM_IDENTIFY_GCC(FILE) /* nothing */
86 #define ASM_IDENTIFY_LANGUAGE(FILE) \
87 fprintf(FILE, "\t%s \"GCC (%s) %s\"\n", IDENT_ASM_OP, \
88 lang_identify(), version_string)
90 #define ASM_FILE_END(FILE) \
92 fprintf ((FILE), "\t%s\t\"GCC: (GNU) %s\"\n", \
93 IDENT_ASM_OP, version_string); \
97 /* Allow #sccs in preprocessor. */
99 #define SCCS_DIRECTIVE
101 /* Output #ident as a .ident. */
103 #define ASM_OUTPUT_IDENT(FILE, NAME) \
104 fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
106 /* This is how to allocate empty space in some section. The .zero
107 pseudo-op is used for this on most svr4 assemblers. */
109 #define SKIP_ASM_OP ".zero"
111 #undef ASM_OUTPUT_SKIP
112 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
113 fprintf (FILE, "\t%s\t%u\n", SKIP_ASM_OP, (SIZE))
115 /* Output the label which precedes a jumptable. Note that for all svr4
116 systems where we actually generate jumptables (which is to say every
117 svr4 target except i386, where we use casesi instead) we put the jump-
118 tables into the .rodata section and since other stuff could have been
119 put into the .rodata section prior to any given jumptable, we have to
120 make sure that the location counter for the .rodata section gets pro-
121 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 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
142 ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
144 /* This says how to output assembler code to declare an
145 uninitialized external linkage data object. Under SVR4,
146 the linker seems to want the alignment of data objects
147 to depend on their types. We do exactly that here. */
149 #define COMMON_ASM_OP ".comm"
151 #undef ASM_OUTPUT_ALIGNED_COMMON
152 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
154 fprintf ((FILE), "\t%s\t", COMMON_ASM_OP); \
155 assemble_name ((FILE), (NAME)); \
156 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
159 /* This says how to output assembler code to declare an
160 uninitialized internal linkage data object. Under SVR4,
161 the linker seems to want the alignment of data objects
162 to depend on their types. We do exactly that here. */
164 #define LOCAL_ASM_OP ".local"
166 #undef ASM_OUTPUT_ALIGNED_LOCAL
167 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
169 fprintf ((FILE), "\t%s\t", LOCAL_ASM_OP); \
170 assemble_name ((FILE), (NAME)); \
171 fprintf ((FILE), "\n"); \
172 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
175 /* This is the pseudo-op used to generate a 64-bit word of data with a
176 specific value in some section. */
178 #define INT_ASM_OP ".quad"
180 /* This is the pseudo-op used to generate a contiguous sequence of byte
181 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
182 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
184 #undef ASCII_DATA_ASM_OP
185 #define ASCII_DATA_ASM_OP ".ascii"
187 /* Support const sections and the ctors and dtors sections for g++.
188 Note that there appears to be two different ways to support const
189 sections at the moment. You can either #define the symbol
190 READONLY_DATA_SECTION (giving it some code which switches to the
191 readonly data section) or else you can #define the symbols
192 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
193 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
195 #define USE_CONST_SECTION 1
197 #define CONST_SECTION_ASM_OP ".section\t.rodata"
199 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
201 Note that we want to give these sections the SHF_WRITE attribute
202 because these sections will actually contain data (i.e. tables of
203 addresses of functions in the current root executable or shared library
204 file) and, in the case of a shared library, the relocatable addresses
205 will have to be properly resolved/relocated (and then written into) by
206 the dynamic linker when it actually attaches the given shared library
207 to the executing process. (Note that on SVR4, you may wish to use the
208 `-z text' option to the ELF linker, when building a shared library, as
209 an additional check that you are doing everything right. But if you do
210 use the `-z text' option when building a shared library, you will get
211 errors unless the .ctors and .dtors sections are marked as writable
212 via the SHF_WRITE attribute.) */
214 #define CTORS_SECTION_ASM_OP ".section\t.ctors,\"aw\""
215 #define DTORS_SECTION_ASM_OP ".section\t.dtors,\"aw\""
217 /* On svr4, we *do* have support for the .init and .fini sections, and we
218 can put stuff in there to be executed before and after `main'. We let
219 crtstuff.c and other files know this by defining the following symbols.
220 The definitions say how to change sections to the .init and .fini
221 sections. This is the same for all known svr4 assemblers. */
223 #define INIT_SECTION_ASM_OP ".section\t.init"
224 #define FINI_SECTION_ASM_OP ".section\t.fini"
226 /* A default list of other sections which we might be "in" at any given
227 time. For targets that use additional sections (e.g. .tdesc) you
228 should override this definition in the target-specific file which
229 includes this file. */
231 #undef EXTRA_SECTIONS
232 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors
234 /* A default list of extra section function definitions. For targets
235 that use additional sections (e.g. .tdesc) you should override this
236 definition in the target-specific file which includes this file. */
238 #undef EXTRA_SECTION_FUNCTIONS
239 #define EXTRA_SECTION_FUNCTIONS \
240 CONST_SECTION_FUNCTION \
241 CTORS_SECTION_FUNCTION \
242 DTORS_SECTION_FUNCTION
244 #undef READONLY_DATA_SECTION
245 #define READONLY_DATA_SECTION() const_section ()
247 extern void text_section ();
249 #define CONST_SECTION_FUNCTION \
253 if (!USE_CONST_SECTION) \
255 else if (in_section != in_const) \
257 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
258 in_section = in_const; \
262 #define CTORS_SECTION_FUNCTION \
266 if (in_section != in_ctors) \
268 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
269 in_section = in_ctors; \
273 #define DTORS_SECTION_FUNCTION \
277 if (in_section != in_dtors) \
279 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
280 in_section = in_dtors; \
284 /* Switch into a generic section.
285 This is currently only used to support section attributes.
287 We make the section read-only and executable for a function decl,
288 read-only for a const data decl, and writable for a non-const data decl. */
289 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
290 fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
291 (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
292 (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
295 /* A C statement (sans semicolon) to output an element in the table of
296 global constructors. */
297 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
300 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
301 assemble_name (FILE, NAME); \
302 fprintf (FILE, "\n"); \
305 /* A C statement (sans semicolon) to output an element in the table of
306 global destructors. */
307 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
310 fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
311 assemble_name (FILE, NAME); \
312 fprintf (FILE, "\n"); \
315 /* A C statement or statements to switch to the appropriate
316 section for output of DECL. DECL is either a `VAR_DECL' node
317 or a constant of some sort. RELOC indicates whether forming
318 the initial value of DECL requires link-time relocations. */
320 #define SELECT_SECTION(DECL,RELOC) \
322 if (TREE_CODE (DECL) == STRING_CST) \
324 if (! flag_writable_strings) \
329 else if (TREE_CODE (DECL) == VAR_DECL) \
331 if ((flag_pic && RELOC) \
332 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
333 || !DECL_INITIAL (DECL) \
334 || (DECL_INITIAL (DECL) != error_mark_node \
335 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
344 /* A C statement or statements to switch to the appropriate
345 section for output of RTX in mode MODE. RTX is some kind
346 of constant in RTL. The argument MODE is redundant except
347 in the case of a `const_int' rtx. Currently, these always
348 go into the const section. */
350 #undef SELECT_RTX_SECTION
351 #define SELECT_RTX_SECTION(MODE,RTX) const_section()
353 /* Define the strings used for the special svr4 .type and .size directives.
354 These strings generally do not vary from one system running svr4 to
355 another, but if a given system (e.g. m88k running svr) needs to use
356 different pseudo-op names for these, they may be overridden in the
357 file which includes this one. */
359 #define TYPE_ASM_OP ".type"
360 #define SIZE_ASM_OP ".size"
362 /* This is how we tell the assembler that a symbol is weak. */
364 #define ASM_WEAKEN_LABEL(FILE,NAME) \
365 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
366 fputc ('\n', FILE); } while (0)
368 /* This is how we tell the assembler that two symbols have the same value. */
370 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
371 do { assemble_name(FILE, NAME1); \
372 fputs(" = ", FILE); \
373 assemble_name(FILE, NAME2); \
374 fputc('\n', FILE); } while (0)
376 /* The following macro defines the format used to output the second
377 operand of the .type assembler directive. Different svr4 assemblers
378 expect various different forms for this operand. The one given here
379 is just a default. You may need to override it in your machine-
380 specific tm.h file (depending upon the particulars of your assembler). */
382 #define TYPE_OPERAND_FMT "@%s"
384 /* Write the extra assembler code needed to declare a function's result.
385 Most svr4 assemblers don't require any special declaration of the
386 result value, but there are exceptions. */
388 #ifndef ASM_DECLARE_RESULT
389 #define ASM_DECLARE_RESULT(FILE, RESULT)
392 /* These macros generate the special .type and .size directives which
393 are used to set the corresponding fields of the linker symbol table
394 entries in an ELF object file under SVR4. These macros also output
395 the starting labels for the relevant functions/objects. */
397 /* Write the extra assembler code needed to declare an object properly. */
399 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
401 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
402 assemble_name (FILE, NAME); \
404 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
406 size_directive_output = 0; \
407 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
409 size_directive_output = 1; \
410 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
411 assemble_name (FILE, NAME); \
412 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
414 ASM_OUTPUT_LABEL(FILE, NAME); \
417 /* Output the size directive for a decl in rest_of_decl_compilation
418 in the case where we did not do so before the initializer.
419 Once we find the error_mark_node, we know that the value of
420 size_directive_output was set
421 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
423 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
425 char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
426 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
427 && ! AT_END && TOP_LEVEL \
428 && DECL_INITIAL (DECL) == error_mark_node \
429 && !size_directive_output) \
431 size_directive_output = 1; \
432 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
433 assemble_name (FILE, name); \
434 fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
438 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
439 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
440 corresponds to a particular byte value [0..255]. For any
441 given byte value, if the value in the corresponding table
442 position is zero, the given character can be output directly.
443 If the table value is 1, the byte must be output as a \ooo
444 octal escape. If the tables value is anything else, then the
445 byte value should be output as a \ followed by the value
446 in the table. Note that we can use standard UN*X escape
447 sequences for many control characters, but we don't use
448 \a to represent BEL because some svr4 assemblers (e.g. on
449 the i386) don't know about that. Also, we don't use \v
450 since some versions of gas, such as 2.2 did not accept it. */
453 "\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\
454 \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\
455 \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\
456 \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\
457 \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\
458 \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\
459 \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\
460 \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"
462 /* Some svr4 assemblers have a limit on the number of characters which
463 can appear in the operand of a .string directive. If your assembler
464 has such a limitation, you should define STRING_LIMIT to reflect that
465 limit. Note that at least some svr4 assemblers have a limit on the
466 actual number of bytes in the double-quoted string, and that they
467 count each character in an escape sequence as one byte. Thus, an
468 escape sequence like \377 would count as four bytes.
470 If your target assembler doesn't support the .string directive, you
471 should define this to zero.
474 #define STRING_LIMIT ((unsigned) 256)
476 #define STRING_ASM_OP ".string"
479 * We always use gas here, so we don't worry about ECOFF assembler problems.
482 #define TARGET_GAS (1)
484 #undef PREFERRED_DEBUGGING_TYPE
485 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
487 /* Provide a STARTFILE_SPEC appropriate for Linux. Here we add
488 the Linux magical crtbegin.o file (see crtstuff.c) which
489 provides part of the support for getting C++ file-scope static
490 object constructed before entering `main'. */
492 #undef STARTFILE_SPEC
493 #define STARTFILE_SPEC \
495 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
496 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
498 /* Provide a ENDFILE_SPEC appropriate for Linux. Here we tack on
499 the Linux magical crtend.o file (see crtstuff.c) which
500 provides part of the support for getting C++ file-scope static
501 object constructed before entering `main', followed by a normal
502 Linux "finalizer" file, `crtn.o'. */
505 #define ENDFILE_SPEC \
506 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"