OSDN Git Service

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