OSDN Git Service

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