1 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2007, 2008,
3 2009, 2010, 2012 Free Software Foundation, Inc.
4 Contributed by Richard Henderson (rth@tamu.edu).
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #define OBJECT_FORMAT_ELF
24 #define DWARF2_DEBUGGING_INFO 1
26 #undef PREFERRED_DEBUGGING_TYPE
27 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
31 /* alpha/ doesn't use elfos.h for some reason. */
32 #define TARGET_OBJFMT_CPP_BUILTINS() \
35 builtin_define ("__ELF__"); \
40 #define CC1_SPEC "%{G*}"
43 #define ASM_SPEC "%{G*} %{relax:-relax} %{!gstabs*:-no-mdebug}%{gstabs*:-mdebug}"
46 #define IDENT_ASM_OP "\t.ident\t"
48 /* Output #ident as a .ident. */
49 #undef ASM_OUTPUT_IDENT
50 #define ASM_OUTPUT_IDENT(FILE, NAME) \
51 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
53 /* This is how to allocate empty space in some section. The .zero
54 pseudo-op is used for this on most svr4 assemblers. */
57 #define SKIP_ASM_OP "\t.zero\t"
59 #undef ASM_OUTPUT_SKIP
60 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
61 fprintf (FILE, "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n", SKIP_ASM_OP, (SIZE))
63 /* Output the label which precedes a jumptable. Note that for all svr4
64 systems where we actually generate jumptables (which is to say every
65 svr4 target except i386, where we use casesi instead) we put the jump-
66 tables into the .rodata section and since other stuff could have been
67 put into the .rodata section prior to any given jumptable, we have to
68 make sure that the location counter for the .rodata section gets pro-
69 perly re-aligned prior to the actual beginning of the jump table. */
72 #define ALIGN_ASM_OP "\t.align\t"
74 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
75 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
76 ASM_OUTPUT_ALIGN ((FILE), 2);
79 #undef ASM_OUTPUT_CASE_LABEL
80 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
82 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
83 (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \
86 /* The standard SVR4 assembler seems to require that certain builtin
87 library routines (e.g. .udiv) be explicitly declared as .globl
88 in each assembly file where they are referenced. */
90 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
91 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
92 (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0))
94 /* This says how to output assembler code to declare an
95 uninitialized external linkage data object. Under SVR4,
96 the linker seems to want the alignment of data objects
97 to depend on their types. We do exactly that here. */
100 #define COMMON_ASM_OP "\t.comm\t"
102 #undef ASM_OUTPUT_ALIGNED_COMMON
103 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
105 fprintf ((FILE), "%s", COMMON_ASM_OP); \
106 assemble_name ((FILE), (NAME)); \
107 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED ",%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
110 /* This says how to output assembler code to declare an
111 uninitialized internal linkage data object. Under SVR4,
112 the linker seems to want the alignment of data objects
113 to depend on their types. We do exactly that here. */
115 #undef ASM_OUTPUT_ALIGNED_LOCAL
116 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
118 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
119 switch_to_section (sbss_section); \
121 switch_to_section (bss_section); \
122 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
123 if (!flag_inhibit_size_directive) \
124 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
125 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
126 ASM_OUTPUT_LABEL(FILE, NAME); \
127 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
130 /* This says how to output assembler code to declare an
131 uninitialized external linkage data object. */
133 #undef ASM_OUTPUT_ALIGNED_BSS
134 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
136 ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
139 /* The biggest alignment supported by ELF in bits. 32-bit ELF
140 supports section alignment up to (0x80000000 * 8), while
141 64-bit ELF supports (0x8000000000000000 * 8). If this macro
142 is not defined, the default is the largest alignment supported
143 by 32-bit ELF and representable on a 32-bit host. Use this
144 macro to limit the alignment which can be specified using
145 the `__attribute__ ((aligned (N)))' construct.
147 This value is really 2^63. Since gcc figures the alignment in bits,
148 we could only potentially get to 2^60 on suitable hosts. Due to other
149 considerations in varasm, we must restrict this to what fits in an int. */
151 #undef MAX_OFILE_ALIGNMENT
152 #define MAX_OFILE_ALIGNMENT (((unsigned int) 1 << 28) * 8)
154 /* This is the pseudo-op used to generate a contiguous sequence of byte
155 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
156 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
158 #undef ASCII_DATA_ASM_OP
159 #define ASCII_DATA_ASM_OP "\t.ascii\t"
161 #undef READONLY_DATA_SECTION_ASM_OP
162 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
163 #undef BSS_SECTION_ASM_OP
164 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
165 #undef SBSS_SECTION_ASM_OP
166 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
167 #undef SDATA_SECTION_ASM_OP
168 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
170 /* On svr4, we *do* have support for the .init and .fini sections, and we
171 can put stuff in there to be executed before and after `main'. We let
172 crtstuff.c and other files know this by defining the following symbols.
173 The definitions say how to change sections to the .init and .fini
174 sections. This is the same for all known svr4 assemblers. */
176 #undef INIT_SECTION_ASM_OP
177 #define INIT_SECTION_ASM_OP "\t.section\t.init"
178 #undef FINI_SECTION_ASM_OP
179 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
181 #ifdef HAVE_GAS_SUBSECTION_ORDERING
183 #define ASM_SECTION_START_OP "\t.subsection\t-1"
185 /* Output assembly directive to move to the beginning of current section. */
186 #define ASM_OUTPUT_SECTION_START(FILE) \
187 fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
191 /* Switch into a generic section. */
192 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
193 #define TARGET_ASM_SELECT_SECTION default_elf_select_section
195 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
197 /* Define the strings used for the special svr4 .type and .size directives.
198 These strings generally do not vary from one system running svr4 to
199 another, but if a given system (e.g. m88k running svr) needs to use
200 different pseudo-op names for these, they may be overridden in the
201 file which includes this one. */
204 #define TYPE_ASM_OP "\t.type\t"
206 #define SIZE_ASM_OP "\t.size\t"
208 /* This is how we tell the assembler that a symbol is weak. */
210 #undef ASM_WEAKEN_LABEL
211 #define ASM_WEAKEN_LABEL(FILE, NAME) \
212 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
213 fputc ('\n', FILE); } while (0)
215 /* This is how we tell the assembler that two symbols have the same value. */
217 #undef ASM_OUTPUT_DEF
218 #define ASM_OUTPUT_DEF(FILE, ALIAS, NAME) \
220 assemble_name(FILE, ALIAS); \
221 fputs(" = ", FILE); \
222 assemble_name(FILE, NAME); \
226 #undef ASM_OUTPUT_DEF_FROM_DECLS
227 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET) \
229 const char *alias = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
230 const char *name = IDENTIFIER_POINTER (TARGET); \
231 if (TREE_CODE (DECL) == FUNCTION_DECL) \
234 assemble_name (FILE, alias); \
235 fputs ("..ng = $", FILE); \
236 assemble_name (FILE, name); \
237 fputs ("..ng\n", FILE); \
239 assemble_name(FILE, alias); \
240 fputs(" = ", FILE); \
241 assemble_name(FILE, name); \
245 /* The following macro defines the format used to output the second
246 operand of the .type assembler directive. Different svr4 assemblers
247 expect various different forms for this operand. The one given here
248 is just a default. You may need to override it in your machine-
249 specific tm.h file (depending upon the particulars of your assembler). */
251 #undef TYPE_OPERAND_FMT
252 #define TYPE_OPERAND_FMT "@%s"
254 /* Write the extra assembler code needed to declare a function's result.
255 Most svr4 assemblers don't require any special declaration of the
256 result value, but there are exceptions. */
258 #ifndef ASM_DECLARE_RESULT
259 #define ASM_DECLARE_RESULT(FILE, RESULT)
262 /* These macros generate the special .type and .size directives which
263 are used to set the corresponding fields of the linker symbol table
264 entries in an ELF object file under SVR4. These macros also output
265 the starting labels for the relevant functions/objects. */
267 /* Write the extra assembler code needed to declare an object properly. */
269 #ifdef HAVE_GAS_GNU_UNIQUE_OBJECT
270 #define USE_GNU_UNIQUE_OBJECT 1
272 #define USE_GNU_UNIQUE_OBJECT 0
275 #undef ASM_DECLARE_OBJECT_NAME
276 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
278 HOST_WIDE_INT size; \
280 /* For template static data member instantiations or \
281 inline fn local statics and their guard variables, use \
282 gnu_unique_object so that they will be combined even under \
283 RTLD_LOCAL. Don't use gnu_unique_object for typeinfo, \
284 vtables and other read-only artificial decls. */ \
285 if (USE_GNU_UNIQUE_OBJECT && DECL_ONE_ONLY (DECL) \
286 && (!DECL_ARTIFICIAL (DECL) || !TREE_READONLY (DECL))) \
287 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "gnu_unique_object"); \
289 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
291 size_directive_output = 0; \
292 if (!flag_inhibit_size_directive \
293 && (DECL) && DECL_SIZE (DECL)) \
295 size_directive_output = 1; \
296 size = int_size_in_bytes (TREE_TYPE (DECL)); \
297 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
300 ASM_OUTPUT_LABEL (FILE, NAME); \
303 /* Output the size directive for a decl in rest_of_decl_compilation
304 in the case where we did not do so before the initializer.
305 Once we find the error_mark_node, we know that the value of
306 size_directive_output was set
307 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
309 #undef ASM_FINISH_DECLARE_OBJECT
310 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
312 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
313 HOST_WIDE_INT size; \
314 if (!flag_inhibit_size_directive \
315 && DECL_SIZE (DECL) \
316 && ! AT_END && TOP_LEVEL \
317 && DECL_INITIAL (DECL) == error_mark_node \
318 && !size_directive_output \
319 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
321 size_directive_output = 1; \
322 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
326 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
327 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
328 corresponds to a particular byte value [0..255]. For any
329 given byte value, if the value in the corresponding table
330 position is zero, the given character can be output directly.
331 If the table value is 1, the byte must be output as a \ooo
332 octal escape. If the tables value is anything else, then the
333 byte value should be output as a \ followed by the value
334 in the table. Note that we can use standard UN*X escape
335 sequences for many control characters, but we don't use
336 \a to represent BEL because some svr4 assemblers (e.g. on
337 the i386) don't know about that. Also, we don't use \v
338 since some versions of gas, such as 2.2 did not accept it. */
340 #undef ELF_ASCII_ESCAPES
341 #define ELF_ASCII_ESCAPES \
342 "\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\
343 \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\
344 \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\
345 \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\
346 \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\
347 \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\
348 \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\
349 \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"
351 /* Some svr4 assemblers have a limit on the number of characters which
352 can appear in the operand of a .string directive. If your assembler
353 has such a limitation, you should define STRING_LIMIT to reflect that
354 limit. Note that at least some svr4 assemblers have a limit on the
355 actual number of bytes in the double-quoted string, and that they
356 count each character in an escape sequence as one byte. Thus, an
357 escape sequence like \377 would count as four bytes.
359 If your target assembler doesn't support the .string directive, you
360 should define this to zero. */
362 #undef ELF_STRING_LIMIT
363 #define ELF_STRING_LIMIT ((unsigned) 256)
366 #define STRING_ASM_OP "\t.string\t"
368 /* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
369 (even more) magical crtbegin.o file which provides part of the
370 support for getting C++ file-scope static object constructed
371 before entering `main'. */
373 #undef STARTFILE_SPEC
375 #define STARTFILE_SPEC \
376 "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
377 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
379 #define STARTFILE_SPEC \
380 "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
381 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
384 /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
385 magical crtend.o file which provides part of the support for
386 getting C++ file-scope static object constructed before entering
387 `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
390 #define ENDFILE_SPEC \
391 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
392 %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
394 /* Select a format to encode pointers in exception handling data. CODE
395 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
396 true if the symbol may be affected by dynamic relocations.
398 Since application size is already constrained to <2GB by the form of
399 the ldgp relocation, we can use a 32-bit pc-relative relocation to
400 static data. Dynamic data is accessed indirectly to allow for read
402 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
403 (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4)
405 /* If defined, a C statement to be executed just prior to the output of
406 assembler code for INSN. */
407 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
408 (alpha_this_literal_sequence_number = 0, \
409 alpha_this_gpdisp_sequence_number = 0)
410 extern int alpha_this_literal_sequence_number
;
411 extern int alpha_this_gpdisp_sequence_number
;
413 /* Since the bits of the _init and _fini function is spread across
414 many object files, each potentially with its own GP, we must assume
415 we need to load our GP. Further, the .init/.fini section can
416 easily be more than 4MB away from the function to call so we can't
418 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
419 asm (SECTION_OP "\n" \
421 "1: ldgp $29,0($29)\n" \
423 " jsr $26," USER_LABEL_PREFIX #FUNC "\n" \
427 /* If we have the capability create headers for efficient EH lookup.
428 As of Jan 2002, only glibc 2.2.4 can actually make use of this, but
429 I imagine that other systems will catch up. In the meantime, it
430 doesn't harm to make sure that the data exists to be used later. */
431 #if defined(HAVE_LD_EH_FRAME_HDR)
432 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
435 /* A C statement (sans semicolon) to output to the stdio stream STREAM
436 any text necessary for declaring the name of an external symbol
437 named NAME which is referenced in this compilation but not defined.
438 It is needed to properly support non-default visibility. */
440 #ifndef ASM_OUTPUT_EXTERNAL
441 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
442 default_elf_asm_output_external (FILE, DECL, NAME)