* ChangeLog: Follow spelling conventions.
[official-gcc.git] / gcc / config / elfos.h
blobcd20878aceeed9790b11188b01a0ce0728f61c64
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, 2002
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)
12 any later version.
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. */
25 /* Define a symbol indicating that we are using elfos.h.
26 Some CPU specific configuration files use this. */
27 #define USING_ELFOS_H
29 /* The prefix to add to user-visible assembler symbols.
31 For ELF systems the convention is *not* to prepend a leading
32 underscore onto user-level symbol names. */
34 #undef USER_LABEL_PREFIX
35 #define USER_LABEL_PREFIX ""
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
45 /* Use periods rather than dollar signs in special g++ assembler names. */
47 #define NO_DOLLAR_IN_LABEL
49 /* Writing `int' for a bitfield forces int alignment for the structure. */
51 #define PCC_BITFIELD_TYPE_MATTERS 1
53 /* Implicit library calls should use memcpy, not bcopy, etc. */
55 #define TARGET_MEM_FUNCTIONS
57 /* Handle #pragma weak and #pragma pack. */
59 #define HANDLE_SYSV_PRAGMA
61 /* System V Release 4 uses DWARF debugging info. */
63 #define DWARF_DEBUGGING_INFO 1
65 /* All ELF targets can support DWARF-2. */
67 #define DWARF2_DEBUGGING_INFO 1
69 /* The GNU tools operate better with dwarf2, and it is required by some
70 psABI's. Since we don't have any native tools to be compatible with,
71 default to dwarf2. */
73 #ifndef PREFERRED_DEBUGGING_TYPE
74 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
75 #endif
77 /* All SVR4 targets use the ELF object file format. */
78 #define OBJECT_FORMAT_ELF
81 /* Output #ident as a .ident. */
83 #define ASM_OUTPUT_IDENT(FILE, NAME) \
84 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
86 #define IDENT_ASM_OP "\t.ident\t"
88 #undef SET_ASM_OP
89 #define SET_ASM_OP "\t.set\t"
91 /* This is how to begin an assembly language file. Most svr4 assemblers want
92 at least a .file directive to come first, and some want to see a .version
93 directive come right after that. Here we just establish a default
94 which generates only the .file directive. If you need a .version
95 directive for any specific target, you should override this definition
96 in the target-specific file which includes this one. */
98 #undef ASM_FILE_START
99 #define ASM_FILE_START(FILE) \
100 output_file_directive ((FILE), main_input_filename)
102 /* This is how to allocate empty space in some section. The .zero
103 pseudo-op is used for this on most svr4 assemblers. */
105 #define SKIP_ASM_OP "\t.zero\t"
107 #undef ASM_OUTPUT_SKIP
108 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
109 fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
111 /* This is how to output an internal numbered label where
112 PREFIX is the class of label and NUM is the number within the class.
114 For most svr4 systems, the convention is that any symbol which begins
115 with a period is not put into the linker symbol table by the assembler. */
117 #undef ASM_OUTPUT_INTERNAL_LABEL
118 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
119 do \
121 fprintf (FILE, ".%s%u:\n", PREFIX, (unsigned) (NUM)); \
123 while (0)
125 /* This is how to store into the string LABEL
126 the symbol_ref name of an internal numbered label where
127 PREFIX is the class of label and NUM is the number within the class.
128 This is suitable for output with `assemble_name'.
130 For most svr4 systems, the convention is that any symbol which begins
131 with a period is not put into the linker symbol table by the assembler. */
133 #undef ASM_GENERATE_INTERNAL_LABEL
134 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
135 do \
137 sprintf (LABEL, "*.%s%u", PREFIX, (unsigned) (NUM)); \
139 while (0)
141 /* Output the label which precedes a jumptable. Note that for all svr4
142 systems where we actually generate jumptables (which is to say every
143 svr4 target except i386, where we use casesi instead) we put the jump-
144 tables into the .rodata section and since other stuff could have been
145 put into the .rodata section prior to any given jumptable, we have to
146 make sure that the location counter for the .rodata section gets pro-
147 perly re-aligned prior to the actual beginning of the jump table. */
149 #undef ALIGN_ASM_OP
150 #define ALIGN_ASM_OP "\t.align\t"
152 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
153 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
154 ASM_OUTPUT_ALIGN ((FILE), 2);
155 #endif
157 #undef ASM_OUTPUT_CASE_LABEL
158 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
159 do \
161 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
162 ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \
164 while (0)
166 /* The standard SVR4 assembler seems to require that certain builtin
167 library routines (e.g. .udiv) be explicitly declared as .globl
168 in each assembly file where they are referenced. */
170 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
171 (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0))
173 /* This says how to output assembler code to declare an
174 uninitialized external linkage data object. Under SVR4,
175 the linker seems to want the alignment of data objects
176 to depend on their types. We do exactly that here. */
178 #define COMMON_ASM_OP "\t.comm\t"
180 #undef ASM_OUTPUT_ALIGNED_COMMON
181 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
182 do \
184 fprintf ((FILE), "%s", COMMON_ASM_OP); \
185 assemble_name ((FILE), (NAME)); \
186 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
188 while (0)
190 /* This says how to output assembler code to declare an
191 uninitialized internal linkage data object. Under SVR4,
192 the linker seems to want the alignment of data objects
193 to depend on their types. We do exactly that here. */
195 #define LOCAL_ASM_OP "\t.local\t"
197 #undef ASM_OUTPUT_ALIGNED_LOCAL
198 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
199 do \
201 fprintf ((FILE), "%s", LOCAL_ASM_OP); \
202 assemble_name ((FILE), (NAME)); \
203 fprintf ((FILE), "\n"); \
204 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
206 while (0)
208 /* This is the pseudo-op used to generate a contiguous sequence of byte
209 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
210 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
212 #undef ASCII_DATA_ASM_OP
213 #define ASCII_DATA_ASM_OP "\t.ascii\t"
215 /* Support a read-only data section. */
216 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
218 /* On svr4, we *do* have support for the .init and .fini sections, and we
219 can put stuff in there to be executed before and after `main'. We let
220 crtstuff.c and other files know this by defining the following symbols.
221 The definitions say how to change sections to the .init and .fini
222 sections. This is the same for all known svr4 assemblers. */
224 #define INIT_SECTION_ASM_OP "\t.section\t.init"
225 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
227 /* Output assembly directive to move to the beginning of current section. */
228 #ifdef HAVE_GAS_SUBSECTION_ORDERING
229 # define ASM_SECTION_START_OP "\t.subsection\t-1"
230 # define ASM_OUTPUT_SECTION_START(FILE) \
231 fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
232 #endif
234 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
236 /* Switch into a generic section. */
237 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
239 #undef TARGET_ASM_SELECT_RTX_SECTION
240 #define TARGET_ASM_SELECT_RTX_SECTION default_elf_select_rtx_section
241 #undef TARGET_ASM_SELECT_SECTION
242 #define TARGET_ASM_SELECT_SECTION default_elf_select_section
244 /* Define the strings used for the special svr4 .type and .size directives.
245 These strings generally do not vary from one system running svr4 to
246 another, but if a given system (e.g. m88k running svr) needs to use
247 different pseudo-op names for these, they may be overridden in the
248 file which includes this one. */
250 #define TYPE_ASM_OP "\t.type\t"
251 #define SIZE_ASM_OP "\t.size\t"
253 /* This is how we tell the assembler that a symbol is weak. */
255 #define ASM_WEAKEN_LABEL(FILE, NAME) \
256 do \
258 fputs ("\t.weak\t", (FILE)); \
259 assemble_name ((FILE), (NAME)); \
260 fputc ('\n', (FILE)); \
262 while (0)
264 /* The following macro defines the format used to output the second
265 operand of the .type assembler directive. Different svr4 assemblers
266 expect various different forms for this operand. The one given here
267 is just a default. You may need to override it in your machine-
268 specific tm.h file (depending upon the particulars of your assembler). */
270 #define TYPE_OPERAND_FMT "@%s"
272 /* Write the extra assembler code needed to declare a function's result.
273 Most svr4 assemblers don't require any special declaration of the
274 result value, but there are exceptions. */
276 #ifndef ASM_DECLARE_RESULT
277 #define ASM_DECLARE_RESULT(FILE, RESULT)
278 #endif
280 /* These macros generate the special .type and .size directives which
281 are used to set the corresponding fields of the linker symbol table
282 entries in an ELF object file under SVR4. These macros also output
283 the starting labels for the relevant functions/objects. */
285 /* Write the extra assembler code needed to declare a function properly.
286 Some svr4 assemblers need to also have something extra said about the
287 function's return value. We allow for that here. */
289 #ifndef ASM_DECLARE_FUNCTION_NAME
290 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
291 do \
293 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
294 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
295 ASM_OUTPUT_LABEL (FILE, NAME); \
297 while (0)
298 #endif
300 /* Write the extra assembler code needed to declare an object properly. */
302 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
303 do \
305 HOST_WIDE_INT size; \
307 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
309 size_directive_output = 0; \
310 if (!flag_inhibit_size_directive \
311 && (DECL) && DECL_SIZE (DECL)) \
313 size_directive_output = 1; \
314 size = int_size_in_bytes (TREE_TYPE (DECL)); \
315 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
318 ASM_OUTPUT_LABEL (FILE, NAME); \
320 while (0)
322 /* Output the size directive for a decl in rest_of_decl_compilation
323 in the case where we did not do so before the initializer.
324 Once we find the error_mark_node, we know that the value of
325 size_directive_output was set
326 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
328 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
329 do \
331 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
332 HOST_WIDE_INT size; \
334 if (!flag_inhibit_size_directive \
335 && DECL_SIZE (DECL) \
336 && ! AT_END && TOP_LEVEL \
337 && DECL_INITIAL (DECL) == error_mark_node \
338 && !size_directive_output) \
340 size_directive_output = 1; \
341 size = int_size_in_bytes (TREE_TYPE (DECL)); \
342 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
345 while (0)
347 /* This is how to declare the size of a function. */
348 #ifndef ASM_DECLARE_FUNCTION_SIZE
349 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
350 do \
352 if (!flag_inhibit_size_directive) \
353 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
355 while (0)
356 #endif
358 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
359 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
360 corresponds to a particular byte value [0..255]. For any
361 given byte value, if the value in the corresponding table
362 position is zero, the given character can be output directly.
363 If the table value is 1, the byte must be output as a \ooo
364 octal escape. If the tables value is anything else, then the
365 byte value should be output as a \ followed by the value
366 in the table. Note that we can use standard UN*X escape
367 sequences for many control characters, but we don't use
368 \a to represent BEL because some svr4 assemblers (e.g. on
369 the i386) don't know about that. Also, we don't use \v
370 since some versions of gas, such as 2.2 did not accept it. */
372 #define ESCAPES \
373 "\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\
374 \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\
375 \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\
376 \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\
377 \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\
378 \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\
379 \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\
380 \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"
382 /* Some svr4 assemblers have a limit on the number of characters which
383 can appear in the operand of a .string directive. If your assembler
384 has such a limitation, you should define STRING_LIMIT to reflect that
385 limit. Note that at least some svr4 assemblers have a limit on the
386 actual number of bytes in the double-quoted string, and that they
387 count each character in an escape sequence as one byte. Thus, an
388 escape sequence like \377 would count as four bytes.
390 If your target assembler doesn't support the .string directive, you
391 should define this to zero.
394 #define STRING_LIMIT ((unsigned) 256)
396 #define STRING_ASM_OP "\t.string\t"
398 /* The routine used to output NUL terminated strings. We use a special
399 version of this for most svr4 targets because doing so makes the
400 generated assembly code more compact (and thus faster to assemble)
401 as well as more readable, especially for targets like the i386
402 (where the only alternative is to output character sequences as
403 comma separated lists of numbers). */
405 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
406 do \
408 register const unsigned char *_limited_str = \
409 (const unsigned char *) (STR); \
410 register unsigned ch; \
412 fprintf ((FILE), "%s\"", STRING_ASM_OP); \
414 for (; (ch = *_limited_str); _limited_str++) \
416 register int escape; \
418 switch (escape = ESCAPES[ch]) \
420 case 0: \
421 putc (ch, (FILE)); \
422 break; \
423 case 1: \
424 fprintf ((FILE), "\\%03o", ch); \
425 break; \
426 default: \
427 putc ('\\', (FILE)); \
428 putc (escape, (FILE)); \
429 break; \
433 fprintf ((FILE), "\"\n"); \
435 while (0)
437 /* The routine used to output sequences of byte values. We use a special
438 version of this for most svr4 targets because doing so makes the
439 generated assembly code more compact (and thus faster to assemble)
440 as well as more readable. Note that if we find subparts of the
441 character sequence which end with NUL (and which are shorter than
442 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
444 #undef ASM_OUTPUT_ASCII
445 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
446 do \
448 register const unsigned char *_ascii_bytes = \
449 (const unsigned char *) (STR); \
450 register const unsigned char *limit = _ascii_bytes + (LENGTH); \
451 register unsigned bytes_in_chunk = 0; \
453 for (; _ascii_bytes < limit; _ascii_bytes++) \
455 register const unsigned char *p; \
457 if (bytes_in_chunk >= 60) \
459 fprintf ((FILE), "\"\n"); \
460 bytes_in_chunk = 0; \
463 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
464 continue; \
466 if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT) \
468 if (bytes_in_chunk > 0) \
470 fprintf ((FILE), "\"\n"); \
471 bytes_in_chunk = 0; \
474 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
475 _ascii_bytes = p; \
477 else \
479 register int escape; \
480 register unsigned ch; \
482 if (bytes_in_chunk == 0) \
483 fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP); \
485 switch (escape = ESCAPES[ch = *_ascii_bytes]) \
487 case 0: \
488 putc (ch, (FILE)); \
489 bytes_in_chunk++; \
490 break; \
491 case 1: \
492 fprintf ((FILE), "\\%03o", ch); \
493 bytes_in_chunk += 4; \
494 break; \
495 default: \
496 putc ('\\', (FILE)); \
497 putc (escape, (FILE)); \
498 bytes_in_chunk += 2; \
499 break; \
504 if (bytes_in_chunk > 0) \
505 fprintf ((FILE), "\"\n"); \
507 while (0)