Merged with mainline at revision 128810.
[official-gcc.git] / gcc / config / alpha / elf.h
blobf831196f00339f9804fbd4bdd8d7c1a27abe2fdf
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
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 3, 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 COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #undef OBJECT_FORMAT_COFF
23 #undef EXTENDED_COFF
24 #define OBJECT_FORMAT_ELF
26 /* ??? Move all SDB stuff from alpha.h to osf.h. */
27 #undef SDB_DEBUGGING_INFO
29 #define DBX_DEBUGGING_INFO 1
30 #define DWARF2_DEBUGGING_INFO 1
32 #undef PREFERRED_DEBUGGING_TYPE
33 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
35 #undef ASM_FINAL_SPEC
37 /* alpha/ doesn't use elfos.h for some reason. */
38 #define TARGET_OBJFMT_CPP_BUILTINS() \
39 do \
40 { \
41 builtin_define ("__ELF__"); \
42 } \
43 while (0)
45 #undef CC1_SPEC
46 #define CC1_SPEC "%{G*}"
48 #undef ASM_SPEC
49 #define ASM_SPEC "%{G*} %{relax:-relax} %{!gstabs*:-no-mdebug}%{gstabs*:-mdebug}"
51 #undef IDENT_ASM_OP
52 #define IDENT_ASM_OP "\t.ident\t"
54 /* Output #ident as a .ident. */
55 #undef ASM_OUTPUT_IDENT
56 #define ASM_OUTPUT_IDENT(FILE, NAME) \
57 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
59 /* This is how to allocate empty space in some section. The .zero
60 pseudo-op is used for this on most svr4 assemblers. */
62 #undef SKIP_ASM_OP
63 #define SKIP_ASM_OP "\t.zero\t"
65 #undef ASM_OUTPUT_SKIP
66 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
67 fprintf (FILE, "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n", SKIP_ASM_OP, (SIZE))
69 /* Output the label which precedes a jumptable. Note that for all svr4
70 systems where we actually generate jumptables (which is to say every
71 svr4 target except i386, where we use casesi instead) we put the jump-
72 tables into the .rodata section and since other stuff could have been
73 put into the .rodata section prior to any given jumptable, we have to
74 make sure that the location counter for the .rodata section gets pro-
75 perly re-aligned prior to the actual beginning of the jump table. */
77 #undef ALIGN_ASM_OP
78 #define ALIGN_ASM_OP "\t.align\t"
80 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
81 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
82 ASM_OUTPUT_ALIGN ((FILE), 2);
83 #endif
85 #undef ASM_OUTPUT_CASE_LABEL
86 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
87 do { \
88 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
89 (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \
90 } while (0)
92 /* The standard SVR4 assembler seems to require that certain builtin
93 library routines (e.g. .udiv) be explicitly declared as .globl
94 in each assembly file where they are referenced. */
96 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
97 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
98 (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0))
100 /* This says how to output assembler code to declare an
101 uninitialized external linkage data object. Under SVR4,
102 the linker seems to want the alignment of data objects
103 to depend on their types. We do exactly that here. */
105 #undef COMMON_ASM_OP
106 #define COMMON_ASM_OP "\t.comm\t"
108 #undef ASM_OUTPUT_ALIGNED_COMMON
109 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
110 do { \
111 fprintf ((FILE), "%s", COMMON_ASM_OP); \
112 assemble_name ((FILE), (NAME)); \
113 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED ",%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
114 } while (0)
116 /* This says how to output assembler code to declare an
117 uninitialized internal linkage data object. Under SVR4,
118 the linker seems to want the alignment of data objects
119 to depend on their types. We do exactly that here. */
121 #undef ASM_OUTPUT_ALIGNED_LOCAL
122 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
123 do { \
124 if ((SIZE) <= g_switch_value) \
125 switch_to_section (sbss_section); \
126 else \
127 switch_to_section (bss_section); \
128 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
129 if (!flag_inhibit_size_directive) \
130 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
131 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
132 ASM_OUTPUT_LABEL(FILE, NAME); \
133 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
134 } while (0)
136 /* This says how to output assembler code to declare an
137 uninitialized external linkage data object. */
139 #undef ASM_OUTPUT_ALIGNED_BSS
140 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
141 do { \
142 ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
143 } while (0)
145 /* Biggest alignment supported by the object file format of this
146 machine. Use this macro to limit the alignment which can be
147 specified using the `__attribute__ ((aligned (N)))' construct. If
148 not defined, the default value is `BIGGEST_ALIGNMENT'.
150 This value is really 2^63. Since gcc figures the alignment in bits,
151 we could only potentially get to 2^60 on suitable hosts. Due to other
152 considerations in varasm, we must restrict this to what fits in an int. */
154 #undef MAX_OFILE_ALIGNMENT
155 #define MAX_OFILE_ALIGNMENT \
156 (1 << (HOST_BITS_PER_INT < 64 ? HOST_BITS_PER_INT - 2 : 62))
158 /* This is the pseudo-op used to generate a contiguous sequence of byte
159 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
160 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
162 #undef ASCII_DATA_ASM_OP
163 #define ASCII_DATA_ASM_OP "\t.ascii\t"
165 #undef READONLY_DATA_SECTION_ASM_OP
166 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
167 #undef BSS_SECTION_ASM_OP
168 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
169 #undef SBSS_SECTION_ASM_OP
170 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
171 #undef SDATA_SECTION_ASM_OP
172 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
174 /* On svr4, we *do* have support for the .init and .fini sections, and we
175 can put stuff in there to be executed before and after `main'. We let
176 crtstuff.c and other files know this by defining the following symbols.
177 The definitions say how to change sections to the .init and .fini
178 sections. This is the same for all known svr4 assemblers. */
180 #undef INIT_SECTION_ASM_OP
181 #define INIT_SECTION_ASM_OP "\t.section\t.init"
182 #undef FINI_SECTION_ASM_OP
183 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
185 #ifdef HAVE_GAS_SUBSECTION_ORDERING
187 #define ASM_SECTION_START_OP "\t.subsection\t-1"
189 /* Output assembly directive to move to the beginning of current section. */
190 #define ASM_OUTPUT_SECTION_START(FILE) \
191 fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
193 #endif
195 /* Switch into a generic section. */
196 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
197 #define TARGET_ASM_SELECT_SECTION default_elf_select_section
199 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
201 /* Define the strings used for the special svr4 .type and .size directives.
202 These strings generally do not vary from one system running svr4 to
203 another, but if a given system (e.g. m88k running svr) needs to use
204 different pseudo-op names for these, they may be overridden in the
205 file which includes this one. */
207 #undef TYPE_ASM_OP
208 #define TYPE_ASM_OP "\t.type\t"
209 #undef SIZE_ASM_OP
210 #define SIZE_ASM_OP "\t.size\t"
212 /* This is how we tell the assembler that a symbol is weak. */
214 #undef ASM_WEAKEN_LABEL
215 #define ASM_WEAKEN_LABEL(FILE, NAME) \
216 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
217 fputc ('\n', FILE); } while (0)
219 /* This is how we tell the assembler that two symbols have the same value. */
221 #undef ASM_OUTPUT_DEF
222 #define ASM_OUTPUT_DEF(FILE, ALIAS, NAME) \
223 do { \
224 assemble_name(FILE, ALIAS); \
225 fputs(" = ", FILE); \
226 assemble_name(FILE, NAME); \
227 fputc('\n', FILE); \
228 } while (0)
230 #undef ASM_OUTPUT_DEF_FROM_DECLS
231 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET) \
232 do { \
233 const char *alias = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
234 const char *name = IDENTIFIER_POINTER (TARGET); \
235 if (TREE_CODE (DECL) == FUNCTION_DECL) \
237 fputc ('$', FILE); \
238 assemble_name (FILE, alias); \
239 fputs ("..ng = $", FILE); \
240 assemble_name (FILE, name); \
241 fputs ("..ng\n", FILE); \
243 assemble_name(FILE, alias); \
244 fputs(" = ", FILE); \
245 assemble_name(FILE, name); \
246 fputc('\n', FILE); \
247 } while (0)
249 /* The following macro defines the format used to output the second
250 operand of the .type assembler directive. Different svr4 assemblers
251 expect various different forms for this operand. The one given here
252 is just a default. You may need to override it in your machine-
253 specific tm.h file (depending upon the particulars of your assembler). */
255 #undef TYPE_OPERAND_FMT
256 #define TYPE_OPERAND_FMT "@%s"
258 /* Write the extra assembler code needed to declare a function's result.
259 Most svr4 assemblers don't require any special declaration of the
260 result value, but there are exceptions. */
262 #ifndef ASM_DECLARE_RESULT
263 #define ASM_DECLARE_RESULT(FILE, RESULT)
264 #endif
266 /* These macros generate the special .type and .size directives which
267 are used to set the corresponding fields of the linker symbol table
268 entries in an ELF object file under SVR4. These macros also output
269 the starting labels for the relevant functions/objects. */
271 /* Write the extra assembler code needed to declare an object properly. */
273 #undef ASM_DECLARE_OBJECT_NAME
274 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
275 do { \
276 HOST_WIDE_INT size; \
277 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
278 size_directive_output = 0; \
279 if (!flag_inhibit_size_directive \
280 && DECL_SIZE (DECL) \
281 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
283 size_directive_output = 1; \
284 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
286 ASM_OUTPUT_LABEL(FILE, NAME); \
287 } while (0)
289 /* Output the size directive for a decl in rest_of_decl_compilation
290 in the case where we did not do so before the initializer.
291 Once we find the error_mark_node, we know that the value of
292 size_directive_output was set
293 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
295 #undef ASM_FINISH_DECLARE_OBJECT
296 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
297 do { \
298 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
299 HOST_WIDE_INT size; \
300 if (!flag_inhibit_size_directive \
301 && DECL_SIZE (DECL) \
302 && ! AT_END && TOP_LEVEL \
303 && DECL_INITIAL (DECL) == error_mark_node \
304 && !size_directive_output \
305 && (size = int_size_in_bytes (TREE_TYPE (DECL))) > 0) \
307 size_directive_output = 1; \
308 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
310 } while (0)
312 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
313 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
314 corresponds to a particular byte value [0..255]. For any
315 given byte value, if the value in the corresponding table
316 position is zero, the given character can be output directly.
317 If the table value is 1, the byte must be output as a \ooo
318 octal escape. If the tables value is anything else, then the
319 byte value should be output as a \ followed by the value
320 in the table. Note that we can use standard UN*X escape
321 sequences for many control characters, but we don't use
322 \a to represent BEL because some svr4 assemblers (e.g. on
323 the i386) don't know about that. Also, we don't use \v
324 since some versions of gas, such as 2.2 did not accept it. */
326 #undef ESCAPES
327 #define ESCAPES \
328 "\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\
329 \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\
330 \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\
331 \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\
332 \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\
333 \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\
334 \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\
335 \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"
337 /* Some svr4 assemblers have a limit on the number of characters which
338 can appear in the operand of a .string directive. If your assembler
339 has such a limitation, you should define STRING_LIMIT to reflect that
340 limit. Note that at least some svr4 assemblers have a limit on the
341 actual number of bytes in the double-quoted string, and that they
342 count each character in an escape sequence as one byte. Thus, an
343 escape sequence like \377 would count as four bytes.
345 If your target assembler doesn't support the .string directive, you
346 should define this to zero. */
348 #undef STRING_LIMIT
349 #define STRING_LIMIT ((unsigned) 256)
350 #undef STRING_ASM_OP
351 #define STRING_ASM_OP "\t.string\t"
353 /* GAS is the only Alpha/ELF assembler. */
354 #undef TARGET_GAS
355 #define TARGET_GAS (1)
357 /* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
358 (even more) magical crtbegin.o file which provides part of the
359 support for getting C++ file-scope static object constructed
360 before entering `main'. */
362 #undef STARTFILE_SPEC
363 #ifdef HAVE_LD_PIE
364 #define STARTFILE_SPEC \
365 "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
366 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
367 #else
368 #define STARTFILE_SPEC \
369 "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
370 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
371 #endif
373 /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
374 magical crtend.o file which provides part of the support for
375 getting C++ file-scope static object constructed before entering
376 `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
378 #undef ENDFILE_SPEC
379 #define ENDFILE_SPEC \
380 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
381 %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
383 /* We support #pragma. */
384 #define HANDLE_SYSV_PRAGMA 1
386 /* Select a format to encode pointers in exception handling data. CODE
387 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
388 true if the symbol may be affected by dynamic relocations.
390 Since application size is already constrained to <2GB by the form of
391 the ldgp relocation, we can use a 32-bit pc-relative relocation to
392 static data. Dynamic data is accessed indirectly to allow for read
393 only EH sections. */
394 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
395 (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4)
397 /* If defined, a C statement to be executed just prior to the output of
398 assembler code for INSN. */
399 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
400 (alpha_this_literal_sequence_number = 0, \
401 alpha_this_gpdisp_sequence_number = 0)
402 extern int alpha_this_literal_sequence_number;
403 extern int alpha_this_gpdisp_sequence_number;
405 /* Since the bits of the _init and _fini function is spread across
406 many object files, each potentially with its own GP, we must assume
407 we need to load our GP. Further, the .init/.fini section can
408 easily be more than 4MB away from the function to call so we can't
409 use bsr. */
410 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
411 asm (SECTION_OP "\n" \
412 " br $29,1f\n" \
413 "1: ldgp $29,0($29)\n" \
414 " unop\n" \
415 " jsr $26," USER_LABEL_PREFIX #FUNC "\n" \
416 " .align 3\n" \
417 " .previous");
419 /* If we have the capability create headers for efficient EH lookup.
420 As of Jan 2002, only glibc 2.2.4 can actually make use of this, but
421 I imagine that other systems will catch up. In the meantime, it
422 doesn't harm to make sure that the data exists to be used later. */
423 #if defined(HAVE_LD_EH_FRAME_HDR)
424 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
425 #endif