OSDN Git Service

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