Import a stripped down version of gcc-4.1.1
[dragonfly.git] / contrib / gcc-4.1 / gcc / config / elfos.h
1 /* elfos.h  --  operating system specific defines to be used when
2    targeting GCC for some generic ELF system
3    Copyright (C) 1991, 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004
4    Free Software Foundation, Inc.
5    Based on svr4.h contributed by Ron Guilmette (rfg@netcom.com).
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 GCC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING.  If not, write to
21 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA.  */
23
24 #define TARGET_OBJFMT_CPP_BUILTINS()            \
25   do                                            \
26     {                                           \
27         builtin_define ("__ELF__");             \
28     }                                           \
29   while (0)
30
31 /* Define a symbol indicating that we are using elfos.h.
32    Some CPU specific configuration files use this.  */
33 #define USING_ELFOS_H
34
35 /* The prefix to add to user-visible assembler symbols.
36
37    For ELF systems the convention is *not* to prepend a leading
38    underscore onto user-level symbol names.  */
39
40 #undef  USER_LABEL_PREFIX
41 #define USER_LABEL_PREFIX ""
42
43 /* Biggest alignment supported by the object file format of this
44    machine.  Use this macro to limit the alignment which can be
45    specified using the `__attribute__ ((aligned (N)))' construct.  If
46    not defined, the default value is `BIGGEST_ALIGNMENT'.  */
47 #ifndef MAX_OFILE_ALIGNMENT
48 #define MAX_OFILE_ALIGNMENT (32768 * 8)
49 #endif
50
51 /* Use periods rather than dollar signs in special g++ assembler names.  */
52
53 #define NO_DOLLAR_IN_LABEL
54
55 /* Writing `int' for a bit-field forces int alignment for the structure.  */
56
57 #ifndef PCC_BITFIELD_TYPE_MATTERS
58 #define PCC_BITFIELD_TYPE_MATTERS 1
59 #endif
60
61 /* Handle #pragma weak and #pragma pack.  */
62
63 #define HANDLE_SYSV_PRAGMA 1
64
65 /* All ELF targets can support DWARF-2.  */
66
67 #define DWARF2_DEBUGGING_INFO 1
68
69 /* The GNU tools operate better with dwarf2, and it is required by some
70    psABI's.  Since we don't have any native tools to be compatible with,
71    default to dwarf2.  */
72
73 #ifndef PREFERRED_DEBUGGING_TYPE
74 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
75 #endif
76
77 /* All SVR4 targets use the ELF object file format.  */
78 #define OBJECT_FORMAT_ELF
79
80
81 /* Output #ident as a .ident.  */
82
83 #define ASM_OUTPUT_IDENT(FILE, NAME) \
84   fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
85
86 #define IDENT_ASM_OP "\t.ident\t"
87
88 #undef  SET_ASM_OP
89 #define SET_ASM_OP      "\t.set\t"
90
91 /* Most svr4 assemblers want a .file directive at the beginning of
92    their input file.  */
93 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
94
95 /* This is how to allocate empty space in some section.  The .zero
96    pseudo-op is used for this on most svr4 assemblers.  */
97
98 #define SKIP_ASM_OP     "\t.zero\t"
99
100 #undef  ASM_OUTPUT_SKIP
101 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
102    fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
103             SKIP_ASM_OP, (SIZE))
104
105 /* This is how to store into the string LABEL
106    the symbol_ref name of an internal numbered label where
107    PREFIX is the class of label and NUM is the number within the class.
108    This is suitable for output with `assemble_name'.
109
110    For most svr4 systems, the convention is that any symbol which begins
111    with a period is not put into the linker symbol table by the assembler.  */
112
113 #undef  ASM_GENERATE_INTERNAL_LABEL
114 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)         \
115   do                                                            \
116     {                                                           \
117       sprintf (LABEL, "*.%s%u", PREFIX, (unsigned) (NUM));      \
118     }                                                           \
119   while (0)
120
121 /* Output the label which precedes a jumptable.  Note that for all svr4
122    systems where we actually generate jumptables (which is to say every
123    svr4 target except i386, where we use casesi instead) we put the jump-
124    tables into the .rodata section and since other stuff could have been
125    put into the .rodata section prior to any given jumptable, we have to
126    make sure that the location counter for the .rodata section gets pro-
127    perly re-aligned prior to the actual beginning of the jump table.  */
128
129 #undef ALIGN_ASM_OP
130 #define ALIGN_ASM_OP "\t.align\t"
131
132 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
133 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
134   ASM_OUTPUT_ALIGN ((FILE), 2);
135 #endif
136
137 #undef  ASM_OUTPUT_CASE_LABEL
138 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)             \
139   do                                                                    \
140     {                                                                   \
141       ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE)       \
142         (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM);                  \
143     }                                                                   \
144   while (0)
145
146 /* The standard SVR4 assembler seems to require that certain builtin
147    library routines (e.g. .udiv) be explicitly declared as .globl
148    in each assembly file where they are referenced.  */
149
150 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)  \
151   (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0))
152
153 /* This says how to output assembler code to declare an
154    uninitialized external linkage data object.  Under SVR4,
155    the linker seems to want the alignment of data objects
156    to depend on their types.  We do exactly that here.  */
157
158 #define COMMON_ASM_OP   "\t.comm\t"
159
160 #undef  ASM_OUTPUT_ALIGNED_COMMON
161 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)              \
162   do                                                                    \
163     {                                                                   \
164       fprintf ((FILE), "%s", COMMON_ASM_OP);                            \
165       assemble_name ((FILE), (NAME));                                   \
166       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",          \
167                (SIZE), (ALIGN) / BITS_PER_UNIT);                        \
168     }                                                                   \
169   while (0)
170
171 /* This says how to output assembler code to declare an
172    uninitialized internal linkage data object.  Under SVR4,
173    the linker seems to want the alignment of data objects
174    to depend on their types.  We do exactly that here.  */
175
176 #define LOCAL_ASM_OP    "\t.local\t"
177
178 #undef  ASM_OUTPUT_ALIGNED_LOCAL
179 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)       \
180   do                                                            \
181     {                                                           \
182       fprintf ((FILE), "%s", LOCAL_ASM_OP);                     \
183       assemble_name ((FILE), (NAME));                           \
184       fprintf ((FILE), "\n");                                   \
185       ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);      \
186     }                                                           \
187   while (0)
188
189 /* This is the pseudo-op used to generate a contiguous sequence of byte
190    values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
191    AUTOMATICALLY APPENDED.  This is the same for most svr4 assemblers.  */
192
193 #undef  ASCII_DATA_ASM_OP
194 #define ASCII_DATA_ASM_OP       "\t.ascii\t"
195
196 /* Support a read-only data section.  */
197 #define READONLY_DATA_SECTION_ASM_OP    "\t.section\t.rodata"
198
199 /* On svr4, we *do* have support for the .init and .fini sections, and we
200    can put stuff in there to be executed before and after `main'.  We let
201    crtstuff.c and other files know this by defining the following symbols.
202    The definitions say how to change sections to the .init and .fini
203    sections.  This is the same for all known svr4 assemblers.  */
204
205 #define INIT_SECTION_ASM_OP     "\t.section\t.init"
206 #define FINI_SECTION_ASM_OP     "\t.section\t.fini"
207
208 /* Output assembly directive to move to the beginning of current section.  */
209 #ifdef HAVE_GAS_SUBSECTION_ORDERING
210 # define ASM_SECTION_START_OP   "\t.subsection\t-1"
211 # define ASM_OUTPUT_SECTION_START(FILE) \
212   fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
213 #endif
214
215 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
216
217 /* Switch into a generic section.  */
218 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
219
220 #undef  TARGET_ASM_SELECT_RTX_SECTION
221 #define TARGET_ASM_SELECT_RTX_SECTION default_elf_select_rtx_section
222 #undef  TARGET_ASM_SELECT_SECTION
223 #define TARGET_ASM_SELECT_SECTION default_elf_select_section
224
225 /* Define the strings used for the special svr4 .type and .size directives.
226    These strings generally do not vary from one system running svr4 to
227    another, but if a given system (e.g. m88k running svr) needs to use
228    different pseudo-op names for these, they may be overridden in the
229    file which includes this one.  */
230
231 #define TYPE_ASM_OP     "\t.type\t"
232 #define SIZE_ASM_OP     "\t.size\t"
233
234 /* This is how we tell the assembler that a symbol is weak.  */
235
236 #define ASM_WEAKEN_LABEL(FILE, NAME)    \
237   do                                    \
238     {                                   \
239       fputs ("\t.weak\t", (FILE));      \
240       assemble_name ((FILE), (NAME));   \
241       fputc ('\n', (FILE));             \
242     }                                   \
243   while (0)
244
245 /* The following macro defines the format used to output the second
246    operand of the .type assembler directive.  Different svr4 assemblers
247    expect various different forms for this operand.  The one given here
248    is just a default.  You may need to override it in your machine-
249    specific tm.h file (depending upon the particulars of your assembler).  */
250
251 #define TYPE_OPERAND_FMT        "@%s"
252
253 /* Write the extra assembler code needed to declare a function's result.
254    Most svr4 assemblers don't require any special declaration of the
255    result value, but there are exceptions.  */
256
257 #ifndef ASM_DECLARE_RESULT
258 #define ASM_DECLARE_RESULT(FILE, RESULT)
259 #endif
260
261 /* These macros generate the special .type and .size directives which
262    are used to set the corresponding fields of the linker symbol table
263    entries in an ELF object file under SVR4.  These macros also output
264    the starting labels for the relevant functions/objects.  */
265
266 /* Write the extra assembler code needed to declare a function properly.
267    Some svr4 assemblers need to also have something extra said about the
268    function's return value.  We allow for that here.  */
269
270 #ifndef ASM_DECLARE_FUNCTION_NAME
271 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)             \
272   do                                                            \
273     {                                                           \
274       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");       \
275       ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));            \
276       ASM_OUTPUT_LABEL (FILE, NAME);                            \
277     }                                                           \
278   while (0)
279 #endif
280
281 /* Write the extra assembler code needed to declare an object properly.  */
282
283 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)               \
284   do                                                            \
285     {                                                           \
286       HOST_WIDE_INT size;                                       \
287                                                                 \
288       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");         \
289                                                                 \
290       size_directive_output = 0;                                \
291       if (!flag_inhibit_size_directive                          \
292           && (DECL) && DECL_SIZE (DECL))                        \
293         {                                                       \
294           size_directive_output = 1;                            \
295           size = int_size_in_bytes (TREE_TYPE (DECL));          \
296           ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);         \
297         }                                                       \
298                                                                 \
299       ASM_OUTPUT_LABEL (FILE, NAME);                            \
300     }                                                           \
301   while (0)
302
303 /* Output the size directive for a decl in rest_of_decl_compilation
304    in the case where we did not do so before the initializer.
305    Once we find the error_mark_node, we know that the value of
306    size_directive_output was set
307    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
308
309 #undef ASM_FINISH_DECLARE_OBJECT
310 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
311   do                                                            \
312     {                                                           \
313       const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);   \
314       HOST_WIDE_INT size;                                       \
315                                                                 \
316       if (!flag_inhibit_size_directive                          \
317           && DECL_SIZE (DECL)                                   \
318           && ! AT_END && TOP_LEVEL                              \
319           && DECL_INITIAL (DECL) == error_mark_node             \
320           && !size_directive_output)                            \
321         {                                                       \
322           size_directive_output = 1;                            \
323           size = int_size_in_bytes (TREE_TYPE (DECL));          \
324           ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);         \
325         }                                                       \
326     }                                                           \
327   while (0)
328
329 /* This is how to declare the size of a function.  */
330 #ifndef ASM_DECLARE_FUNCTION_SIZE
331 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)            \
332   do                                                            \
333     {                                                           \
334       if (!flag_inhibit_size_directive)                         \
335         ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME);                 \
336     }                                                           \
337   while (0)
338 #endif
339
340 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
341    ASM_OUTPUT_LIMITED_STRING macros.  Each byte in the table
342    corresponds to a particular byte value [0..255].  For any
343    given byte value, if the value in the corresponding table
344    position is zero, the given character can be output directly.
345    If the table value is 1, the byte must be output as a \ooo
346    octal escape.  If the tables value is anything else, then the
347    byte value should be output as a \ followed by the value
348    in the table.  Note that we can use standard UN*X escape
349    sequences for many control characters, but we don't use
350    \a to represent BEL because some svr4 assemblers (e.g. on
351    the i386) don't know about that.  Also, we don't use \v
352    since some versions of gas, such as 2.2 did not accept it.  */
353
354 #define ESCAPES \
355 "\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\
356 \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\
357 \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\
358 \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\
359 \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\
360 \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\
361 \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\
362 \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"
363
364 /* Some svr4 assemblers have a limit on the number of characters which
365    can appear in the operand of a .string directive.  If your assembler
366    has such a limitation, you should define STRING_LIMIT to reflect that
367    limit.  Note that at least some svr4 assemblers have a limit on the
368    actual number of bytes in the double-quoted string, and that they
369    count each character in an escape sequence as one byte.  Thus, an
370    escape sequence like \377 would count as four bytes.
371
372    If your target assembler doesn't support the .string directive, you
373    should define this to zero.
374 */
375
376 #define STRING_LIMIT    ((unsigned) 256)
377
378 #define STRING_ASM_OP   "\t.string\t"
379
380 /* The routine used to output NUL terminated strings.  We use a special
381    version of this for most svr4 targets because doing so makes the
382    generated assembly code more compact (and thus faster to assemble)
383    as well as more readable, especially for targets like the i386
384    (where the only alternative is to output character sequences as
385    comma separated lists of numbers).  */
386
387 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR)            \
388   do                                                    \
389     {                                                   \
390       register const unsigned char *_limited_str =      \
391         (const unsigned char *) (STR);                  \
392       register unsigned ch;                             \
393                                                         \
394       fprintf ((FILE), "%s\"", STRING_ASM_OP);          \
395                                                         \
396       for (; (ch = *_limited_str); _limited_str++)      \
397         {                                               \
398           register int escape;                          \
399                                                         \
400           switch (escape = ESCAPES[ch])                 \
401             {                                           \
402             case 0:                                     \
403               putc (ch, (FILE));                        \
404               break;                                    \
405             case 1:                                     \
406               fprintf ((FILE), "\\%03o", ch);           \
407               break;                                    \
408             default:                                    \
409               putc ('\\', (FILE));                      \
410               putc (escape, (FILE));                    \
411               break;                                    \
412             }                                           \
413         }                                               \
414                                                         \
415       fprintf ((FILE), "\"\n");                         \
416     }                                                   \
417   while (0)
418
419 /* The routine used to output sequences of byte values.  We use a special
420    version of this for most svr4 targets because doing so makes the
421    generated assembly code more compact (and thus faster to assemble)
422    as well as more readable.  Note that if we find subparts of the
423    character sequence which end with NUL (and which are shorter than
424    STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING.  */
425
426 #undef  ASM_OUTPUT_ASCII
427 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)                             \
428   do                                                                    \
429     {                                                                   \
430       register const unsigned char *_ascii_bytes =                      \
431         (const unsigned char *) (STR);                                  \
432       register const unsigned char *limit = _ascii_bytes + (LENGTH);    \
433       register unsigned bytes_in_chunk = 0;                             \
434                                                                         \
435       for (; _ascii_bytes < limit; _ascii_bytes++)                      \
436         {                                                               \
437           register const unsigned char *p;                              \
438                                                                         \
439           if (bytes_in_chunk >= 60)                                     \
440             {                                                           \
441               fprintf ((FILE), "\"\n");                                 \
442               bytes_in_chunk = 0;                                       \
443             }                                                           \
444                                                                         \
445           for (p = _ascii_bytes; p < limit && *p != '\0'; p++)          \
446             continue;                                                   \
447                                                                         \
448           if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT)    \
449             {                                                           \
450               if (bytes_in_chunk > 0)                                   \
451                 {                                                       \
452                   fprintf ((FILE), "\"\n");                             \
453                   bytes_in_chunk = 0;                                   \
454                 }                                                       \
455                                                                         \
456               ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);         \
457               _ascii_bytes = p;                                         \
458             }                                                           \
459           else                                                          \
460             {                                                           \
461               register int escape;                                      \
462               register unsigned ch;                                     \
463                                                                         \
464               if (bytes_in_chunk == 0)                                  \
465                 fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP);            \
466                                                                         \
467               switch (escape = ESCAPES[ch = *_ascii_bytes])             \
468                 {                                                       \
469                 case 0:                                                 \
470                   putc (ch, (FILE));                                    \
471                   bytes_in_chunk++;                                     \
472                   break;                                                \
473                 case 1:                                                 \
474                   fprintf ((FILE), "\\%03o", ch);                       \
475                   bytes_in_chunk += 4;                                  \
476                   break;                                                \
477                 default:                                                \
478                   putc ('\\', (FILE));                                  \
479                   putc (escape, (FILE));                                \
480                   bytes_in_chunk += 2;                                  \
481                   break;                                                \
482                 }                                                       \
483             }                                                           \
484         }                                                               \
485                                                                         \
486       if (bytes_in_chunk > 0)                                           \
487         fprintf ((FILE), "\"\n");                                       \
488     }                                                                   \
489   while (0)