PR target/16201
[official-gcc.git] / gcc / config / alpha / elf.h
blob34bba3ecb179335db1a882afc3b760b43de62748
1 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 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 2, or (at your option)
11 any later version.
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 COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #undef OBJECT_FORMAT_COFF
24 #undef EXTENDED_COFF
25 #define OBJECT_FORMAT_ELF
27 /* ??? Move all SDB stuff from alpha.h to osf.h. */
28 #undef SDB_DEBUGGING_INFO
30 #define DBX_DEBUGGING_INFO 1
31 #define DWARF2_DEBUGGING_INFO 1
33 #undef PREFERRED_DEBUGGING_TYPE
34 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
36 #undef ASM_FINAL_SPEC
38 /* alpha/ doesn't use elfos.h for some reason. */
39 #define TARGET_OBJFMT_CPP_BUILTINS() \
40 do \
41 { \
42 builtin_define ("__ELF__"); \
43 } \
44 while (0)
46 #undef CC1_SPEC
47 #define CC1_SPEC "%{G*}"
49 #undef ASM_SPEC
50 #define ASM_SPEC "%{G*} %{relax:-relax} %{!gstabs*:-no-mdebug}%{gstabs*:-mdebug}"
52 #undef IDENT_ASM_OP
53 #define IDENT_ASM_OP "\t.ident\t"
55 /* Output #ident as a .ident. */
56 #undef ASM_OUTPUT_IDENT
57 #define ASM_OUTPUT_IDENT(FILE, NAME) \
58 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
60 /* This is how to allocate empty space in some section. The .zero
61 pseudo-op is used for this on most svr4 assemblers. */
63 #undef SKIP_ASM_OP
64 #define SKIP_ASM_OP "\t.zero\t"
66 #undef ASM_OUTPUT_SKIP
67 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
68 fprintf (FILE, "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n", SKIP_ASM_OP, (SIZE))
70 /* Output the label which precedes a jumptable. Note that for all svr4
71 systems where we actually generate jumptables (which is to say every
72 svr4 target except i386, where we use casesi instead) we put the jump-
73 tables into the .rodata section and since other stuff could have been
74 put into the .rodata section prior to any given jumptable, we have to
75 make sure that the location counter for the .rodata section gets pro-
76 perly re-aligned prior to the actual beginning of the jump table. */
78 #undef ALIGN_ASM_OP
79 #define ALIGN_ASM_OP "\t.align\t"
81 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
82 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
83 ASM_OUTPUT_ALIGN ((FILE), 2);
84 #endif
86 #undef ASM_OUTPUT_CASE_LABEL
87 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
88 do { \
89 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
90 (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \
91 } while (0)
93 /* The standard SVR4 assembler seems to require that certain builtin
94 library routines (e.g. .udiv) be explicitly declared as .globl
95 in each assembly file where they are referenced. */
97 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
98 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
99 (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0))
101 /* This says how to output assembler code to declare an
102 uninitialized external linkage data object. Under SVR4,
103 the linker seems to want the alignment of data objects
104 to depend on their types. We do exactly that here. */
106 #undef COMMON_ASM_OP
107 #define COMMON_ASM_OP "\t.comm\t"
109 #undef ASM_OUTPUT_ALIGNED_COMMON
110 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
111 do { \
112 fprintf ((FILE), "%s", COMMON_ASM_OP); \
113 assemble_name ((FILE), (NAME)); \
114 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED ",%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
115 } while (0)
117 /* This says how to output assembler code to declare an
118 uninitialized internal linkage data object. Under SVR4,
119 the linker seems to want the alignment of data objects
120 to depend on their types. We do exactly that here. */
122 #undef ASM_OUTPUT_ALIGNED_LOCAL
123 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
124 do { \
125 if ((SIZE) <= g_switch_value) \
126 sbss_section(); \
127 else \
128 bss_section(); \
129 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
130 if (!flag_inhibit_size_directive) \
131 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
132 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
133 ASM_OUTPUT_LABEL(FILE, NAME); \
134 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
135 } while (0)
137 /* This says how to output assembler code to declare an
138 uninitialized external linkage data object. */
140 #undef ASM_OUTPUT_ALIGNED_BSS
141 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
142 do { \
143 ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
144 } while (0)
146 /* Biggest alignment supported by the object file format of this
147 machine. Use this macro to limit the alignment which can be
148 specified using the `__attribute__ ((aligned (N)))' construct. If
149 not defined, the default value is `BIGGEST_ALIGNMENT'.
151 This value is really 2^63. Since gcc figures the alignment in bits,
152 we could only potentially get to 2^60 on suitable hosts. Due to other
153 considerations in varasm, we must restrict this to what fits in an int. */
155 #undef MAX_OFILE_ALIGNMENT
156 #define MAX_OFILE_ALIGNMENT \
157 (1 << (HOST_BITS_PER_INT < 64 ? HOST_BITS_PER_INT - 2 : 62))
159 /* This is the pseudo-op used to generate a contiguous sequence of byte
160 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
161 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
163 #undef ASCII_DATA_ASM_OP
164 #define ASCII_DATA_ASM_OP "\t.ascii\t"
166 #undef READONLY_DATA_SECTION_ASM_OP
167 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
168 #undef BSS_SECTION_ASM_OP
169 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
170 #undef SBSS_SECTION_ASM_OP
171 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
172 #undef SDATA_SECTION_ASM_OP
173 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
175 /* On svr4, we *do* have support for the .init and .fini sections, and we
176 can put stuff in there to be executed before and after `main'. We let
177 crtstuff.c and other files know this by defining the following symbols.
178 The definitions say how to change sections to the .init and .fini
179 sections. This is the same for all known svr4 assemblers. */
181 #undef INIT_SECTION_ASM_OP
182 #define INIT_SECTION_ASM_OP "\t.section\t.init"
183 #undef FINI_SECTION_ASM_OP
184 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
186 #ifdef HAVE_GAS_SUBSECTION_ORDERING
188 #define ASM_SECTION_START_OP "\t.subsection\t-1"
190 /* Output assembly directive to move to the beginning of current section. */
191 #define ASM_OUTPUT_SECTION_START(FILE) \
192 fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
194 #endif
196 /* A default list of other sections which we might be "in" at any given
197 time. For targets that use additional sections (e.g. .tdesc) you
198 should override this definition in the target-specific file which
199 includes this file. */
201 #undef EXTRA_SECTIONS
202 #define EXTRA_SECTIONS in_sbss, in_sdata
204 /* A default list of extra section function definitions. For targets
205 that use additional sections (e.g. .tdesc) you should override this
206 definition in the target-specific file which includes this file. */
208 #undef EXTRA_SECTION_FUNCTIONS
209 #define EXTRA_SECTION_FUNCTIONS \
210 SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
211 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP)
213 extern void sbss_section (void);
214 extern void sdata_section (void);
216 #undef SECTION_FUNCTION_TEMPLATE
217 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
218 void FN (void) \
220 if (in_section != ENUM) \
222 fprintf (asm_out_file, "%s\n", OP); \
223 in_section = ENUM; \
227 /* Switch into a generic section. */
228 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
229 #define TARGET_ASM_SELECT_SECTION default_elf_select_section
231 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
233 /* Define the strings used for the special svr4 .type and .size directives.
234 These strings generally do not vary from one system running svr4 to
235 another, but if a given system (e.g. m88k running svr) needs to use
236 different pseudo-op names for these, they may be overridden in the
237 file which includes this one. */
239 #undef TYPE_ASM_OP
240 #define TYPE_ASM_OP "\t.type\t"
241 #undef SIZE_ASM_OP
242 #define SIZE_ASM_OP "\t.size\t"
244 /* This is how we tell the assembler that a symbol is weak. */
246 #undef ASM_WEAKEN_LABEL
247 #define ASM_WEAKEN_LABEL(FILE, NAME) \
248 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
249 fputc ('\n', FILE); } while (0)
251 /* This is how we tell the assembler that two symbols have the same value. */
253 #undef ASM_OUTPUT_DEF
254 #define ASM_OUTPUT_DEF(FILE, ALIAS, NAME) \
255 do { \
256 assemble_name(FILE, ALIAS); \
257 fputs(" = ", FILE); \
258 assemble_name(FILE, NAME); \
259 fputc('\n', FILE); \
260 } while (0)
262 #undef ASM_OUTPUT_DEF_FROM_DECLS
263 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET) \
264 do { \
265 const char *alias = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
266 const char *name = IDENTIFIER_POINTER (TARGET); \
267 if (TREE_CODE (DECL) == FUNCTION_DECL) \
269 fputc ('$', FILE); \
270 assemble_name (FILE, alias); \
271 fputs ("..ng = $", FILE); \
272 assemble_name (FILE, name); \
273 fputs ("..ng\n", FILE); \
275 assemble_name(FILE, alias); \
276 fputs(" = ", FILE); \
277 assemble_name(FILE, name); \
278 fputc('\n', FILE); \
279 } while (0)
281 /* The following macro defines the format used to output the second
282 operand of the .type assembler directive. Different svr4 assemblers
283 expect various different forms for this operand. The one given here
284 is just a default. You may need to override it in your machine-
285 specific tm.h file (depending upon the particulars of your assembler). */
287 #undef TYPE_OPERAND_FMT
288 #define TYPE_OPERAND_FMT "@%s"
290 /* Write the extra assembler code needed to declare a function's result.
291 Most svr4 assemblers don't require any special declaration of the
292 result value, but there are exceptions. */
294 #ifndef ASM_DECLARE_RESULT
295 #define ASM_DECLARE_RESULT(FILE, RESULT)
296 #endif
298 /* These macros generate the special .type and .size directives which
299 are used to set the corresponding fields of the linker symbol table
300 entries in an ELF object file under SVR4. These macros also output
301 the starting labels for the relevant functions/objects. */
303 /* Write the extra assembler code needed to declare an object properly. */
305 #undef ASM_DECLARE_OBJECT_NAME
306 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
307 do { \
308 HOST_WIDE_INT size; \
309 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
310 size_directive_output = 0; \
311 if (!flag_inhibit_size_directive \
312 && DECL_SIZE (DECL) \
313 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
315 size_directive_output = 1; \
316 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
318 ASM_OUTPUT_LABEL(FILE, NAME); \
319 } while (0)
321 /* Output the size directive for a decl in rest_of_decl_compilation
322 in the case where we did not do so before the initializer.
323 Once we find the error_mark_node, we know that the value of
324 size_directive_output was set
325 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
327 #undef ASM_FINISH_DECLARE_OBJECT
328 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
329 do { \
330 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
331 HOST_WIDE_INT size; \
332 if (!flag_inhibit_size_directive \
333 && DECL_SIZE (DECL) \
334 && ! AT_END && TOP_LEVEL \
335 && DECL_INITIAL (DECL) == error_mark_node \
336 && !size_directive_output \
337 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
339 size_directive_output = 1; \
340 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
342 } while (0)
344 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
345 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
346 corresponds to a particular byte value [0..255]. For any
347 given byte value, if the value in the corresponding table
348 position is zero, the given character can be output directly.
349 If the table value is 1, the byte must be output as a \ooo
350 octal escape. If the tables value is anything else, then the
351 byte value should be output as a \ followed by the value
352 in the table. Note that we can use standard UN*X escape
353 sequences for many control characters, but we don't use
354 \a to represent BEL because some svr4 assemblers (e.g. on
355 the i386) don't know about that. Also, we don't use \v
356 since some versions of gas, such as 2.2 did not accept it. */
358 #undef ESCAPES
359 #define ESCAPES \
360 "\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\
361 \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\
362 \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\
363 \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\
364 \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\
365 \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\
366 \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\
367 \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"
369 /* Some svr4 assemblers have a limit on the number of characters which
370 can appear in the operand of a .string directive. If your assembler
371 has such a limitation, you should define STRING_LIMIT to reflect that
372 limit. Note that at least some svr4 assemblers have a limit on the
373 actual number of bytes in the double-quoted string, and that they
374 count each character in an escape sequence as one byte. Thus, an
375 escape sequence like \377 would count as four bytes.
377 If your target assembler doesn't support the .string directive, you
378 should define this to zero. */
380 #undef STRING_LIMIT
381 #define STRING_LIMIT ((unsigned) 256)
382 #undef STRING_ASM_OP
383 #define STRING_ASM_OP "\t.string\t"
385 /* GAS is the only Alpha/ELF assembler. */
386 #undef TARGET_GAS
387 #define TARGET_GAS (1)
389 /* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
390 (even more) magical crtbegin.o file which provides part of the
391 support for getting C++ file-scope static object constructed
392 before entering `main'. */
394 #undef STARTFILE_SPEC
395 #ifdef HAVE_LD_PIE
396 #define STARTFILE_SPEC \
397 "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
398 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
399 #else
400 #define STARTFILE_SPEC \
401 "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
402 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
403 #endif
405 /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
406 magical crtend.o file which provides part of the support for
407 getting C++ file-scope static object constructed before entering
408 `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
410 #undef ENDFILE_SPEC
411 #define ENDFILE_SPEC \
412 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
413 %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
415 /* We support #pragma. */
416 #define HANDLE_SYSV_PRAGMA 1
418 /* Select a format to encode pointers in exception handling data. CODE
419 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
420 true if the symbol may be affected by dynamic relocations.
422 Since application size is already constrained to <2GB by the form of
423 the ldgp relocation, we can use a 32-bit pc-relative relocation to
424 static data. Dynamic data is accessed indirectly to allow for read
425 only EH sections. */
426 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
427 (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4)
429 /* If defined, a C statement to be executed just prior to the output of
430 assembler code for INSN. */
431 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
432 (alpha_this_literal_sequence_number = 0, \
433 alpha_this_gpdisp_sequence_number = 0)
434 extern int alpha_this_literal_sequence_number;
435 extern int alpha_this_gpdisp_sequence_number;
437 /* Since the bits of the _init and _fini function is spread across
438 many object files, each potentially with its own GP, we must assume
439 we need to load our GP. Further, the .init/.fini section can
440 easily be more than 4MB away from the function to call so we can't
441 use bsr. */
442 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
443 asm (SECTION_OP "\n" \
444 " br $29,1f\n" \
445 "1: ldgp $29,0($29)\n" \
446 " unop\n" \
447 " jsr $26," USER_LABEL_PREFIX #FUNC "\n" \
448 " .align 3\n" \
449 " .previous");
451 /* If we have the capability create headers for efficient EH lookup.
452 As of Jan 2002, only glibc 2.2.4 can actually make use of this, but
453 I imagine that other systems will catch up. In the meantime, it
454 doesn't harm to make sure that the data exists to be used later. */
455 #if defined(HAVE_LD_EH_FRAME_HDR)
456 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
457 #endif