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).
7 This file is part of GNU CC.
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)
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.
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. */
24 /* The prefix to add to user-visible assembler symbols.
26 For ELF systems the convention is *not* to prepend a leading
27 underscore onto user-level symbol names. */
29 #undef USER_LABEL_PREFIX
30 #define USER_LABEL_PREFIX ""
32 /* Biggest alignment supported by the object file format of this
33 machine. Use this macro to limit the alignment which can be
34 specified using the `__attribute__ ((aligned (N)))' construct. If
35 not defined, the default value is `BIGGEST_ALIGNMENT'. */
36 #ifndef MAX_OFILE_ALIGNMENT
37 #define MAX_OFILE_ALIGNMENT (32768 * 8)
41 #define ENDFILE_SPEC "crtend.o%s"
44 #define STARTFILE_SPEC "%{!shared: \
46 %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}\
49 /* Use periods rather than dollar signs in special g++ assembler names. */
51 #define NO_DOLLAR_IN_LABEL
53 /* Writing `int' for a bitfield forces int alignment for the structure. */
55 #define PCC_BITFIELD_TYPE_MATTERS 1
57 /* Implicit library calls should use memcpy, not bcopy, etc. */
59 #define TARGET_MEM_FUNCTIONS
61 /* Handle #pragma weak and #pragma pack. */
63 #define HANDLE_SYSV_PRAGMA
65 /* System V Release 4 uses DWARF debugging info. */
67 #ifndef DWARF_DEBUGGING_INFO
68 #define DWARF_DEBUGGING_INFO 1
71 /* All ELF targets can support DWARF-2. */
73 #ifndef DWARF2_DEBUGGING_INFO
74 #define DWARF2_DEBUGGING_INFO 1
77 /* Also allow them to support STABS debugging. */
81 /* The GNU tools operate better with stabs. Since we don't have
82 any native tools to be compatible with, default to stabs. */
84 #ifndef PREFERRED_DEBUGGING_TYPE
85 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
88 /* All SVR4 targets use the ELF object file format. */
89 #define OBJECT_FORMAT_ELF
92 /* Output #ident as a .ident. */
94 #define ASM_OUTPUT_IDENT(FILE, NAME) \
95 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
97 /* Attach a special .ident directive to the end of the file to identify
98 the version of GCC which compiled this code. The format of the
99 .ident string is patterned after the ones produced by native svr4
102 #define IDENT_ASM_OP "\t.ident\t"
105 #define ASM_FILE_END(FILE) \
108 if (!flag_no_ident) \
109 fprintf ((FILE), "%s\"GCC: (GNU) %s\"\n", \
110 IDENT_ASM_OP, version_string); \
115 #define ASM_BYTE_OP "\t.byte\t"
118 #define SET_ASM_OP "\t.set\t"
120 /* This is how to begin an assembly language file. Most svr4 assemblers want
121 at least a .file directive to come first, and some want to see a .version
122 directive come right after that. Here we just establish a default
123 which generates only the .file directive. If you need a .version
124 directive for any specific target, you should override this definition
125 in the target-specific file which includes this one. */
127 #undef ASM_FILE_START
128 #define ASM_FILE_START(FILE) \
129 output_file_directive ((FILE), main_input_filename)
131 /* This is how to allocate empty space in some section. The .zero
132 pseudo-op is used for this on most svr4 assemblers. */
134 #define SKIP_ASM_OP "\t.zero\t"
136 #undef ASM_OUTPUT_SKIP
137 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
138 fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
140 /* This is how to output an internal numbered label where
141 PREFIX is the class of label and NUM is the number within the class.
143 For most svr4 systems, the convention is that any symbol which begins
144 with a period is not put into the linker symbol table by the assembler. */
146 #undef ASM_OUTPUT_INTERNAL_LABEL
147 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
150 fprintf (FILE, ".%s%d:\n", PREFIX, NUM); \
154 /* This is how to store into the string LABEL
155 the symbol_ref name of an internal numbered label where
156 PREFIX is the class of label and NUM is the number within the class.
157 This is suitable for output with `assemble_name'.
159 For most svr4 systems, the convention is that any symbol which begins
160 with a period is not put into the linker symbol table by the assembler. */
162 #undef ASM_GENERATE_INTERNAL_LABEL
163 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
166 sprintf (LABEL, "*.%s%u", PREFIX, (unsigned) (NUM)); \
170 /* Output the label which precedes a jumptable. Note that for all svr4
171 systems where we actually generate jumptables (which is to say every
172 svr4 target except i386, where we use casesi instead) we put the jump-
173 tables into the .rodata section and since other stuff could have been
174 put into the .rodata section prior to any given jumptable, we have to
175 make sure that the location counter for the .rodata section gets pro-
176 perly re-aligned prior to the actual beginning of the jump table. */
178 #define ALIGN_ASM_OP "\t.align\t"
180 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
181 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
182 ASM_OUTPUT_ALIGN ((FILE), 2);
185 #undef ASM_OUTPUT_CASE_LABEL
186 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
189 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
190 ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \
194 /* The standard SVR4 assembler seems to require that certain builtin
195 library routines (e.g. .udiv) be explicitly declared as .globl
196 in each assembly file where they are referenced. */
198 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
199 ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
201 /* This says how to output assembler code to declare an
202 uninitialized external linkage data object. Under SVR4,
203 the linker seems to want the alignment of data objects
204 to depend on their types. We do exactly that here. */
206 #define COMMON_ASM_OP "\t.comm\t"
208 #undef ASM_OUTPUT_ALIGNED_COMMON
209 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
212 fprintf ((FILE), "%s", COMMON_ASM_OP); \
213 assemble_name ((FILE), (NAME)); \
214 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
218 /* This says how to output assembler code to declare an
219 uninitialized internal linkage data object. Under SVR4,
220 the linker seems to want the alignment of data objects
221 to depend on their types. We do exactly that here. */
223 #define LOCAL_ASM_OP "\t.local\t"
225 #undef ASM_OUTPUT_ALIGNED_LOCAL
226 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
229 fprintf ((FILE), "%s", LOCAL_ASM_OP); \
230 assemble_name ((FILE), (NAME)); \
231 fprintf ((FILE), "\n"); \
232 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
236 /* This is the pseudo-op used to generate a reference to a specific
237 symbol in some section. It is only used in machine-specific
238 configuration files, typically only in ASM_OUTPUT_CONSTRUCTOR and
239 ASM_OUTPUT_DESTRUCTOR. This is the same for all known svr4
240 assemblers, except those in targets that don't use 32-bit pointers.
241 Those should override INT_ASM_OP. Yes, the name of the macro is
245 #define INT_ASM_OP "\t.long\t"
248 /* This is the pseudo-op used to generate a contiguous sequence of byte
249 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
250 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
252 #undef ASCII_DATA_ASM_OP
253 #define ASCII_DATA_ASM_OP "\t.ascii\t"
255 /* Support const sections and the ctors and dtors sections for g++.
256 Note that there appears to be two different ways to support const
257 sections at the moment. You can either #define the symbol
258 READONLY_DATA_SECTION (giving it some code which switches to the
259 readonly data section) or else you can #define the symbols
260 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
261 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
263 #define USE_CONST_SECTION 1
265 #define CONST_SECTION_ASM_OP "\t.section\t.rodata"
267 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
269 Note that we want to give these sections the SHF_WRITE attribute
270 because these sections will actually contain data (i.e. tables of
271 addresses of functions in the current root executable or shared library
272 file) and, in the case of a shared library, the relocatable addresses
273 will have to be properly resolved/relocated (and then written into) by
274 the dynamic linker when it actually attaches the given shared library
275 to the executing process. (Note that on SVR4, you may wish to use the
276 `-z text' option to the ELF linker, when building a shared library, as
277 an additional check that you are doing everything right. But if you do
278 use the `-z text' option when building a shared library, you will get
279 errors unless the .ctors and .dtors sections are marked as writable
280 via the SHF_WRITE attribute.) */
282 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
283 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
285 /* On svr4, we *do* have support for the .init and .fini sections, and we
286 can put stuff in there to be executed before and after `main'. We let
287 crtstuff.c and other files know this by defining the following symbols.
288 The definitions say how to change sections to the .init and .fini
289 sections. This is the same for all known svr4 assemblers. */
291 #define INIT_SECTION_ASM_OP "\t.section\t.init"
292 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
294 /* A default list of other sections which we might be "in" at any given
295 time. For targets that use additional sections (e.g. .tdesc) you
296 should override this definition in the target-specific file which
297 includes this file. */
299 #undef EXTRA_SECTIONS
300 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors
302 /* A default list of extra section function definitions. For targets
303 that use additional sections (e.g. .tdesc) you should override this
304 definition in the target-specific file which includes this file. */
306 #undef EXTRA_SECTION_FUNCTIONS
307 #define EXTRA_SECTION_FUNCTIONS \
308 CONST_SECTION_FUNCTION \
309 CTORS_SECTION_FUNCTION \
310 DTORS_SECTION_FUNCTION
312 #define READONLY_DATA_SECTION() const_section ()
314 #define CONST_SECTION_FUNCTION \
318 if (!USE_CONST_SECTION) \
320 else if (in_section != in_const) \
322 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
323 in_section = in_const; \
327 #define CTORS_SECTION_FUNCTION \
331 if (in_section != in_ctors) \
333 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
334 in_section = in_ctors; \
338 #define DTORS_SECTION_FUNCTION \
342 if (in_section != in_dtors) \
344 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
345 in_section = in_dtors; \
349 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
351 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
353 #define UNIQUE_SECTION(DECL, RELOC) \
360 const char *prefix; \
361 static const char *prefixes[/*4*/3][2] = \
363 { ".text.", ".gnu.linkonce.t." }, \
364 { ".rodata.", ".gnu.linkonce.r." }, \
365 { ".data.", ".gnu.linkonce.d." } \
366 /* Do not generate unique sections for uninitialised \
367 data since we do not have support for this in the \
368 linker scripts yet... \
369 ,{ ".bss.", ".gnu.linkonce.b." } */ \
372 if (TREE_CODE (DECL) == FUNCTION_DECL) \
374 /* else if (DECL_INITIAL (DECL) == 0 \
375 || DECL_INITIAL (DECL) == error_mark_node) \
377 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
382 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
383 /* Strip off any encoding in name. */ \
384 STRIP_NAME_ENCODING (name, name); \
385 prefix = prefixes[sec][DECL_ONE_ONLY(DECL)]; \
386 len = strlen (name) + strlen (prefix); \
387 string = alloca (len + 1); \
389 sprintf (string, "%s%s", prefix, name); \
391 DECL_SECTION_NAME (DECL) = build_string (len, string); \
395 /* A C statement (sans semicolon) to output an
396 element in the table of global constructors. */
397 #define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME) \
401 fprintf (FILE, "%s", INT_ASM_OP); \
402 assemble_name (FILE, NAME); \
403 fprintf (FILE, "\n"); \
407 /* A C statement (sans semicolon) to output an
408 element in the table of global destructors. */
409 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
413 fprintf (FILE, "%s", INT_ASM_OP); \
414 assemble_name (FILE, NAME); \
415 fprintf (FILE, "\n"); \
419 /* Switch into a generic section.
421 We make the section read-only and executable for a function decl,
422 read-only for a const data decl, and writable for a non-const data decl.
424 If the section has already been defined, we must not
425 emit the attributes here. The SVR4 assembler does not
426 recognize section redefinitions.
427 If DECL is NULL, no attributes are emitted. */
429 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
432 static htab_t htab; \
434 struct section_info \
436 enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
439 struct section_info *s; \
441 enum sect_enum type; \
444 /* The names we put in the hashtable will always be the unique \
445 versions gived to us by the stringtable, so we can just use \
446 their addresses as the keys. */ \
448 htab = htab_create (31, \
453 if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
454 type = SECT_EXEC, mode = "ax"; \
455 else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
456 type = SECT_RO, mode = "a"; \
458 type = SECT_RW, mode = "aw"; \
461 /* See if we already have an entry for this section. */ \
462 slot = htab_find_slot (htab, NAME, INSERT); \
465 s = (struct section_info *) xmalloc (sizeof (* s)); \
468 fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", \
473 s = (struct section_info *) *slot; \
474 if (DECL && s->type != type) \
475 error_with_decl (DECL, \
476 "%s causes a section type conflict"); \
478 fprintf (FILE, "\t.section\t%s\n", NAME); \
483 /* A C statement or statements to switch to the appropriate
484 section for output of RTX in mode MODE. RTX is some kind
485 of constant in RTL. The argument MODE is redundant except
486 in the case of a `const_int' rtx. Currently, these always
487 go into the const section. */
489 #undef SELECT_RTX_SECTION
490 #define SELECT_RTX_SECTION(MODE, RTX) const_section ()
492 /* A C statement or statements to switch to the appropriate
493 section for output of DECL. DECL is either a `VAR_DECL' node
494 or a constant of some sort. RELOC indicates whether forming
495 the initial value of DECL requires link-time relocations. */
497 #undef SELECT_SECTION
498 #define SELECT_SECTION(DECL, RELOC) \
500 if (TREE_CODE (DECL) == STRING_CST) \
502 if (! flag_writable_strings) \
507 else if (TREE_CODE (DECL) == VAR_DECL) \
509 if ((flag_pic && RELOC) \
510 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
511 || !DECL_INITIAL (DECL) \
512 || (DECL_INITIAL (DECL) != error_mark_node \
513 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
518 else if (TREE_CODE (DECL) == CONSTRUCTOR) \
520 if ((flag_pic && RELOC) \
521 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
522 || ! TREE_CONSTANT (DECL)) \
531 /* Define the strings used for the special svr4 .type and .size directives.
532 These strings generally do not vary from one system running svr4 to
533 another, but if a given system (e.g. m88k running svr) needs to use
534 different pseudo-op names for these, they may be overridden in the
535 file which includes this one. */
537 #define TYPE_ASM_OP "\t.type\t"
538 #define SIZE_ASM_OP "\t.size\t"
540 /* This is how we tell the assembler that a symbol is weak. */
542 #define ASM_WEAKEN_LABEL(FILE, NAME) \
545 fputs ("\t.weak\t", (FILE)); \
546 assemble_name ((FILE), (NAME)); \
547 fputc ('\n', (FILE)); \
551 /* The following macro defines the format used to output the second
552 operand of the .type assembler directive. Different svr4 assemblers
553 expect various different forms for this operand. The one given here
554 is just a default. You may need to override it in your machine-
555 specific tm.h file (depending upon the particulars of your assembler). */
557 #define TYPE_OPERAND_FMT "@%s"
559 /* Write the extra assembler code needed to declare a function's result.
560 Most svr4 assemblers don't require any special declaration of the
561 result value, but there are exceptions. */
563 #ifndef ASM_DECLARE_RESULT
564 #define ASM_DECLARE_RESULT(FILE, RESULT)
567 /* These macros generate the special .type and .size directives which
568 are used to set the corresponding fields of the linker symbol table
569 entries in an ELF object file under SVR4. These macros also output
570 the starting labels for the relevant functions/objects. */
572 /* Write the extra assembler code needed to declare a function properly.
573 Some svr4 assemblers need to also have something extra said about the
574 function's return value. We allow for that here. */
576 #ifndef ASM_DECLARE_FUNCTION_NAME
577 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
580 fprintf (FILE, "%s", TYPE_ASM_OP); \
581 assemble_name (FILE, NAME); \
583 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
586 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
587 ASM_OUTPUT_LABEL(FILE, NAME); \
592 /* Write the extra assembler code needed to declare an object properly. */
594 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
597 fprintf (FILE, "%s", TYPE_ASM_OP); \
598 assemble_name (FILE, NAME); \
600 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
603 size_directive_output = 0; \
605 if (!flag_inhibit_size_directive \
606 && (DECL) && DECL_SIZE (DECL)) \
608 size_directive_output = 1; \
609 fprintf (FILE, "%s", SIZE_ASM_OP); \
610 assemble_name (FILE, NAME); \
612 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
613 int_size_in_bytes (TREE_TYPE (DECL))); \
614 fputc ('\n', FILE); \
617 ASM_OUTPUT_LABEL (FILE, NAME); \
621 /* Output the size directive for a decl in rest_of_decl_compilation
622 in the case where we did not do so before the initializer.
623 Once we find the error_mark_node, we know that the value of
624 size_directive_output was set
625 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
627 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
630 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
632 if (!flag_inhibit_size_directive \
633 && DECL_SIZE (DECL) \
634 && ! AT_END && TOP_LEVEL \
635 && DECL_INITIAL (DECL) == error_mark_node \
636 && !size_directive_output) \
638 size_directive_output = 1; \
639 fprintf (FILE, "%s", SIZE_ASM_OP); \
640 assemble_name (FILE, name); \
642 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
643 int_size_in_bytes (TREE_TYPE (DECL))); \
644 fputc ('\n', FILE); \
649 /* This is how to declare the size of a function. */
650 #ifndef ASM_DECLARE_FUNCTION_SIZE
651 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
654 if (!flag_inhibit_size_directive) \
657 static int labelno; \
661 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
662 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
664 fprintf (FILE, "%s", SIZE_ASM_OP); \
665 assemble_name (FILE, (FNAME)); \
666 fprintf (FILE, ","); \
667 assemble_name (FILE, label); \
668 fprintf (FILE, "-"); \
669 assemble_name (FILE, (FNAME)); \
676 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
677 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
678 corresponds to a particular byte value [0..255]. For any
679 given byte value, if the value in the corresponding table
680 position is zero, the given character can be output directly.
681 If the table value is 1, the byte must be output as a \ooo
682 octal escape. If the tables value is anything else, then the
683 byte value should be output as a \ followed by the value
684 in the table. Note that we can use standard UN*X escape
685 sequences for many control characters, but we don't use
686 \a to represent BEL because some svr4 assemblers (e.g. on
687 the i386) don't know about that. Also, we don't use \v
688 since some versions of gas, such as 2.2 did not accept it. */
691 "\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\
692 \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\
693 \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\
694 \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\
695 \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\
696 \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\
697 \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\
698 \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"
700 /* Some svr4 assemblers have a limit on the number of characters which
701 can appear in the operand of a .string directive. If your assembler
702 has such a limitation, you should define STRING_LIMIT to reflect that
703 limit. Note that at least some svr4 assemblers have a limit on the
704 actual number of bytes in the double-quoted string, and that they
705 count each character in an escape sequence as one byte. Thus, an
706 escape sequence like \377 would count as four bytes.
708 If your target assembler doesn't support the .string directive, you
709 should define this to zero.
712 #define STRING_LIMIT ((unsigned) 256)
714 #define STRING_ASM_OP "\t.string\t"
716 /* The routine used to output NUL terminated strings. We use a special
717 version of this for most svr4 targets because doing so makes the
718 generated assembly code more compact (and thus faster to assemble)
719 as well as more readable, especially for targets like the i386
720 (where the only alternative is to output character sequences as
721 comma separated lists of numbers). */
723 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
726 register const unsigned char *_limited_str = \
727 (const unsigned char *) (STR); \
728 register unsigned ch; \
730 fprintf ((FILE), "%s\"", STRING_ASM_OP); \
732 for (; (ch = *_limited_str); _limited_str++) \
734 register int escape; \
736 switch (escape = ESCAPES[ch]) \
742 fprintf ((FILE), "\\%03o", ch); \
745 putc ('\\', (FILE)); \
746 putc (escape, (FILE)); \
751 fprintf ((FILE), "\"\n"); \
755 /* The routine used to output sequences of byte values. We use a special
756 version of this for most svr4 targets because doing so makes the
757 generated assembly code more compact (and thus faster to assemble)
758 as well as more readable. Note that if we find subparts of the
759 character sequence which end with NUL (and which are shorter than
760 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
762 #undef ASM_OUTPUT_ASCII
763 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
766 register const unsigned char *_ascii_bytes = \
767 (const unsigned char *) (STR); \
768 register const unsigned char *limit = _ascii_bytes + (LENGTH); \
769 register unsigned bytes_in_chunk = 0; \
771 for (; _ascii_bytes < limit; _ascii_bytes++) \
773 register const unsigned char *p; \
775 if (bytes_in_chunk >= 60) \
777 fprintf ((FILE), "\"\n"); \
778 bytes_in_chunk = 0; \
781 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
784 if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT) \
786 if (bytes_in_chunk > 0) \
788 fprintf ((FILE), "\"\n"); \
789 bytes_in_chunk = 0; \
792 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
797 register int escape; \
798 register unsigned ch; \
800 if (bytes_in_chunk == 0) \
801 fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP); \
803 switch (escape = ESCAPES[ch = *_ascii_bytes]) \
810 fprintf ((FILE), "\\%03o", ch); \
811 bytes_in_chunk += 4; \
814 putc ('\\', (FILE)); \
815 putc (escape, (FILE)); \
816 bytes_in_chunk += 2; \
822 if (bytes_in_chunk > 0) \
823 fprintf ((FILE), "\"\n"); \