OSDN Git Service

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