OSDN Git Service

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