xref: /openbsd/gnu/gcc/gcc/config/elfos.h (revision 8529ddd3)
1404b540aSrobert /* elfos.h  --  operating system specific defines to be used when
2404b540aSrobert    targeting GCC for some generic ELF system
3404b540aSrobert    Copyright (C) 1991, 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004
4404b540aSrobert    Free Software Foundation, Inc.
5404b540aSrobert    Based on svr4.h contributed by Ron Guilmette (rfg@netcom.com).
6404b540aSrobert 
7404b540aSrobert This file is part of GCC.
8404b540aSrobert 
9404b540aSrobert GCC is free software; you can redistribute it and/or modify
10404b540aSrobert it under the terms of the GNU General Public License as published by
11404b540aSrobert the Free Software Foundation; either version 2, or (at your option)
12404b540aSrobert any later version.
13404b540aSrobert 
14404b540aSrobert GCC is distributed in the hope that it will be useful,
15404b540aSrobert but WITHOUT ANY WARRANTY; without even the implied warranty of
16404b540aSrobert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17404b540aSrobert GNU General Public License for more details.
18404b540aSrobert 
19404b540aSrobert You should have received a copy of the GNU General Public License
20404b540aSrobert along with GCC; see the file COPYING.  If not, write to
21404b540aSrobert the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22404b540aSrobert Boston, MA 02110-1301, USA.  */
23404b540aSrobert 
24404b540aSrobert #define TARGET_OBJFMT_CPP_BUILTINS()		\
25404b540aSrobert   do						\
26404b540aSrobert     {						\
27404b540aSrobert 	builtin_define ("__ELF__");		\
28404b540aSrobert     }						\
29404b540aSrobert   while (0)
30404b540aSrobert 
31404b540aSrobert /* Define a symbol indicating that we are using elfos.h.
32404b540aSrobert    Some CPU specific configuration files use this.  */
33404b540aSrobert #define USING_ELFOS_H
34404b540aSrobert 
35404b540aSrobert /* The prefix to add to user-visible assembler symbols.
36404b540aSrobert 
37404b540aSrobert    For ELF systems the convention is *not* to prepend a leading
38404b540aSrobert    underscore onto user-level symbol names.  */
39404b540aSrobert 
40404b540aSrobert #undef  USER_LABEL_PREFIX
41404b540aSrobert #define USER_LABEL_PREFIX ""
42404b540aSrobert 
43404b540aSrobert /* Biggest alignment supported by the object file format of this
44404b540aSrobert    machine.  Use this macro to limit the alignment which can be
45404b540aSrobert    specified using the `__attribute__ ((aligned (N)))' construct.  If
46404b540aSrobert    not defined, the default value is `BIGGEST_ALIGNMENT'.  */
47404b540aSrobert #ifndef MAX_OFILE_ALIGNMENT
48404b540aSrobert #define MAX_OFILE_ALIGNMENT (32768 * 8)
49404b540aSrobert #endif
50404b540aSrobert 
51404b540aSrobert /* Use periods rather than dollar signs in special g++ assembler names.  */
52404b540aSrobert 
53404b540aSrobert #define NO_DOLLAR_IN_LABEL
54404b540aSrobert 
55404b540aSrobert /* Writing `int' for a bit-field forces int alignment for the structure.  */
56404b540aSrobert 
57404b540aSrobert #ifndef PCC_BITFIELD_TYPE_MATTERS
58404b540aSrobert #define PCC_BITFIELD_TYPE_MATTERS 1
59404b540aSrobert #endif
60404b540aSrobert 
61404b540aSrobert /* Handle #pragma weak and #pragma pack.  */
62404b540aSrobert 
63404b540aSrobert #define HANDLE_SYSV_PRAGMA 1
64404b540aSrobert 
65404b540aSrobert /* All ELF targets can support DWARF-2.  */
66404b540aSrobert 
67404b540aSrobert #define DWARF2_DEBUGGING_INFO 1
68404b540aSrobert 
69404b540aSrobert /* The GNU tools operate better with dwarf2, and it is required by some
70404b540aSrobert    psABI's.  Since we don't have any native tools to be compatible with,
71404b540aSrobert    default to dwarf2.  */
72404b540aSrobert 
73404b540aSrobert #ifndef PREFERRED_DEBUGGING_TYPE
74404b540aSrobert #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
75404b540aSrobert #endif
76404b540aSrobert 
77404b540aSrobert /* All SVR4 targets use the ELF object file format.  */
78404b540aSrobert #define OBJECT_FORMAT_ELF
79404b540aSrobert 
80404b540aSrobert 
81404b540aSrobert /* Output #ident as a .ident.  */
82404b540aSrobert 
83404b540aSrobert #define ASM_OUTPUT_IDENT(FILE, NAME) \
84404b540aSrobert   fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
85404b540aSrobert 
86404b540aSrobert #define IDENT_ASM_OP "\t.ident\t"
87404b540aSrobert 
88404b540aSrobert #undef  SET_ASM_OP
89404b540aSrobert #define SET_ASM_OP	"\t.set\t"
90404b540aSrobert 
91404b540aSrobert /* Most svr4 assemblers want a .file directive at the beginning of
92404b540aSrobert    their input file.  */
93404b540aSrobert #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
94404b540aSrobert 
95404b540aSrobert /* This is how to allocate empty space in some section.  The .zero
96404b540aSrobert    pseudo-op is used for this on most svr4 assemblers.  */
97404b540aSrobert 
98404b540aSrobert #define SKIP_ASM_OP	"\t.zero\t"
99404b540aSrobert 
100404b540aSrobert #undef  ASM_OUTPUT_SKIP
101404b540aSrobert #define ASM_OUTPUT_SKIP(FILE, SIZE) \
102404b540aSrobert    fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
103404b540aSrobert 	    SKIP_ASM_OP, (SIZE))
104404b540aSrobert 
105404b540aSrobert /* This is how to store into the string LABEL
106404b540aSrobert    the symbol_ref name of an internal numbered label where
107404b540aSrobert    PREFIX is the class of label and NUM is the number within the class.
108404b540aSrobert    This is suitable for output with `assemble_name'.
109404b540aSrobert 
110404b540aSrobert    For most svr4 systems, the convention is that any symbol which begins
111404b540aSrobert    with a period is not put into the linker symbol table by the assembler.  */
112404b540aSrobert 
113404b540aSrobert #undef  ASM_GENERATE_INTERNAL_LABEL
114404b540aSrobert #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)		\
115404b540aSrobert   do								\
116404b540aSrobert     {								\
117404b540aSrobert       sprintf (LABEL, "*.%s%u", PREFIX, (unsigned) (NUM));	\
118404b540aSrobert     }								\
119404b540aSrobert   while (0)
120404b540aSrobert 
121404b540aSrobert /* Output the label which precedes a jumptable.  Note that for all svr4
122404b540aSrobert    systems where we actually generate jumptables (which is to say every
123404b540aSrobert    svr4 target except i386, where we use casesi instead) we put the jump-
124404b540aSrobert    tables into the .rodata section and since other stuff could have been
125404b540aSrobert    put into the .rodata section prior to any given jumptable, we have to
126404b540aSrobert    make sure that the location counter for the .rodata section gets pro-
127404b540aSrobert    perly re-aligned prior to the actual beginning of the jump table.  */
128404b540aSrobert 
129404b540aSrobert #undef ALIGN_ASM_OP
130404b540aSrobert #define ALIGN_ASM_OP "\t.align\t"
131404b540aSrobert 
132404b540aSrobert #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
133404b540aSrobert #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
134404b540aSrobert   ASM_OUTPUT_ALIGN ((FILE), 2);
135404b540aSrobert #endif
136404b540aSrobert 
137404b540aSrobert #undef  ASM_OUTPUT_CASE_LABEL
138404b540aSrobert #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)		\
139404b540aSrobert   do									\
140404b540aSrobert     {									\
141404b540aSrobert       ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE)	\
142404b540aSrobert 	(*targetm.asm_out.internal_label) (FILE, PREFIX, NUM);			\
143404b540aSrobert     }									\
144404b540aSrobert   while (0)
145404b540aSrobert 
146404b540aSrobert /* The standard SVR4 assembler seems to require that certain builtin
147404b540aSrobert    library routines (e.g. .udiv) be explicitly declared as .globl
148404b540aSrobert    in each assembly file where they are referenced.  */
149404b540aSrobert 
150404b540aSrobert #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)	\
151404b540aSrobert   (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0))
152404b540aSrobert 
153404b540aSrobert /* This says how to output assembler code to declare an
154404b540aSrobert    uninitialized external linkage data object.  Under SVR4,
155404b540aSrobert    the linker seems to want the alignment of data objects
156404b540aSrobert    to depend on their types.  We do exactly that here.  */
157404b540aSrobert 
158404b540aSrobert #define COMMON_ASM_OP	"\t.comm\t"
159404b540aSrobert 
160404b540aSrobert #undef  ASM_OUTPUT_ALIGNED_COMMON
161404b540aSrobert #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
162404b540aSrobert   do									\
163404b540aSrobert     {									\
164404b540aSrobert       fprintf ((FILE), "%s", COMMON_ASM_OP);				\
165404b540aSrobert       assemble_name ((FILE), (NAME));					\
166404b540aSrobert       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",		\
167404b540aSrobert 	       (SIZE), (ALIGN) / BITS_PER_UNIT);			\
168404b540aSrobert     }									\
169404b540aSrobert   while (0)
170404b540aSrobert 
171404b540aSrobert /* This says how to output assembler code to declare an
172404b540aSrobert    uninitialized internal linkage data object.  Under SVR4,
173404b540aSrobert    the linker seems to want the alignment of data objects
174404b540aSrobert    to depend on their types.  We do exactly that here.  */
175404b540aSrobert 
176404b540aSrobert #define LOCAL_ASM_OP	"\t.local\t"
177404b540aSrobert 
178404b540aSrobert #undef  ASM_OUTPUT_ALIGNED_LOCAL
179404b540aSrobert #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)	\
180404b540aSrobert   do								\
181404b540aSrobert     {								\
182404b540aSrobert       fprintf ((FILE), "%s", LOCAL_ASM_OP);			\
183404b540aSrobert       assemble_name ((FILE), (NAME));				\
184404b540aSrobert       fprintf ((FILE), "\n");					\
185404b540aSrobert       ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);	\
186404b540aSrobert     }								\
187404b540aSrobert   while (0)
188404b540aSrobert 
189404b540aSrobert /* This is the pseudo-op used to generate a contiguous sequence of byte
190404b540aSrobert    values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
191404b540aSrobert    AUTOMATICALLY APPENDED.  This is the same for most svr4 assemblers.  */
192404b540aSrobert 
193404b540aSrobert #undef  ASCII_DATA_ASM_OP
194404b540aSrobert #define ASCII_DATA_ASM_OP	"\t.ascii\t"
195404b540aSrobert 
196404b540aSrobert /* Support a read-only data section.  */
197404b540aSrobert #define READONLY_DATA_SECTION_ASM_OP	"\t.section\t.rodata"
198404b540aSrobert 
199404b540aSrobert /* On svr4, we *do* have support for the .init and .fini sections, and we
200404b540aSrobert    can put stuff in there to be executed before and after `main'.  We let
201404b540aSrobert    crtstuff.c and other files know this by defining the following symbols.
202404b540aSrobert    The definitions say how to change sections to the .init and .fini
203404b540aSrobert    sections.  This is the same for all known svr4 assemblers.  */
204404b540aSrobert 
205404b540aSrobert #define INIT_SECTION_ASM_OP	"\t.section\t.init"
206404b540aSrobert #define FINI_SECTION_ASM_OP	"\t.section\t.fini"
207404b540aSrobert 
208404b540aSrobert /* Output assembly directive to move to the beginning of current section.  */
209404b540aSrobert #ifdef HAVE_GAS_SUBSECTION_ORDERING
210404b540aSrobert # define ASM_SECTION_START_OP	"\t.subsection\t-1"
211404b540aSrobert # define ASM_OUTPUT_SECTION_START(FILE)	\
212404b540aSrobert   fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
213404b540aSrobert #endif
214404b540aSrobert 
215404b540aSrobert #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
216404b540aSrobert 
217404b540aSrobert /* Switch into a generic section.  */
218404b540aSrobert #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
219404b540aSrobert 
220404b540aSrobert #undef  TARGET_ASM_SELECT_RTX_SECTION
221404b540aSrobert #define TARGET_ASM_SELECT_RTX_SECTION default_elf_select_rtx_section
222404b540aSrobert #undef	TARGET_ASM_SELECT_SECTION
223404b540aSrobert #define TARGET_ASM_SELECT_SECTION default_elf_select_section
224404b540aSrobert #undef  TARGET_HAVE_SWITCHABLE_BSS_SECTIONS
225404b540aSrobert #define TARGET_HAVE_SWITCHABLE_BSS_SECTIONS true
226404b540aSrobert 
227404b540aSrobert /* Define the strings used for the special svr4 .type and .size directives.
228404b540aSrobert    These strings generally do not vary from one system running svr4 to
229404b540aSrobert    another, but if a given system (e.g. m88k running svr) needs to use
230404b540aSrobert    different pseudo-op names for these, they may be overridden in the
231404b540aSrobert    file which includes this one.  */
232404b540aSrobert 
233404b540aSrobert #define TYPE_ASM_OP	"\t.type\t"
234404b540aSrobert #define SIZE_ASM_OP	"\t.size\t"
235404b540aSrobert 
236404b540aSrobert /* This is how we tell the assembler that a symbol is weak.  */
237404b540aSrobert 
238404b540aSrobert #define ASM_WEAKEN_LABEL(FILE, NAME)	\
239404b540aSrobert   do					\
240404b540aSrobert     {					\
241404b540aSrobert       fputs ("\t.weak\t", (FILE));	\
242404b540aSrobert       assemble_name ((FILE), (NAME));	\
243404b540aSrobert       fputc ('\n', (FILE));		\
244404b540aSrobert     }					\
245404b540aSrobert   while (0)
246404b540aSrobert 
247404b540aSrobert /* The following macro defines the format used to output the second
248404b540aSrobert    operand of the .type assembler directive.  Different svr4 assemblers
249404b540aSrobert    expect various different forms for this operand.  The one given here
250404b540aSrobert    is just a default.  You may need to override it in your machine-
251404b540aSrobert    specific tm.h file (depending upon the particulars of your assembler).  */
252404b540aSrobert 
253404b540aSrobert #define TYPE_OPERAND_FMT	"@%s"
254404b540aSrobert 
255404b540aSrobert /* Write the extra assembler code needed to declare a function's result.
256404b540aSrobert    Most svr4 assemblers don't require any special declaration of the
257404b540aSrobert    result value, but there are exceptions.  */
258404b540aSrobert 
259404b540aSrobert #ifndef ASM_DECLARE_RESULT
260404b540aSrobert #define ASM_DECLARE_RESULT(FILE, RESULT)
261404b540aSrobert #endif
262404b540aSrobert 
263404b540aSrobert /* These macros generate the special .type and .size directives which
264404b540aSrobert    are used to set the corresponding fields of the linker symbol table
265404b540aSrobert    entries in an ELF object file under SVR4.  These macros also output
266404b540aSrobert    the starting labels for the relevant functions/objects.  */
267404b540aSrobert 
268404b540aSrobert /* Write the extra assembler code needed to declare a function properly.
269404b540aSrobert    Some svr4 assemblers need to also have something extra said about the
270404b540aSrobert    function's return value.  We allow for that here.  */
271404b540aSrobert 
272404b540aSrobert #ifndef ASM_DECLARE_FUNCTION_NAME
273404b540aSrobert #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)		\
274404b540aSrobert   do								\
275404b540aSrobert     {								\
276404b540aSrobert       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");	\
277404b540aSrobert       ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));		\
278404b540aSrobert       ASM_OUTPUT_LABEL (FILE, NAME);				\
279404b540aSrobert     }								\
280404b540aSrobert   while (0)
281404b540aSrobert #endif
282404b540aSrobert 
283404b540aSrobert /* Write the extra assembler code needed to declare an object properly.  */
284404b540aSrobert 
285404b540aSrobert #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)		\
286404b540aSrobert   do								\
287404b540aSrobert     {								\
288404b540aSrobert       HOST_WIDE_INT size;					\
289404b540aSrobert 								\
290404b540aSrobert       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");		\
291404b540aSrobert 								\
292404b540aSrobert       size_directive_output = 0;				\
293404b540aSrobert       if (!flag_inhibit_size_directive				\
294404b540aSrobert 	  && (DECL) && DECL_SIZE (DECL))			\
295404b540aSrobert 	{							\
296404b540aSrobert 	  size_directive_output = 1;				\
297404b540aSrobert 	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
298404b540aSrobert 	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);		\
299404b540aSrobert 	}							\
300404b540aSrobert 								\
301404b540aSrobert       ASM_OUTPUT_LABEL (FILE, NAME);				\
302404b540aSrobert     }								\
303404b540aSrobert   while (0)
304404b540aSrobert 
305404b540aSrobert /* Output the size directive for a decl in rest_of_decl_compilation
306404b540aSrobert    in the case where we did not do so before the initializer.
307404b540aSrobert    Once we find the error_mark_node, we know that the value of
308404b540aSrobert    size_directive_output was set
309404b540aSrobert    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
310404b540aSrobert 
311404b540aSrobert #undef ASM_FINISH_DECLARE_OBJECT
312404b540aSrobert #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
313404b540aSrobert   do								\
314404b540aSrobert     {								\
315404b540aSrobert       const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);	\
316404b540aSrobert       HOST_WIDE_INT size;					\
317404b540aSrobert 								\
318404b540aSrobert       if (!flag_inhibit_size_directive				\
319404b540aSrobert 	  && DECL_SIZE (DECL)					\
320404b540aSrobert 	  && ! AT_END && TOP_LEVEL				\
321404b540aSrobert 	  && DECL_INITIAL (DECL) == error_mark_node		\
322404b540aSrobert 	  && !size_directive_output)				\
323404b540aSrobert 	{							\
324404b540aSrobert 	  size_directive_output = 1;				\
325404b540aSrobert 	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
326404b540aSrobert 	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);		\
327404b540aSrobert 	}							\
328404b540aSrobert     }								\
329404b540aSrobert   while (0)
330404b540aSrobert 
331404b540aSrobert /* This is how to declare the size of a function.  */
332404b540aSrobert #ifndef ASM_DECLARE_FUNCTION_SIZE
333404b540aSrobert #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)		\
334404b540aSrobert   do								\
335404b540aSrobert     {								\
336404b540aSrobert       if (!flag_inhibit_size_directive)				\
337404b540aSrobert 	ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME);			\
338404b540aSrobert     }								\
339404b540aSrobert   while (0)
340404b540aSrobert #endif
341404b540aSrobert 
342404b540aSrobert /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
343404b540aSrobert    ASM_OUTPUT_LIMITED_STRING macros.  Each byte in the table
344404b540aSrobert    corresponds to a particular byte value [0..255].  For any
345404b540aSrobert    given byte value, if the value in the corresponding table
346404b540aSrobert    position is zero, the given character can be output directly.
347404b540aSrobert    If the table value is 1, the byte must be output as a \ooo
348404b540aSrobert    octal escape.  If the tables value is anything else, then the
349404b540aSrobert    byte value should be output as a \ followed by the value
350404b540aSrobert    in the table.  Note that we can use standard UN*X escape
351404b540aSrobert    sequences for many control characters, but we don't use
352404b540aSrobert    \a to represent BEL because some svr4 assemblers (e.g. on
353404b540aSrobert    the i386) don't know about that.  Also, we don't use \v
354404b540aSrobert    since some versions of gas, such as 2.2 did not accept it.  */
355404b540aSrobert 
356404b540aSrobert #define ESCAPES \
357404b540aSrobert "\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\
358404b540aSrobert \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\
359404b540aSrobert \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\
360404b540aSrobert \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\
361404b540aSrobert \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\
362404b540aSrobert \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\
363404b540aSrobert \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\
364404b540aSrobert \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"
365404b540aSrobert 
366404b540aSrobert /* Some svr4 assemblers have a limit on the number of characters which
367404b540aSrobert    can appear in the operand of a .string directive.  If your assembler
368404b540aSrobert    has such a limitation, you should define STRING_LIMIT to reflect that
369404b540aSrobert    limit.  Note that at least some svr4 assemblers have a limit on the
370404b540aSrobert    actual number of bytes in the double-quoted string, and that they
371404b540aSrobert    count each character in an escape sequence as one byte.  Thus, an
372404b540aSrobert    escape sequence like \377 would count as four bytes.
373404b540aSrobert 
374404b540aSrobert    If your target assembler doesn't support the .string directive, you
375404b540aSrobert    should define this to zero.
376404b540aSrobert */
377404b540aSrobert 
378404b540aSrobert #define STRING_LIMIT	((unsigned) 256)
379404b540aSrobert 
380404b540aSrobert #define STRING_ASM_OP	"\t.string\t"
381404b540aSrobert 
382404b540aSrobert /* The routine used to output NUL terminated strings.  We use a special
383404b540aSrobert    version of this for most svr4 targets because doing so makes the
384404b540aSrobert    generated assembly code more compact (and thus faster to assemble)
385404b540aSrobert    as well as more readable, especially for targets like the i386
386404b540aSrobert    (where the only alternative is to output character sequences as
387404b540aSrobert    comma separated lists of numbers).  */
388404b540aSrobert 
389404b540aSrobert #define ASM_OUTPUT_LIMITED_STRING(FILE, STR)		\
390404b540aSrobert   do							\
391404b540aSrobert     {							\
392404b540aSrobert       register const unsigned char *_limited_str =	\
393404b540aSrobert 	(const unsigned char *) (STR);			\
394404b540aSrobert       register unsigned ch;				\
395404b540aSrobert 							\
396404b540aSrobert       fprintf ((FILE), "%s\"", STRING_ASM_OP);		\
397404b540aSrobert 							\
398404b540aSrobert       for (; (ch = *_limited_str); _limited_str++)	\
399404b540aSrobert         {						\
400404b540aSrobert 	  register int escape;				\
401404b540aSrobert 							\
402404b540aSrobert 	  switch (escape = ESCAPES[ch])			\
403404b540aSrobert 	    {						\
404404b540aSrobert 	    case 0:					\
405404b540aSrobert 	      putc (ch, (FILE));			\
406404b540aSrobert 	      break;					\
407404b540aSrobert 	    case 1:					\
408404b540aSrobert 	      fprintf ((FILE), "\\%03o", ch);		\
409404b540aSrobert 	      break;					\
410404b540aSrobert 	    default:					\
411404b540aSrobert 	      putc ('\\', (FILE));			\
412404b540aSrobert 	      putc (escape, (FILE));			\
413404b540aSrobert 	      break;					\
414404b540aSrobert 	    }						\
415404b540aSrobert         }						\
416404b540aSrobert 							\
417404b540aSrobert       fprintf ((FILE), "\"\n");				\
418404b540aSrobert     }							\
419404b540aSrobert   while (0)
420404b540aSrobert 
421404b540aSrobert /* The routine used to output sequences of byte values.  We use a special
422404b540aSrobert    version of this for most svr4 targets because doing so makes the
423404b540aSrobert    generated assembly code more compact (and thus faster to assemble)
424404b540aSrobert    as well as more readable.  Note that if we find subparts of the
425404b540aSrobert    character sequence which end with NUL (and which are shorter than
426404b540aSrobert    STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING.  */
427404b540aSrobert 
428404b540aSrobert #undef  ASM_OUTPUT_ASCII
429404b540aSrobert #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)				\
430404b540aSrobert   do									\
431404b540aSrobert     {									\
432404b540aSrobert       const unsigned char *_ascii_bytes =				\
433404b540aSrobert 	(const unsigned char *) (STR);					\
434404b540aSrobert       const unsigned char *limit = _ascii_bytes + (LENGTH);		\
435404b540aSrobert       const unsigned char *last_null = NULL;				\
436404b540aSrobert       unsigned bytes_in_chunk = 0;					\
437404b540aSrobert 									\
438404b540aSrobert       for (; _ascii_bytes < limit; _ascii_bytes++)			\
439404b540aSrobert         {								\
440404b540aSrobert 	  const unsigned char *p;					\
441404b540aSrobert 									\
442404b540aSrobert 	  if (bytes_in_chunk >= 60)					\
443404b540aSrobert 	    {								\
444404b540aSrobert 	      fprintf ((FILE), "\"\n");					\
445404b540aSrobert 	      bytes_in_chunk = 0;					\
446404b540aSrobert 	    }								\
447404b540aSrobert 									\
448404b540aSrobert 	  if (_ascii_bytes > last_null)					\
449404b540aSrobert 	    {								\
450404b540aSrobert 	      for (p = _ascii_bytes; p < limit && *p != '\0'; p++)	\
451404b540aSrobert 		continue;						\
452404b540aSrobert 	      last_null = p;						\
453404b540aSrobert 	    }								\
454404b540aSrobert 	  else								\
455404b540aSrobert 	    p = last_null;						\
456404b540aSrobert 									\
457404b540aSrobert 	  if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT)	\
458404b540aSrobert 	    {								\
459404b540aSrobert 	      if (bytes_in_chunk > 0)					\
460404b540aSrobert 		{							\
461404b540aSrobert 		  fprintf ((FILE), "\"\n");				\
462404b540aSrobert 		  bytes_in_chunk = 0;					\
463404b540aSrobert 		}							\
464404b540aSrobert 									\
465404b540aSrobert 	      ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);		\
466404b540aSrobert 	      _ascii_bytes = p;						\
467404b540aSrobert 	    }								\
468404b540aSrobert 	  else								\
469404b540aSrobert 	    {								\
470404b540aSrobert 	      register int escape;					\
471404b540aSrobert 	      register unsigned ch;					\
472404b540aSrobert 									\
473404b540aSrobert 	      if (bytes_in_chunk == 0)					\
474404b540aSrobert 		fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP);		\
475404b540aSrobert 									\
476404b540aSrobert 	      switch (escape = ESCAPES[ch = *_ascii_bytes])		\
477404b540aSrobert 		{							\
478404b540aSrobert 		case 0:							\
479404b540aSrobert 		  putc (ch, (FILE));					\
480404b540aSrobert 		  bytes_in_chunk++;					\
481404b540aSrobert 		  break;						\
482404b540aSrobert 		case 1:							\
483404b540aSrobert 		  fprintf ((FILE), "\\%03o", ch);			\
484404b540aSrobert 		  bytes_in_chunk += 4;					\
485404b540aSrobert 		  break;						\
486404b540aSrobert 		default:						\
487404b540aSrobert 		  putc ('\\', (FILE));					\
488404b540aSrobert 		  putc (escape, (FILE));				\
489404b540aSrobert 		  bytes_in_chunk += 2;					\
490404b540aSrobert 		  break;						\
491404b540aSrobert 		}							\
492404b540aSrobert 	    }								\
493404b540aSrobert 	}								\
494404b540aSrobert 									\
495404b540aSrobert       if (bytes_in_chunk > 0)						\
496404b540aSrobert         fprintf ((FILE), "\"\n");					\
497404b540aSrobert     }									\
498404b540aSrobert   while (0)
499*8529ddd3Skettenis 
500*8529ddd3Skettenis /* A C statement (sans semicolon) to output to the stdio stream STREAM
501*8529ddd3Skettenis    any text necessary for declaring the name of an external symbol
502*8529ddd3Skettenis    named NAME whch is referenced in this compilation but not defined.
503*8529ddd3Skettenis    It is needed to properly support non-default visibility.  */
504*8529ddd3Skettenis 
505*8529ddd3Skettenis #ifndef ASM_OUTPUT_EXTERNAL
506*8529ddd3Skettenis #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
507*8529ddd3Skettenis   default_elf_asm_output_external (FILE, DECL, NAME)
508*8529ddd3Skettenis #endif
509