FSF GCC merge 02/23/03
[official-gcc.git] / gcc / config / alpha / elf.h
blobafe96462d4ed38f59628716288765613c3bdef7f
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 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 #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 /* Output #ident as a .ident. */
72 #undef ASM_OUTPUT_IDENT
73 #define ASM_OUTPUT_IDENT(FILE, NAME) \
74 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
76 /* This is how to allocate empty space in some section. The .zero
77 pseudo-op is used for this on most svr4 assemblers. */
79 #undef SKIP_ASM_OP
80 #define SKIP_ASM_OP "\t.zero\t"
82 #undef ASM_OUTPUT_SKIP
83 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
84 fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
86 /* Output the label which precedes a jumptable. Note that for all svr4
87 systems where we actually generate jumptables (which is to say every
88 svr4 target except i386, where we use casesi instead) we put the jump-
89 tables into the .rodata section and since other stuff could have been
90 put into the .rodata section prior to any given jumptable, we have to
91 make sure that the location counter for the .rodata section gets pro-
92 perly re-aligned prior to the actual beginning of the jump table. */
94 #undef ALIGN_ASM_OP
95 #define ALIGN_ASM_OP "\t.align\t"
97 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
98 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
99 ASM_OUTPUT_ALIGN ((FILE), 2);
100 #endif
102 #undef ASM_OUTPUT_CASE_LABEL
103 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
104 do { \
105 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
106 (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \
107 } while (0)
109 /* The standard SVR4 assembler seems to require that certain builtin
110 library routines (e.g. .udiv) be explicitly declared as .globl
111 in each assembly file where they are referenced. */
113 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
114 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
115 (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0))
117 /* This says how to output assembler code to declare an
118 uninitialized external 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 COMMON_ASM_OP
123 #define COMMON_ASM_OP "\t.comm\t"
125 #undef ASM_OUTPUT_ALIGNED_COMMON
126 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
127 do { \
128 fprintf ((FILE), "%s", COMMON_ASM_OP); \
129 assemble_name ((FILE), (NAME)); \
130 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
131 } while (0)
133 /* This says how to output assembler code to declare an
134 uninitialized internal linkage data object. Under SVR4,
135 the linker seems to want the alignment of data objects
136 to depend on their types. We do exactly that here. */
138 #undef ASM_OUTPUT_ALIGNED_LOCAL
139 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
140 do { \
141 if ((SIZE) <= g_switch_value) \
142 sbss_section(); \
143 else \
144 bss_section(); \
145 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
146 if (!flag_inhibit_size_directive) \
147 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
148 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
149 ASM_OUTPUT_LABEL(FILE, NAME); \
150 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
151 } while (0)
153 /* This says how to output assembler code to declare an
154 uninitialized external linkage data object. */
156 #undef ASM_OUTPUT_ALIGNED_BSS
157 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
158 do { \
159 (*targetm.asm_out.globalize_label) (FILE, NAME); \
160 ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
161 } while (0)
163 /* Biggest alignment supported by the object file format of this
164 machine. Use this macro to limit the alignment which can be
165 specified using the `__attribute__ ((aligned (N)))' construct. If
166 not defined, the default value is `BIGGEST_ALIGNMENT'.
168 This value is really 2^63. Since gcc figures the alignment in bits,
169 we could only potentially get to 2^60 on suitible hosts. Due to other
170 considerations in varasm, we must restrict this to what fits in an int. */
172 #undef MAX_OFILE_ALIGNMENT
173 #define MAX_OFILE_ALIGNMENT \
174 (1 << (HOST_BITS_PER_INT < 64 ? HOST_BITS_PER_INT - 2 : 62))
176 /* This is the pseudo-op used to generate a contiguous sequence of byte
177 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
178 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
180 #undef ASCII_DATA_ASM_OP
181 #define ASCII_DATA_ASM_OP "\t.ascii\t"
183 #undef READONLY_DATA_SECTION_ASM_OP
184 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
185 #undef BSS_SECTION_ASM_OP
186 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
187 #undef SBSS_SECTION_ASM_OP
188 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
189 #undef SDATA_SECTION_ASM_OP
190 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
192 /* On svr4, we *do* have support for the .init and .fini sections, and we
193 can put stuff in there to be executed before and after `main'. We let
194 crtstuff.c and other files know this by defining the following symbols.
195 The definitions say how to change sections to the .init and .fini
196 sections. This is the same for all known svr4 assemblers. */
198 #undef INIT_SECTION_ASM_OP
199 #define INIT_SECTION_ASM_OP "\t.section\t.init"
200 #undef FINI_SECTION_ASM_OP
201 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
203 #ifdef HAVE_GAS_SUBSECTION_ORDERING
205 #define ASM_SECTION_START_OP "\t.subsection\t-1"
207 /* Output assembly directive to move to the beginning of current section. */
208 #define ASM_OUTPUT_SECTION_START(FILE) \
209 fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
211 #endif
213 /* A default list of other sections which we might be "in" at any given
214 time. For targets that use additional sections (e.g. .tdesc) you
215 should override this definition in the target-specific file which
216 includes this file. */
218 #undef EXTRA_SECTIONS
219 #define EXTRA_SECTIONS in_sbss, in_sdata
221 /* A default list of extra section function definitions. For targets
222 that use additional sections (e.g. .tdesc) you should override this
223 definition in the target-specific file which includes this file. */
225 #undef EXTRA_SECTION_FUNCTIONS
226 #define EXTRA_SECTION_FUNCTIONS \
227 SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
228 SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP)
230 extern void sbss_section PARAMS ((void));
231 extern void sdata_section PARAMS ((void));
233 #undef SECTION_FUNCTION_TEMPLATE
234 #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
235 void FN () \
237 if (in_section != ENUM) \
239 fprintf (asm_out_file, "%s\n", OP); \
240 in_section = ENUM; \
244 /* Switch into a generic section. */
245 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
246 #define TARGET_ASM_SELECT_SECTION default_elf_select_section
248 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
250 /* Define the strings used for the special svr4 .type and .size directives.
251 These strings generally do not vary from one system running svr4 to
252 another, but if a given system (e.g. m88k running svr) needs to use
253 different pseudo-op names for these, they may be overridden in the
254 file which includes this one. */
256 #undef TYPE_ASM_OP
257 #define TYPE_ASM_OP "\t.type\t"
258 #undef SIZE_ASM_OP
259 #define SIZE_ASM_OP "\t.size\t"
261 /* This is how we tell the assembler that a symbol is weak. */
263 #undef ASM_WEAKEN_LABEL
264 #define ASM_WEAKEN_LABEL(FILE, NAME) \
265 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
266 fputc ('\n', FILE); } while (0)
268 /* This is how we tell the assembler that two symbols have the same value. */
270 #undef ASM_OUTPUT_DEF
271 #define ASM_OUTPUT_DEF(FILE, ALIAS, NAME) \
272 do { \
273 assemble_name(FILE, ALIAS); \
274 fputs(" = ", FILE); \
275 assemble_name(FILE, NAME); \
276 fputc('\n', FILE); \
277 } while (0)
279 #undef ASM_OUTPUT_DEF_FROM_DECLS
280 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET) \
281 do { \
282 const char *alias = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
283 const char *name = IDENTIFIER_POINTER (TARGET); \
284 if (TREE_CODE (DECL) == FUNCTION_DECL) \
286 fputc ('$', FILE); \
287 assemble_name (FILE, alias); \
288 fputs ("..ng = $", FILE); \
289 assemble_name (FILE, name); \
290 fputs ("..ng\n", FILE); \
292 assemble_name(FILE, alias); \
293 fputs(" = ", FILE); \
294 assemble_name(FILE, name); \
295 fputc('\n', FILE); \
296 } while (0)
298 /* The following macro defines the format used to output the second
299 operand of the .type assembler directive. Different svr4 assemblers
300 expect various different forms for this operand. The one given here
301 is just a default. You may need to override it in your machine-
302 specific tm.h file (depending upon the particulars of your assembler). */
304 #undef TYPE_OPERAND_FMT
305 #define TYPE_OPERAND_FMT "@%s"
307 /* Write the extra assembler code needed to declare a function's result.
308 Most svr4 assemblers don't require any special declaration of the
309 result value, but there are exceptions. */
311 #ifndef ASM_DECLARE_RESULT
312 #define ASM_DECLARE_RESULT(FILE, RESULT)
313 #endif
315 /* These macros generate the special .type and .size directives which
316 are used to set the corresponding fields of the linker symbol table
317 entries in an ELF object file under SVR4. These macros also output
318 the starting labels for the relevant functions/objects. */
320 /* Write the extra assembler code needed to declare an object properly. */
322 #undef ASM_DECLARE_OBJECT_NAME
323 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
324 do { \
325 HOST_WIDE_INT size; \
326 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
327 size_directive_output = 0; \
328 if (!flag_inhibit_size_directive \
329 && DECL_SIZE (DECL) \
330 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
332 size_directive_output = 1; \
333 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
335 ASM_OUTPUT_LABEL(FILE, NAME); \
336 } while (0)
338 /* Output the size directive for a decl in rest_of_decl_compilation
339 in the case where we did not do so before the initializer.
340 Once we find the error_mark_node, we know that the value of
341 size_directive_output was set
342 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
344 #undef ASM_FINISH_DECLARE_OBJECT
345 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
346 do { \
347 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
348 HOST_WIDE_INT size; \
349 if (!flag_inhibit_size_directive \
350 && DECL_SIZE (DECL) \
351 && ! AT_END && TOP_LEVEL \
352 && DECL_INITIAL (DECL) == error_mark_node \
353 && !size_directive_output \
354 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
356 size_directive_output = 1; \
357 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
359 } while (0)
361 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
362 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
363 corresponds to a particular byte value [0..255]. For any
364 given byte value, if the value in the corresponding table
365 position is zero, the given character can be output directly.
366 If the table value is 1, the byte must be output as a \ooo
367 octal escape. If the tables value is anything else, then the
368 byte value should be output as a \ followed by the value
369 in the table. Note that we can use standard UN*X escape
370 sequences for many control characters, but we don't use
371 \a to represent BEL because some svr4 assemblers (e.g. on
372 the i386) don't know about that. Also, we don't use \v
373 since some versions of gas, such as 2.2 did not accept it. */
375 #undef ESCAPES
376 #define ESCAPES \
377 "\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\
378 \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\
379 \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\
380 \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\
381 \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\
382 \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\
383 \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\
384 \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"
386 /* Some svr4 assemblers have a limit on the number of characters which
387 can appear in the operand of a .string directive. If your assembler
388 has such a limitation, you should define STRING_LIMIT to reflect that
389 limit. Note that at least some svr4 assemblers have a limit on the
390 actual number of bytes in the double-quoted string, and that they
391 count each character in an escape sequence as one byte. Thus, an
392 escape sequence like \377 would count as four bytes.
394 If your target assembler doesn't support the .string directive, you
395 should define this to zero. */
397 #undef STRING_LIMIT
398 #define STRING_LIMIT ((unsigned) 256)
399 #undef STRING_ASM_OP
400 #define STRING_ASM_OP "\t.string\t"
402 /* GAS is the only Alpha/ELF assembler. */
403 #undef TARGET_GAS
404 #define TARGET_GAS (1)
406 /* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
407 (even more) magical crtbegin.o file which provides part of the
408 support for getting C++ file-scope static object constructed
409 before entering `main'. */
411 #undef STARTFILE_SPEC
412 #define STARTFILE_SPEC \
413 "%{!shared: \
414 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
415 crti.o%s %{static:crtbeginT.o%s}\
416 %{!static:%{shared:crtbeginS.o%s}%{!shared:crtbegin.o%s}}"
418 /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
419 magical crtend.o file which provides part of the support for
420 getting C++ file-scope static object constructed before entering
421 `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
423 #undef ENDFILE_SPEC
424 #define ENDFILE_SPEC \
425 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
426 %{shared:crtendS.o%s}%{!shared:crtend.o%s} crtn.o%s"
428 /* We support #pragma. */
429 #define HANDLE_SYSV_PRAGMA 1
431 /* Select a format to encode pointers in exception handling data. CODE
432 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
433 true if the symbol may be affected by dynamic relocations.
435 Since application size is already constrained to <2GB by the form of
436 the ldgp relocation, we can use a 32-bit pc-relative relocation to
437 static data. Dynamic data is accessed indirectly to allow for read
438 only EH sections. */
439 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
440 (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4)
442 /* If defined, a C statement to be executed just prior to the output of
443 assembler code for INSN. */
444 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
445 (alpha_this_literal_sequence_number = 0, \
446 alpha_this_gpdisp_sequence_number = 0)
447 extern int alpha_this_literal_sequence_number;
448 extern int alpha_this_gpdisp_sequence_number;
450 /* Since the bits of the _init and _fini function is spread across
451 many object files, each potentially with its own GP, we must assume
452 we need to load our GP. Further, the .init/.fini section can
453 easily be more than 4MB away from the function to call so we can't
454 use bsr. */
455 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
456 asm (SECTION_OP "\n" \
457 " br $29,1f\n" \
458 "1: ldgp $29,0($29)\n" \
459 " unop\n" \
460 " jsr $26," USER_LABEL_PREFIX #FUNC "\n" \
461 " .align 3\n" \
462 " .previous");
464 /* If we have the capability create headers for efficient EH lookup.
465 As of Jan 2002, only glibc 2.2.4 can actually make use of this, but
466 I imagine that other systems will catch up. In the meantime, it
467 doesn't harm to make sure that the data exists to be used later. */
468 #if defined(HAVE_LD_EH_FRAME_HDR)
469 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
470 #endif