OSDN Git Service

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