* final.c (HAVE_READONLY_DATA_SECTION): New.
[official-gcc.git] / gcc / config / alpha / elf.h
blob3e8d1e06f9bb765a9cca084c31a8d8d66a62ab22
1 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
4 Contributed by Richard Henderson (rth@tamu.edu).
6 This file is part of GNU CC.
8 GNU CC 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 GNU CC 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 GNU CC; 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
31 #define DWARF2_DEBUGGING_INFO
33 #undef PREFERRED_DEBUGGING_TYPE
34 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
36 #undef ASM_FINAL_SPEC
38 #undef CPP_SUBTARGET_SPEC
39 #define CPP_SUBTARGET_SPEC "-D__ELF__"
41 #undef CC1_SPEC
42 #define CC1_SPEC "%{G*}"
44 #undef ASM_SPEC
45 #define ASM_SPEC "%{G*} %{relax:-relax} %{!gstabs*:-no-mdebug}%{gstabs*:-mdebug}"
47 /* Output at beginning of assembler file. */
48 #undef ASM_FILE_START
49 #define ASM_FILE_START(FILE) \
50 do { \
51 if (write_symbols == DBX_DEBUG) \
52 { \
53 alpha_write_verstamp (FILE); \
54 output_file_directive (FILE, main_input_filename); \
55 } \
56 fprintf (FILE, "\t.set noat\n"); \
57 fprintf (FILE, "\t.set noreorder\n"); \
58 if (TARGET_EXPLICIT_RELOCS) \
59 fprintf (FILE, "\t.set nomacro\n"); \
60 if (TARGET_BWX | TARGET_MAX | TARGET_FIX | TARGET_CIX) \
61 { \
62 fprintf (FILE, "\t.arch %s\n", \
63 (TARGET_CPU_EV6 ? "ev6" \
64 : TARGET_MAX ? "pca56" : "ev56")); \
65 } \
66 } while (0)
68 #undef IDENT_ASM_OP
69 #define IDENT_ASM_OP "\t.ident\t"
71 /* Allow #sccs in preprocessor. */
72 #define SCCS_DIRECTIVE
74 /* Output #ident as a .ident. */
75 #undef ASM_OUTPUT_IDENT
76 #define ASM_OUTPUT_IDENT(FILE, NAME) \
77 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
79 /* This is how to allocate empty space in some section. The .zero
80 pseudo-op is used for this on most svr4 assemblers. */
82 #undef SKIP_ASM_OP
83 #define SKIP_ASM_OP "\t.zero\t"
85 #undef ASM_OUTPUT_SKIP
86 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
87 fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
89 /* Output the label which precedes a jumptable. Note that for all svr4
90 systems where we actually generate jumptables (which is to say every
91 svr4 target except i386, where we use casesi instead) we put the jump-
92 tables into the .rodata section and since other stuff could have been
93 put into the .rodata section prior to any given jumptable, we have to
94 make sure that the location counter for the .rodata section gets pro-
95 perly re-aligned prior to the actual beginning of the jump table. */
97 #undef ALIGN_ASM_OP
98 #define ALIGN_ASM_OP "\t.align\t"
100 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
101 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
102 ASM_OUTPUT_ALIGN ((FILE), 2);
103 #endif
105 #undef ASM_OUTPUT_CASE_LABEL
106 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
107 do { \
108 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
109 ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \
110 } while (0)
112 /* The standard SVR4 assembler seems to require that certain builtin
113 library routines (e.g. .udiv) be explicitly declared as .globl
114 in each assembly file where they are referenced. */
116 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
117 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
118 ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
120 /* This says how to output assembler code to declare an
121 uninitialized external linkage data object. Under SVR4,
122 the linker seems to want the alignment of data objects
123 to depend on their types. We do exactly that here. */
125 #undef COMMON_ASM_OP
126 #define COMMON_ASM_OP "\t.comm\t"
128 #undef ASM_OUTPUT_ALIGNED_COMMON
129 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
130 do { \
131 fprintf ((FILE), "%s", COMMON_ASM_OP); \
132 assemble_name ((FILE), (NAME)); \
133 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
134 } while (0)
136 /* This says how to output assembler code to declare an
137 uninitialized internal linkage data object. Under SVR4,
138 the linker seems to want the alignment of data objects
139 to depend on their types. We do exactly that here. */
141 #undef ASM_OUTPUT_ALIGNED_LOCAL
142 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
143 do { \
144 if ((SIZE) <= g_switch_value) \
145 sbss_section(); \
146 else \
147 bss_section(); \
148 fprintf (FILE, "%s", TYPE_ASM_OP); \
149 assemble_name (FILE, NAME); \
150 putc (',', FILE); \
151 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
152 putc ('\n', FILE); \
153 if (!flag_inhibit_size_directive) \
155 fprintf (FILE, "%s", SIZE_ASM_OP); \
156 assemble_name (FILE, NAME); \
157 fprintf (FILE, ",%d\n", (SIZE)); \
159 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
160 ASM_OUTPUT_LABEL(FILE, NAME); \
161 ASM_OUTPUT_SKIP((FILE), (SIZE)); \
162 } while (0)
164 /* This says how to output assembler code to declare an
165 uninitialized external linkage data object. */
167 #undef ASM_OUTPUT_ALIGNED_BSS
168 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
169 do { \
170 ASM_GLOBALIZE_LABEL (FILE, NAME); \
171 ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
172 } while (0)
174 /* Biggest alignment supported by the object file format of this
175 machine. Use this macro to limit the alignment which can be
176 specified using the `__attribute__ ((aligned (N)))' construct. If
177 not defined, the default value is `BIGGEST_ALIGNMENT'.
179 This value is really 2^63. Since gcc figures the alignment in bits,
180 we could only potentially get to 2^60 on suitible hosts. Due to other
181 considerations in varasm, we must restrict this to what fits in an int. */
183 #undef MAX_OFILE_ALIGNMENT
184 #define MAX_OFILE_ALIGNMENT \
185 (1 << (HOST_BITS_PER_INT < 64 ? HOST_BITS_PER_INT - 2 : 62))
187 /* This is the pseudo-op used to generate a contiguous sequence of byte
188 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
189 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
191 #undef ASCII_DATA_ASM_OP
192 #define ASCII_DATA_ASM_OP "\t.ascii\t"
194 #undef READONLY_DATA_SECTION_ASM_OP
195 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
196 #undef BSS_SECTION_ASM_OP
197 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
198 #undef SBSS_SECTION_ASM_OP
199 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
200 #undef SDATA_SECTION_ASM_OP
201 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
203 /* On svr4, we *do* have support for the .init and .fini sections, and we
204 can put stuff in there to be executed before and after `main'. We let
205 crtstuff.c and other files know this by defining the following symbols.
206 The definitions say how to change sections to the .init and .fini
207 sections. This is the same for all known svr4 assemblers. */
209 #undef INIT_SECTION_ASM_OP
210 #define INIT_SECTION_ASM_OP "\t.section\t.init"
211 #undef FINI_SECTION_ASM_OP
212 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
214 #ifdef HAVE_GAS_SUBSECTION_ORDERING
216 #define ASM_SECTION_START_OP "\t.subsection\t-1"
218 /* Output assembly directive to move to the beginning of current section. */
219 #define ASM_OUTPUT_SECTION_START(FILE) \
220 fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
222 #endif
224 /* A default list of other sections which we might be "in" at any given
225 time. For targets that use additional sections (e.g. .tdesc) you
226 should override this definition in the target-specific file which
227 includes this file. */
229 #undef EXTRA_SECTIONS
230 #define EXTRA_SECTIONS in_sbss, in_sdata
232 /* A default list of extra section function definitions. For targets
233 that use additional sections (e.g. .tdesc) you should override this
234 definition in the target-specific file which includes this file. */
236 #undef EXTRA_SECTION_FUNCTIONS
237 #define EXTRA_SECTION_FUNCTIONS \
238 SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
239 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP)
241 extern void sbss_section PARAMS ((void));
242 extern void sdata_section PARAMS ((void));
244 #undef SECTION_FUNCTION_TEMPLATE
245 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
246 void FN () \
248 if (in_section != ENUM) \
250 fprintf (asm_out_file, "%s\n", OP); \
251 in_section = ENUM; \
255 /* Switch into a generic section. */
256 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
257 #define TARGET_ASM_SELECT_SECTION default_elf_select_section
259 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
261 /* A C statement or statements to switch to the appropriate
262 section for output of RTX in mode MODE. RTX is some kind
263 of constant in RTL. The argument MODE is redundant except
264 in the case of a `const_int' rtx. Currently, these always
265 go into the const section. */
267 #undef SELECT_RTX_SECTION
268 #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) \
269 do { \
270 if (TARGET_SMALL_DATA && GET_MODE_SIZE (MODE) <= g_switch_value) \
271 /* ??? Consider .sdata.{lit4,lit8} as SHF_MERGE|SHF_ALPHA_GPREL. */ \
272 sdata_section (); \
273 else \
274 mergeable_constant_section((MODE), (ALIGN), 0); \
275 } while (0)
277 /* Define the strings used for the special svr4 .type and .size directives.
278 These strings generally do not vary from one system running svr4 to
279 another, but if a given system (e.g. m88k running svr) needs to use
280 different pseudo-op names for these, they may be overridden in the
281 file which includes this one. */
283 #undef TYPE_ASM_OP
284 #define TYPE_ASM_OP "\t.type\t"
285 #undef SIZE_ASM_OP
286 #define SIZE_ASM_OP "\t.size\t"
288 /* This is how we tell the assembler that a symbol is weak. */
290 #undef ASM_WEAKEN_LABEL
291 #define ASM_WEAKEN_LABEL(FILE, NAME) \
292 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
293 fputc ('\n', FILE); } while (0)
295 /* This is how we tell the assembler that two symbols have the same value. */
297 #undef ASM_OUTPUT_DEF
298 #define ASM_OUTPUT_DEF(FILE, ALIAS, NAME) \
299 do { \
300 assemble_name(FILE, ALIAS); \
301 fputs(" = ", FILE); \
302 assemble_name(FILE, NAME); \
303 fputc('\n', FILE); \
304 } while (0)
306 #undef ASM_OUTPUT_DEF_FROM_DECLS
307 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET) \
308 do { \
309 const char *alias = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
310 const char *name = IDENTIFIER_POINTER (TARGET); \
311 if (TREE_CODE (DECL) == FUNCTION_DECL) \
313 fputc ('$', FILE); \
314 assemble_name (FILE, alias); \
315 fputs ("..ng = $", FILE); \
316 assemble_name (FILE, name); \
317 fputs ("..ng\n", FILE); \
319 assemble_name(FILE, alias); \
320 fputs(" = ", FILE); \
321 assemble_name(FILE, name); \
322 fputc('\n', FILE); \
323 } while (0)
325 /* The following macro defines the format used to output the second
326 operand of the .type assembler directive. Different svr4 assemblers
327 expect various different forms for this operand. The one given here
328 is just a default. You may need to override it in your machine-
329 specific tm.h file (depending upon the particulars of your assembler). */
331 #undef TYPE_OPERAND_FMT
332 #define TYPE_OPERAND_FMT "@%s"
334 /* Write the extra assembler code needed to declare a function's result.
335 Most svr4 assemblers don't require any special declaration of the
336 result value, but there are exceptions. */
338 #ifndef ASM_DECLARE_RESULT
339 #define ASM_DECLARE_RESULT(FILE, RESULT)
340 #endif
342 /* These macros generate the special .type and .size directives which
343 are used to set the corresponding fields of the linker symbol table
344 entries in an ELF object file under SVR4. These macros also output
345 the starting labels for the relevant functions/objects. */
347 /* Write the extra assembler code needed to declare an object properly. */
349 #undef ASM_DECLARE_OBJECT_NAME
350 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
351 do { \
352 HOST_WIDE_INT size; \
353 fprintf (FILE, "%s", TYPE_ASM_OP); \
354 assemble_name (FILE, NAME); \
355 putc (',', FILE); \
356 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
357 putc ('\n', FILE); \
358 size_directive_output = 0; \
359 if (!flag_inhibit_size_directive \
360 && DECL_SIZE (DECL) \
361 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
363 size_directive_output = 1; \
364 fprintf (FILE, "%s", SIZE_ASM_OP); \
365 assemble_name (FILE, NAME); \
366 fputc (',', FILE); \
367 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, size); \
368 fputc ('\n', FILE); \
370 ASM_OUTPUT_LABEL(FILE, NAME); \
371 } while (0)
373 /* Output the size directive for a decl in rest_of_decl_compilation
374 in the case where we did not do so before the initializer.
375 Once we find the error_mark_node, we know that the value of
376 size_directive_output was set
377 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
379 #undef ASM_FINISH_DECLARE_OBJECT
380 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
381 do { \
382 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
383 HOST_WIDE_INT size; \
384 if (!flag_inhibit_size_directive \
385 && DECL_SIZE (DECL) \
386 && ! AT_END && TOP_LEVEL \
387 && DECL_INITIAL (DECL) == error_mark_node \
388 && !size_directive_output \
389 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
391 size_directive_output = 1; \
392 fprintf (FILE, "%s", SIZE_ASM_OP); \
393 assemble_name (FILE, name); \
394 fputc (',', FILE); \
395 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, size); \
396 fputc ('\n', FILE); \
398 } while (0)
400 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
401 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
402 corresponds to a particular byte value [0..255]. For any
403 given byte value, if the value in the corresponding table
404 position is zero, the given character can be output directly.
405 If the table value is 1, the byte must be output as a \ooo
406 octal escape. If the tables value is anything else, then the
407 byte value should be output as a \ followed by the value
408 in the table. Note that we can use standard UN*X escape
409 sequences for many control characters, but we don't use
410 \a to represent BEL because some svr4 assemblers (e.g. on
411 the i386) don't know about that. Also, we don't use \v
412 since some versions of gas, such as 2.2 did not accept it. */
414 #undef ESCAPES
415 #define ESCAPES \
416 "\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\
417 \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\
418 \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\
419 \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\
420 \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\
421 \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\
422 \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\
423 \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"
425 /* Some svr4 assemblers have a limit on the number of characters which
426 can appear in the operand of a .string directive. If your assembler
427 has such a limitation, you should define STRING_LIMIT to reflect that
428 limit. Note that at least some svr4 assemblers have a limit on the
429 actual number of bytes in the double-quoted string, and that they
430 count each character in an escape sequence as one byte. Thus, an
431 escape sequence like \377 would count as four bytes.
433 If your target assembler doesn't support the .string directive, you
434 should define this to zero. */
436 #undef STRING_LIMIT
437 #define STRING_LIMIT ((unsigned) 256)
438 #undef STRING_ASM_OP
439 #define STRING_ASM_OP "\t.string\t"
441 /* GAS is the only Alpha/ELF assembler. */
442 #undef TARGET_GAS
443 #define TARGET_GAS (1)
445 /* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
446 (even more) magical crtbegin.o file which provides part of the
447 support for getting C++ file-scope static object constructed
448 before entering `main'. */
450 #undef STARTFILE_SPEC
451 #define STARTFILE_SPEC \
452 "%{!shared: \
453 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
454 crti.o%s %{static:crtbeginT.o%s}\
455 %{!static:%{shared:crtbeginS.o%s}%{!shared:crtbegin.o%s}}"
457 /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
458 magical crtend.o file which provides part of the support for
459 getting C++ file-scope static object constructed before entering
460 `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
462 #undef ENDFILE_SPEC
463 #define ENDFILE_SPEC \
464 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
465 %{shared:crtendS.o%s}%{!shared:crtend.o%s} crtn.o%s"
467 /* We support #pragma. */
468 #define HANDLE_SYSV_PRAGMA
470 /* Select a format to encode pointers in exception handling data. CODE
471 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
472 true if the symbol may be affected by dynamic relocations.
474 Since application size is already constrained to <2GB by the form of
475 the ldgp relocation, we can use a 32-bit pc-relative relocation to
476 static data. Dynamic data is accessed indirectly to allow for read
477 only EH sections. */
478 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
479 (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4)
481 /* If defined, a C statement to be executed just prior to the output of
482 assembler code for INSN. */
483 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
484 (alpha_this_literal_sequence_number = 0, \
485 alpha_this_gpdisp_sequence_number = 0)
486 extern int alpha_this_literal_sequence_number;
487 extern int alpha_this_gpdisp_sequence_number;
489 /* Since the bits of the _init and _fini function is spread across
490 many object files, each potentially with its own GP, we must assume
491 we need to load our GP. Further, the .init/.fini section can
492 easily be more than 4MB away from the function to call so we can't
493 use bsr. */
494 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
495 asm (SECTION_OP "\n" \
496 " br $29,1f\n" \
497 "1: ldgp $29,0($29)\n" \
498 " unop\n" \
499 " jsr $26," USER_LABEL_PREFIX #FUNC "\n" \
500 " .align 3\n" \
501 " .previous");
503 /* If we have the capability create headers for efficient EH lookup.
504 As of Jan 2002, only glibc 2.2.4 can actually make use of this, but
505 I imagine that other systems will catch up. In the meantime, it
506 doesn't harm to make sure that the data exists to be used later. */
507 #if defined(HAVE_LD_EH_FRAME_HDR)
508 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
509 #endif