OSDN Git Service

* elfos.h (SELECT_SECTION): Undef before defining.
[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
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 /* The prefix to add to user-visible assembler symbols.
25
26    For ELF systems the convention is *not* to prepend a leading
27    underscore onto user-level symbol names.  */
28
29 #undef  USER_LABEL_PREFIX
30 #define USER_LABEL_PREFIX ""
31
32 /* Biggest alignment supported by the object file format of this
33    machine.  Use this macro to limit the alignment which can be
34    specified using the `__attribute__ ((aligned (N)))' construct.  If
35    not defined, the default value is `BIGGEST_ALIGNMENT'.  */
36 #ifndef MAX_OFILE_ALIGNMENT
37 #define MAX_OFILE_ALIGNMENT (32768 * 8)
38 #endif
39
40 #undef  ENDFILE_SPEC
41 #define ENDFILE_SPEC "crtend.o%s"
42
43 #undef  STARTFILE_SPEC
44 #define STARTFILE_SPEC "%{!shared: \
45                          %{!symbolic: \
46                           %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}\
47                         crtbegin.o%s"
48
49 /* Use periods rather than dollar signs in special g++ assembler names.  */
50
51 #define NO_DOLLAR_IN_LABEL
52
53 /* Writing `int' for a bitfield forces int alignment for the structure.  */
54
55 #define PCC_BITFIELD_TYPE_MATTERS 1
56
57 /* Implicit library calls should use memcpy, not bcopy, etc.  */
58
59 #define TARGET_MEM_FUNCTIONS
60
61 /* Handle #pragma weak and #pragma pack.  */
62
63 #define HANDLE_SYSV_PRAGMA
64
65 /* System V Release 4 uses DWARF debugging info.  */
66
67 #ifndef DWARF_DEBUGGING_INFO
68 #define DWARF_DEBUGGING_INFO 1
69 #endif
70
71 /* All ELF targets can support DWARF-2.  */
72
73 #ifndef DWARF2_DEBUGGING_INFO
74 #define DWARF2_DEBUGGING_INFO 1
75 #endif
76
77 /* Also allow them to support STABS debugging.  */
78
79 #include "dbxelf.h"
80
81 /* The GNU tools operate better with stabs.  Since we don't have
82    any native tools to be compatible with, default to stabs.  */
83
84 #ifndef PREFERRED_DEBUGGING_TYPE
85 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
86 #endif
87
88 /* All SVR4 targets use the ELF object file format.  */
89 #define OBJECT_FORMAT_ELF
90
91
92 /* Output #ident as a .ident.  */
93
94 #define ASM_OUTPUT_IDENT(FILE, NAME) \
95   fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
96
97 /* Attach a special .ident directive to the end of the file to identify
98    the version of GCC which compiled this code.  The format of the
99    .ident string is patterned after the ones produced by native svr4
100    C compilers.  */
101
102 #define IDENT_ASM_OP "\t.ident\t"
103
104 #undef ASM_FILE_END
105 #define ASM_FILE_END(FILE)                              \
106   do                                                    \
107     {                                                   \
108       if (!flag_no_ident)                               \
109         fprintf ((FILE), "%s\"GCC: (GNU) %s\"\n",       \
110                  IDENT_ASM_OP, version_string);         \
111     }                                                   \
112   while (0)
113
114 #undef  ASM_BYTE_OP
115 #define ASM_BYTE_OP     "\t.byte\t"
116
117 #undef  SET_ASM_OP
118 #define SET_ASM_OP      "\t.set\t"
119
120 /* This is how to begin an assembly language file.  Most svr4 assemblers want
121    at least a .file directive to come first, and some want to see a .version
122    directive come right after that.  Here we just establish a default
123    which generates only the .file directive.  If you need a .version
124    directive for any specific target, you should override this definition
125    in the target-specific file which includes this one.  */
126
127 #undef ASM_FILE_START
128 #define ASM_FILE_START(FILE)                            \
129   output_file_directive ((FILE), main_input_filename)
130
131 /* This is how to allocate empty space in some section.  The .zero
132    pseudo-op is used for this on most svr4 assemblers.  */
133
134 #define SKIP_ASM_OP     "\t.zero\t"
135
136 #undef  ASM_OUTPUT_SKIP
137 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
138   fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
139
140 /* This is how to output an internal numbered label where
141    PREFIX is the class of label and NUM is the number within the class.
142
143    For most svr4 systems, the convention is that any symbol which begins
144    with a period is not put into the linker symbol table by the assembler.  */
145
146 #undef  ASM_OUTPUT_INTERNAL_LABEL
147 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM)    \
148   do                                                    \
149     {                                                   \
150       fprintf (FILE, ".%s%d:\n", PREFIX, NUM);          \
151     }                                                   \
152   while (0)
153
154 /* This is how to store into the string LABEL
155    the symbol_ref name of an internal numbered label where
156    PREFIX is the class of label and NUM is the number within the class.
157    This is suitable for output with `assemble_name'.
158
159    For most svr4 systems, the convention is that any symbol which begins
160    with a period is not put into the linker symbol table by the assembler.  */
161
162 #undef  ASM_GENERATE_INTERNAL_LABEL
163 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)         \
164   do                                                            \
165     {                                                           \
166       sprintf (LABEL, "*.%s%u", PREFIX, (unsigned) (NUM));      \
167     }                                                           \
168   while (0)
169
170 /* Output the label which precedes a jumptable.  Note that for all svr4
171    systems where we actually generate jumptables (which is to say every
172    svr4 target except i386, where we use casesi instead) we put the jump-
173    tables into the .rodata section and since other stuff could have been
174    put into the .rodata section prior to any given jumptable, we have to
175    make sure that the location counter for the .rodata section gets pro-
176    perly re-aligned prior to the actual beginning of the jump table.  */
177
178 #define ALIGN_ASM_OP "\t.align\t"
179
180 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
181 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
182   ASM_OUTPUT_ALIGN ((FILE), 2);
183 #endif
184
185 #undef  ASM_OUTPUT_CASE_LABEL
186 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)             \
187   do                                                                    \
188     {                                                                   \
189       ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE)       \
190         ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM);                  \
191     }                                                                   \
192   while (0)
193
194 /* The standard SVR4 assembler seems to require that certain builtin
195    library routines (e.g. .udiv) be explicitly declared as .globl
196    in each assembly file where they are referenced.  */
197
198 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)  \
199   ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
200
201 /* This says how to output assembler code to declare an
202    uninitialized external linkage data object.  Under SVR4,
203    the linker seems to want the alignment of data objects
204    to depend on their types.  We do exactly that here.  */
205
206 #define COMMON_ASM_OP   "\t.comm\t"
207
208 #undef  ASM_OUTPUT_ALIGNED_COMMON
209 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)              \
210   do                                                                    \
211     {                                                                   \
212       fprintf ((FILE), "%s", COMMON_ASM_OP);                            \
213       assemble_name ((FILE), (NAME));                                   \
214       fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);    \
215     }                                                                   \
216   while (0)
217
218 /* This says how to output assembler code to declare an
219    uninitialized internal linkage data object.  Under SVR4,
220    the linker seems to want the alignment of data objects
221    to depend on their types.  We do exactly that here.  */
222
223 #define LOCAL_ASM_OP    "\t.local\t"
224
225 #undef  ASM_OUTPUT_ALIGNED_LOCAL
226 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)       \
227   do                                                            \
228     {                                                           \
229       fprintf ((FILE), "%s", LOCAL_ASM_OP);                     \
230       assemble_name ((FILE), (NAME));                           \
231       fprintf ((FILE), "\n");                                   \
232       ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);      \
233     }                                                           \
234   while (0)
235
236 /* This is the pseudo-op used to generate a reference to a specific
237    symbol in some section.  It is only used in machine-specific
238    configuration files, typically only in ASM_OUTPUT_CONSTRUCTOR and
239    ASM_OUTPUT_DESTRUCTOR.  This is the same for all known svr4
240    assemblers, except those in targets that don't use 32-bit pointers.
241    Those should override INT_ASM_OP.  Yes, the name of the macro is
242    misleading.  */
243
244 #ifndef INT_ASM_OP
245 #define INT_ASM_OP              "\t.long\t"
246 #endif
247
248 /* This is the pseudo-op used to generate a contiguous sequence of byte
249    values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
250    AUTOMATICALLY APPENDED.  This is the same for most svr4 assemblers.  */
251
252 #undef  ASCII_DATA_ASM_OP
253 #define ASCII_DATA_ASM_OP       "\t.ascii\t"
254
255 /* Support const sections and the ctors and dtors sections for g++.
256    Note that there appears to be two different ways to support const
257    sections at the moment.  You can either #define the symbol
258    READONLY_DATA_SECTION (giving it some code which switches to the
259    readonly data section) or else you can #define the symbols
260    EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
261    SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
262
263 #define USE_CONST_SECTION       1
264
265 #define CONST_SECTION_ASM_OP    "\t.section\t.rodata"
266
267 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
268
269    Note that we want to give these sections the SHF_WRITE attribute
270    because these sections will actually contain data (i.e. tables of
271    addresses of functions in the current root executable or shared library
272    file) and, in the case of a shared library, the relocatable addresses
273    will have to be properly resolved/relocated (and then written into) by
274    the dynamic linker when it actually attaches the given shared library
275    to the executing process.  (Note that on SVR4, you may wish to use the
276    `-z text' option to the ELF linker, when building a shared library, as
277    an additional check that you are doing everything right.  But if you do
278    use the `-z text' option when building a shared library, you will get
279    errors unless the .ctors and .dtors sections are marked as writable
280    via the SHF_WRITE attribute.)  */
281
282 #define CTORS_SECTION_ASM_OP    "\t.section\t.ctors,\"aw\""
283 #define DTORS_SECTION_ASM_OP    "\t.section\t.dtors,\"aw\""
284
285 /* On svr4, we *do* have support for the .init and .fini sections, and we
286    can put stuff in there to be executed before and after `main'.  We let
287    crtstuff.c and other files know this by defining the following symbols.
288    The definitions say how to change sections to the .init and .fini
289    sections.  This is the same for all known svr4 assemblers.  */
290
291 #define INIT_SECTION_ASM_OP     "\t.section\t.init"
292 #define FINI_SECTION_ASM_OP     "\t.section\t.fini"
293
294 /* A default list of other sections which we might be "in" at any given
295    time.  For targets that use additional sections (e.g. .tdesc) you
296    should override this definition in the target-specific file which
297    includes this file.  */
298
299 #undef  EXTRA_SECTIONS
300 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors
301
302 /* A default list of extra section function definitions.  For targets
303    that use additional sections (e.g. .tdesc) you should override this
304    definition in the target-specific file which includes this file.  */
305
306 #undef  EXTRA_SECTION_FUNCTIONS
307 #define EXTRA_SECTION_FUNCTIONS         \
308   CONST_SECTION_FUNCTION                \
309   CTORS_SECTION_FUNCTION                \
310   DTORS_SECTION_FUNCTION
311
312 #define READONLY_DATA_SECTION() const_section ()
313
314 #define CONST_SECTION_FUNCTION                                  \
315 void                                                            \
316 const_section ()                                                \
317 {                                                               \
318   if (!USE_CONST_SECTION)                                       \
319     text_section ();                                            \
320   else if (in_section != in_const)                              \
321     {                                                           \
322       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);     \
323       in_section = in_const;                                    \
324     }                                                           \
325 }
326
327 #define CTORS_SECTION_FUNCTION                                  \
328 void                                                            \
329 ctors_section ()                                                \
330 {                                                               \
331   if (in_section != in_ctors)                                   \
332     {                                                           \
333       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);     \
334       in_section = in_ctors;                                    \
335     }                                                           \
336 }
337
338 #define DTORS_SECTION_FUNCTION                                  \
339 void                                                            \
340 dtors_section ()                                                \
341 {                                                               \
342   if (in_section != in_dtors)                                   \
343     {                                                           \
344       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);     \
345       in_section = in_dtors;                                    \
346     }                                                           \
347 }
348
349 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
350
351 #define UNIQUE_SECTION_P(DECL)   (DECL_ONE_ONLY (DECL))
352
353 #define UNIQUE_SECTION(DECL, RELOC)                             \
354   do                                                            \
355     {                                                           \
356       int len;                                                  \
357       int sec;                                                  \
358       const char *name;                                         \
359       char *string;                                             \
360       const char *prefix;                                       \
361       static const char *prefixes[/*4*/3][2] =                  \
362       {                                                         \
363         { ".text.",   ".gnu.linkonce.t." },                     \
364         { ".rodata.", ".gnu.linkonce.r." },                     \
365         { ".data.",   ".gnu.linkonce.d." }                      \
366         /* Do not generate unique sections for uninitialised    \
367            data since we do not have support for this in the    \
368            linker scripts yet...                                \
369         ,{ ".bss.",    ".gnu.linkonce.b." }  */                 \
370       };                                                        \
371                                                                 \
372       if (TREE_CODE (DECL) == FUNCTION_DECL)                    \
373         sec = 0;                                                \
374   /*  else if (DECL_INITIAL (DECL) == 0                         \
375                || DECL_INITIAL (DECL) == error_mark_node)       \
376         sec =  3; */                                            \
377       else if (DECL_READONLY_SECTION (DECL, RELOC))             \
378         sec = 1;                                                \
379       else                                                      \
380         sec = 2;                                                \
381                                                                 \
382       name   = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
383       /* Strip off any encoding in name.  */                    \
384       STRIP_NAME_ENCODING (name, name);                         \
385       prefix = prefixes[sec][DECL_ONE_ONLY(DECL)];              \
386       len    = strlen (name) + strlen (prefix);                 \
387       string = alloca (len + 1);                                \
388                                                                 \
389       sprintf (string, "%s%s", prefix, name);                   \
390                                                                 \
391       DECL_SECTION_NAME (DECL) = build_string (len, string);    \
392     }                                                           \
393   while (0)
394      
395 /* A C statement (sans semicolon) to output an
396    element in the table of global constructors.  */
397 #define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME)                      \
398   do                                                            \
399     {                                                           \
400       ctors_section ();                                         \
401       fprintf (FILE, "%s", INT_ASM_OP);                         \
402       assemble_name (FILE, NAME);                               \
403       fprintf (FILE, "\n");                                     \
404     }                                                           \
405   while (0)
406
407 /* A C statement (sans semicolon) to output an
408    element in the table of global destructors.  */
409 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                        \
410   do                                                            \
411     {                                                           \
412       dtors_section ();                                         \
413       fprintf (FILE, "%s", INT_ASM_OP);                         \
414       assemble_name (FILE, NAME);                               \
415       fprintf (FILE, "\n");                                     \
416     }                                                           \
417   while (0)
418
419 /* Switch into a generic section.
420  
421    We make the section read-only and executable for a function decl,
422    read-only for a const data decl, and writable for a non-const data decl.
423  
424    If the section has already been defined, we must not
425    emit the attributes here. The SVR4 assembler does not
426    recognize section redefinitions.
427    If DECL is NULL, no attributes are emitted.  */
428
429 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)                \
430   do                                                                    \
431     {                                                                   \
432       static htab_t htab;                                               \
433                                                                         \
434       struct section_info                                               \
435       {                                                                 \
436         enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type;              \
437       };                                                                \
438                                                                         \
439       struct section_info *s;                                           \
440       const char *mode;                                                 \
441       enum sect_enum type;                                              \
442       PTR* slot;                                                        \
443                                                                         \
444       /* The names we put in the hashtable will always be the unique    \
445          versions gived to us by the stringtable, so we can just use    \
446          their addresses as the keys.  */                               \
447       if (!htab)                                                        \
448         htab = htab_create (31,                                         \
449                             htab_hash_pointer,                          \
450                             htab_eq_pointer,                            \
451                             NULL);                                      \
452                                                                         \
453       if (DECL && TREE_CODE (DECL) == FUNCTION_DECL)                    \
454         type = SECT_EXEC, mode = "ax";                                  \
455       else if (DECL && DECL_READONLY_SECTION (DECL, RELOC))             \
456         type = SECT_RO, mode = "a";                                     \
457       else                                                              \
458         type = SECT_RW, mode = "aw";                                    \
459                                                                         \
460                                                                         \
461       /* See if we already have an entry for this section.  */          \
462       slot = htab_find_slot (htab, NAME, INSERT);                       \
463       if (!*slot)                                                       \
464         {                                                               \
465           s = (struct section_info *) xmalloc (sizeof (* s));           \
466           s->type = type;                                               \
467           *slot = s;                                                    \
468           fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n",           \
469                    NAME, mode);                                         \
470         }                                                               \
471       else                                                              \
472         {                                                               \
473           s = (struct section_info *) *slot;                            \
474           if (DECL && s->type != type)                                  \
475             error_with_decl (DECL,                                      \
476                              "%s causes a section type conflict");      \
477                                                                         \
478           fprintf (FILE, "\t.section\t%s\n", NAME);                     \
479         }                                                               \
480     }                                                                   \
481   while (0)
482
483 /* A C statement or statements to switch to the appropriate
484    section for output of RTX in mode MODE.  RTX is some kind
485    of constant in RTL.  The argument MODE is redundant except
486    in the case of a `const_int' rtx.  Currently, these always
487    go into the const section.  */
488
489 #undef  SELECT_RTX_SECTION
490 #define SELECT_RTX_SECTION(MODE, RTX) const_section ()
491
492 /* A C statement or statements to switch to the appropriate
493    section for output of DECL.  DECL is either a `VAR_DECL' node
494    or a constant of some sort.  RELOC indicates whether forming
495    the initial value of DECL requires link-time relocations.  */
496
497 #undef SELECT_SECTION
498 #define SELECT_SECTION(DECL, RELOC)                             \
499 {                                                               \
500   if (TREE_CODE (DECL) == STRING_CST)                           \
501     {                                                           \
502       if (! flag_writable_strings)                              \
503         const_section ();                                       \
504       else                                                      \
505         data_section ();                                        \
506     }                                                           \
507   else if (TREE_CODE (DECL) == VAR_DECL)                        \
508     {                                                           \
509       if ((flag_pic && RELOC)                                   \
510           || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)  \
511           || !DECL_INITIAL (DECL)                               \
512           || (DECL_INITIAL (DECL) != error_mark_node            \
513               && !TREE_CONSTANT (DECL_INITIAL (DECL))))         \
514         data_section ();                                        \
515       else                                                      \
516         const_section ();                                       \
517     }                                                           \
518   else if (TREE_CODE (DECL) == CONSTRUCTOR)                     \
519     {                                                           \
520       if ((flag_pic && RELOC)                                   \
521           || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)  \
522           || ! TREE_CONSTANT (DECL))                            \
523         data_section ();                                        \
524       else                                                      \
525         const_section ();                                       \
526     }                                                           \
527   else                                                          \
528     const_section ();                                           \
529 }
530
531 /* Define the strings used for the special svr4 .type and .size directives.
532    These strings generally do not vary from one system running svr4 to
533    another, but if a given system (e.g. m88k running svr) needs to use
534    different pseudo-op names for these, they may be overridden in the
535    file which includes this one.  */
536
537 #define TYPE_ASM_OP     "\t.type\t"
538 #define SIZE_ASM_OP     "\t.size\t"
539
540 /* This is how we tell the assembler that a symbol is weak.  */
541
542 #define ASM_WEAKEN_LABEL(FILE, NAME)    \
543   do                                    \
544     {                                   \
545       fputs ("\t.weak\t", (FILE));      \
546       assemble_name ((FILE), (NAME));   \
547       fputc ('\n', (FILE));             \
548     }                                   \
549   while (0)
550
551 /* The following macro defines the format used to output the second
552    operand of the .type assembler directive.  Different svr4 assemblers
553    expect various different forms for this operand.  The one given here
554    is just a default.  You may need to override it in your machine-
555    specific tm.h file (depending upon the particulars of your assembler).  */
556
557 #define TYPE_OPERAND_FMT        "@%s"
558
559 /* Write the extra assembler code needed to declare a function's result.
560    Most svr4 assemblers don't require any special declaration of the
561    result value, but there are exceptions.  */
562
563 #ifndef ASM_DECLARE_RESULT
564 #define ASM_DECLARE_RESULT(FILE, RESULT)
565 #endif
566
567 /* These macros generate the special .type and .size directives which
568    are used to set the corresponding fields of the linker symbol table
569    entries in an ELF object file under SVR4.  These macros also output
570    the starting labels for the relevant functions/objects.  */
571
572 /* Write the extra assembler code needed to declare a function properly.
573    Some svr4 assemblers need to also have something extra said about the
574    function's return value.  We allow for that here.  */
575
576 #ifndef ASM_DECLARE_FUNCTION_NAME
577 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)     \
578   do                                                    \
579     {                                                   \
580       fprintf (FILE, "%s", TYPE_ASM_OP);                \
581       assemble_name (FILE, NAME);                       \
582       putc (',', FILE);                                 \
583       fprintf (FILE, TYPE_OPERAND_FMT, "function");     \
584       putc ('\n', FILE);                                \
585                                                         \
586       ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));    \
587       ASM_OUTPUT_LABEL(FILE, NAME);                     \
588     }                                                   \
589   while (0)
590 #endif
591
592 /* Write the extra assembler code needed to declare an object properly.  */
593
594 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)               \
595   do                                                            \
596     {                                                           \
597       fprintf (FILE, "%s", TYPE_ASM_OP);                        \
598       assemble_name (FILE, NAME);                               \
599       putc (',', FILE);                                         \
600       fprintf (FILE, TYPE_OPERAND_FMT, "object");               \
601       putc ('\n', FILE);                                        \
602                                                                 \
603       size_directive_output = 0;                                \
604                                                                 \
605       if (!flag_inhibit_size_directive                          \
606           && (DECL) && DECL_SIZE (DECL))                        \
607         {                                                       \
608           size_directive_output = 1;                            \
609           fprintf (FILE, "%s", SIZE_ASM_OP);                    \
610           assemble_name (FILE, NAME);                           \
611           putc (',', FILE);                                     \
612           fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,               \
613                    int_size_in_bytes (TREE_TYPE (DECL)));       \
614           fputc ('\n', FILE);                                   \
615         }                                                       \
616                                                                 \
617       ASM_OUTPUT_LABEL (FILE, NAME);                            \
618     }                                                           \
619   while (0)
620
621 /* Output the size directive for a decl in rest_of_decl_compilation
622    in the case where we did not do so before the initializer.
623    Once we find the error_mark_node, we know that the value of
624    size_directive_output was set
625    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
626
627 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
628   do                                                            \
629     {                                                           \
630       const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);   \
631                                                                 \
632       if (!flag_inhibit_size_directive                          \
633           && DECL_SIZE (DECL)                                   \
634           && ! AT_END && TOP_LEVEL                              \
635           && DECL_INITIAL (DECL) == error_mark_node             \
636           && !size_directive_output)                            \
637         {                                                       \
638           size_directive_output = 1;                            \
639           fprintf (FILE, "%s", SIZE_ASM_OP);                    \
640           assemble_name (FILE, name);                           \
641           putc (',', FILE);                                     \
642           fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,               \
643                    int_size_in_bytes (TREE_TYPE (DECL)));       \
644           fputc ('\n', FILE);                                   \
645         }                                                       \
646     }                                                           \
647   while (0)
648
649 /* This is how to declare the size of a function.  */
650 #ifndef ASM_DECLARE_FUNCTION_SIZE
651 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)            \
652   do                                                            \
653     {                                                           \
654       if (!flag_inhibit_size_directive)                         \
655         {                                                       \
656           char label[256];                                      \
657           static int labelno;                                   \
658                                                                 \
659           labelno++;                                            \
660                                                                 \
661           ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);  \
662           ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);     \
663                                                                 \
664           fprintf (FILE, "%s", SIZE_ASM_OP);                    \
665           assemble_name (FILE, (FNAME));                        \
666           fprintf (FILE, ",");                                  \
667           assemble_name (FILE, label);                          \
668           fprintf (FILE, "-");                                  \
669           assemble_name (FILE, (FNAME));                        \
670           putc ('\n', FILE);                                    \
671         }                                                       \
672     }                                                           \
673   while (0)
674 #endif
675
676 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
677    ASM_OUTPUT_LIMITED_STRING macros.  Each byte in the table
678    corresponds to a particular byte value [0..255].  For any
679    given byte value, if the value in the corresponding table
680    position is zero, the given character can be output directly.
681    If the table value is 1, the byte must be output as a \ooo
682    octal escape.  If the tables value is anything else, then the
683    byte value should be output as a \ followed by the value
684    in the table.  Note that we can use standard UN*X escape
685    sequences for many control characters, but we don't use
686    \a to represent BEL because some svr4 assemblers (e.g. on
687    the i386) don't know about that.  Also, we don't use \v
688    since some versions of gas, such as 2.2 did not accept it.  */
689
690 #define ESCAPES \
691 "\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\
692 \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\
693 \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\
694 \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\
695 \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\
696 \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\
697 \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\
698 \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"
699
700 /* Some svr4 assemblers have a limit on the number of characters which
701    can appear in the operand of a .string directive.  If your assembler
702    has such a limitation, you should define STRING_LIMIT to reflect that
703    limit.  Note that at least some svr4 assemblers have a limit on the
704    actual number of bytes in the double-quoted string, and that they
705    count each character in an escape sequence as one byte.  Thus, an
706    escape sequence like \377 would count as four bytes.
707
708    If your target assembler doesn't support the .string directive, you
709    should define this to zero.
710 */
711
712 #define STRING_LIMIT    ((unsigned) 256)
713
714 #define STRING_ASM_OP   "\t.string\t"
715
716 /* The routine used to output NUL terminated strings.  We use a special
717    version of this for most svr4 targets because doing so makes the
718    generated assembly code more compact (and thus faster to assemble)
719    as well as more readable, especially for targets like the i386
720    (where the only alternative is to output character sequences as
721    comma separated lists of numbers).   */
722
723 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR)            \
724   do                                                    \
725     {                                                   \
726       register const unsigned char *_limited_str =      \
727         (const unsigned char *) (STR);                  \
728       register unsigned ch;                             \
729                                                         \
730       fprintf ((FILE), "%s\"", STRING_ASM_OP);          \
731                                                         \
732       for (; (ch = *_limited_str); _limited_str++)      \
733         {                                               \
734           register int escape;                          \
735                                                         \
736           switch (escape = ESCAPES[ch])                 \
737             {                                           \
738             case 0:                                     \
739               putc (ch, (FILE));                        \
740               break;                                    \
741             case 1:                                     \
742               fprintf ((FILE), "\\%03o", ch);           \
743               break;                                    \
744             default:                                    \
745               putc ('\\', (FILE));                      \
746               putc (escape, (FILE));                    \
747               break;                                    \
748             }                                           \
749         }                                               \
750                                                         \
751       fprintf ((FILE), "\"\n");                         \
752     }                                                   \
753   while (0)
754
755 /* The routine used to output sequences of byte values.  We use a special
756    version of this for most svr4 targets because doing so makes the
757    generated assembly code more compact (and thus faster to assemble)
758    as well as more readable.  Note that if we find subparts of the
759    character sequence which end with NUL (and which are shorter than
760    STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING.  */
761
762 #undef  ASM_OUTPUT_ASCII
763 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)                             \
764   do                                                                    \
765     {                                                                   \
766       register const unsigned char *_ascii_bytes =                      \
767         (const unsigned char *) (STR);                                  \
768       register const unsigned char *limit = _ascii_bytes + (LENGTH);    \
769       register unsigned bytes_in_chunk = 0;                             \
770                                                                         \
771       for (; _ascii_bytes < limit; _ascii_bytes++)                      \
772         {                                                               \
773           register const unsigned char *p;                              \
774                                                                         \
775           if (bytes_in_chunk >= 60)                                     \
776             {                                                           \
777               fprintf ((FILE), "\"\n");                                 \
778               bytes_in_chunk = 0;                                       \
779             }                                                           \
780                                                                         \
781           for (p = _ascii_bytes; p < limit && *p != '\0'; p++)          \
782             continue;                                                   \
783                                                                         \
784           if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT)    \
785             {                                                           \
786               if (bytes_in_chunk > 0)                                   \
787                 {                                                       \
788                   fprintf ((FILE), "\"\n");                             \
789                   bytes_in_chunk = 0;                                   \
790                 }                                                       \
791                                                                         \
792               ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);         \
793               _ascii_bytes = p;                                         \
794             }                                                           \
795           else                                                          \
796             {                                                           \
797               register int escape;                                      \
798               register unsigned ch;                                     \
799                                                                         \
800               if (bytes_in_chunk == 0)                                  \
801                 fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP);            \
802                                                                         \
803               switch (escape = ESCAPES[ch = *_ascii_bytes])             \
804                 {                                                       \
805                 case 0:                                                 \
806                   putc (ch, (FILE));                                    \
807                   bytes_in_chunk++;                                     \
808                   break;                                                \
809                 case 1:                                                 \
810                   fprintf ((FILE), "\\%03o", ch);                       \
811                   bytes_in_chunk += 4;                                  \
812                   break;                                                \
813                 default:                                                \
814                   putc ('\\', (FILE));                                  \
815                   putc (escape, (FILE));                                \
816                   bytes_in_chunk += 2;                                  \
817                   break;                                                \
818                 }                                                       \
819             }                                                           \
820         }                                                               \
821                                                                         \
822       if (bytes_in_chunk > 0)                                           \
823         fprintf ((FILE), "\"\n");                                       \
824     }                                                                   \
825   while (0)