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