stl_bvector.h (swap(_Bit_reference,_Bit_reference)): Move/rename...
[official-gcc.git] / gcc / config / elfos.h
blob46a13b4afa738f4a0f511b2477bb76d90c52c20c
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 #ifndef DWARF_DEBUGGING_INFO
64 #define DWARF_DEBUGGING_INFO 1
65 #endif
67 /* All ELF targets can support DWARF-2. */
69 #ifndef DWARF2_DEBUGGING_INFO
70 #define DWARF2_DEBUGGING_INFO 1
71 #endif
73 /* The GNU tools operate better with dwarf2, and it is required by some
74 psABI's. Since we don't have any native tools to be compatible with,
75 default to dwarf2. */
77 #ifndef PREFERRED_DEBUGGING_TYPE
78 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
79 #endif
81 /* All SVR4 targets use the ELF object file format. */
82 #define OBJECT_FORMAT_ELF
85 /* Output #ident as a .ident. */
87 #define ASM_OUTPUT_IDENT(FILE, NAME) \
88 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
90 #define IDENT_ASM_OP "\t.ident\t"
92 #undef SET_ASM_OP
93 #define SET_ASM_OP "\t.set\t"
95 /* This is how to begin an assembly language file. Most svr4 assemblers want
96 at least a .file directive to come first, and some want to see a .version
97 directive come right after that. Here we just establish a default
98 which generates only the .file directive. If you need a .version
99 directive for any specific target, you should override this definition
100 in the target-specific file which includes this one. */
102 #undef ASM_FILE_START
103 #define ASM_FILE_START(FILE) \
104 output_file_directive ((FILE), main_input_filename)
106 /* This is how to allocate empty space in some section. The .zero
107 pseudo-op is used for this on most svr4 assemblers. */
109 #define SKIP_ASM_OP "\t.zero\t"
111 #undef ASM_OUTPUT_SKIP
112 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
113 fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
115 /* This is how to output an internal numbered label where
116 PREFIX is the class of label and NUM is the number within the class.
118 For most svr4 systems, the convention is that any symbol which begins
119 with a period is not put into the linker symbol table by the assembler. */
121 #undef ASM_OUTPUT_INTERNAL_LABEL
122 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
123 do \
125 fprintf (FILE, ".%s%u:\n", PREFIX, (unsigned) (NUM)); \
127 while (0)
129 /* This is how to store into the string LABEL
130 the symbol_ref name of an internal numbered label where
131 PREFIX is the class of label and NUM is the number within the class.
132 This is suitable for output with `assemble_name'.
134 For most svr4 systems, the convention is that any symbol which begins
135 with a period is not put into the linker symbol table by the assembler. */
137 #undef ASM_GENERATE_INTERNAL_LABEL
138 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
139 do \
141 sprintf (LABEL, "*.%s%u", PREFIX, (unsigned) (NUM)); \
143 while (0)
145 /* Output the label which precedes a jumptable. Note that for all svr4
146 systems where we actually generate jumptables (which is to say every
147 svr4 target except i386, where we use casesi instead) we put the jump-
148 tables into the .rodata section and since other stuff could have been
149 put into the .rodata section prior to any given jumptable, we have to
150 make sure that the location counter for the .rodata section gets pro-
151 perly re-aligned prior to the actual beginning of the jump table. */
153 #undef ALIGN_ASM_OP
154 #define ALIGN_ASM_OP "\t.align\t"
156 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
157 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
158 ASM_OUTPUT_ALIGN ((FILE), 2);
159 #endif
161 #undef ASM_OUTPUT_CASE_LABEL
162 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
163 do \
165 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
166 ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \
168 while (0)
170 /* The standard SVR4 assembler seems to require that certain builtin
171 library routines (e.g. .udiv) be explicitly declared as .globl
172 in each assembly file where they are referenced. */
174 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
175 ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
177 /* This says how to output assembler code to declare an
178 uninitialized external linkage data object. Under SVR4,
179 the linker seems to want the alignment of data objects
180 to depend on their types. We do exactly that here. */
182 #define COMMON_ASM_OP "\t.comm\t"
184 #undef ASM_OUTPUT_ALIGNED_COMMON
185 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
186 do \
188 fprintf ((FILE), "%s", COMMON_ASM_OP); \
189 assemble_name ((FILE), (NAME)); \
190 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
192 while (0)
194 /* This says how to output assembler code to declare an
195 uninitialized internal linkage data object. Under SVR4,
196 the linker seems to want the alignment of data objects
197 to depend on their types. We do exactly that here. */
199 #define LOCAL_ASM_OP "\t.local\t"
201 #undef ASM_OUTPUT_ALIGNED_LOCAL
202 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
203 do \
205 fprintf ((FILE), "%s", LOCAL_ASM_OP); \
206 assemble_name ((FILE), (NAME)); \
207 fprintf ((FILE), "\n"); \
208 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
210 while (0)
212 /* This is the pseudo-op used to generate a contiguous sequence of byte
213 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
214 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
216 #undef ASCII_DATA_ASM_OP
217 #define ASCII_DATA_ASM_OP "\t.ascii\t"
219 /* Support a read-only data section. */
220 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
222 /* On svr4, we *do* have support for the .init and .fini sections, and we
223 can put stuff in there to be executed before and after `main'. We let
224 crtstuff.c and other files know this by defining the following symbols.
225 The definitions say how to change sections to the .init and .fini
226 sections. This is the same for all known svr4 assemblers. */
228 #define INIT_SECTION_ASM_OP "\t.section\t.init"
229 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
231 /* Output assembly directive to move to the beginning of current section. */
232 #ifdef HAVE_GAS_SUBSECTION_ORDERING
233 # define ASM_SECTION_START_OP "\t.subsection\t-1"
234 # define ASM_OUTPUT_SECTION_START(FILE) \
235 fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
236 #endif
238 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
240 /* Switch into a generic section. */
241 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
243 #undef TARGET_ASM_SELECT_RTX_SECTION
244 #define TARGET_ASM_SELECT_RTX_SECTION default_elf_select_rtx_section
245 #undef TARGET_ASM_SELECT_SECTION
246 #define TARGET_ASM_SELECT_SECTION default_elf_select_section
248 /* Define the strings used for the special svr4 .type and .size directives.
249 These strings generally do not vary from one system running svr4 to
250 another, but if a given system (e.g. m88k running svr) needs to use
251 different pseudo-op names for these, they may be overridden in the
252 file which includes this one. */
254 #define TYPE_ASM_OP "\t.type\t"
255 #define SIZE_ASM_OP "\t.size\t"
257 /* This is how we tell the assembler that a symbol is weak. */
259 #define ASM_WEAKEN_LABEL(FILE, NAME) \
260 do \
262 fputs ("\t.weak\t", (FILE)); \
263 assemble_name ((FILE), (NAME)); \
264 fputc ('\n', (FILE)); \
266 while (0)
268 /* The following macro defines the format used to output the second
269 operand of the .type assembler directive. Different svr4 assemblers
270 expect various different forms for this operand. The one given here
271 is just a default. You may need to override it in your machine-
272 specific tm.h file (depending upon the particulars of your assembler). */
274 #define TYPE_OPERAND_FMT "@%s"
276 /* Write the extra assembler code needed to declare a function's result.
277 Most svr4 assemblers don't require any special declaration of the
278 result value, but there are exceptions. */
280 #ifndef ASM_DECLARE_RESULT
281 #define ASM_DECLARE_RESULT(FILE, RESULT)
282 #endif
284 /* These macros generate the special .type and .size directives which
285 are used to set the corresponding fields of the linker symbol table
286 entries in an ELF object file under SVR4. These macros also output
287 the starting labels for the relevant functions/objects. */
289 /* Write the extra assembler code needed to declare a function properly.
290 Some svr4 assemblers need to also have something extra said about the
291 function's return value. We allow for that here. */
293 #ifndef ASM_DECLARE_FUNCTION_NAME
294 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
295 do \
297 fprintf (FILE, "%s", TYPE_ASM_OP); \
298 assemble_name (FILE, NAME); \
299 putc (',', FILE); \
300 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
301 putc ('\n', FILE); \
303 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
304 ASM_OUTPUT_LABEL(FILE, NAME); \
306 while (0)
307 #endif
309 /* Write the extra assembler code needed to declare an object properly. */
311 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
312 do \
314 fprintf (FILE, "%s", TYPE_ASM_OP); \
315 assemble_name (FILE, NAME); \
316 putc (',', FILE); \
317 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
318 putc ('\n', FILE); \
320 size_directive_output = 0; \
322 if (!flag_inhibit_size_directive \
323 && (DECL) && DECL_SIZE (DECL)) \
325 size_directive_output = 1; \
326 fprintf (FILE, "%s", SIZE_ASM_OP); \
327 assemble_name (FILE, NAME); \
328 putc (',', FILE); \
329 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
330 int_size_in_bytes (TREE_TYPE (DECL))); \
331 fputc ('\n', FILE); \
334 ASM_OUTPUT_LABEL (FILE, NAME); \
336 while (0)
338 /* Output the size directive for a decl in rest_of_decl_compilation
339 in the case where we did not do so before the initializer.
340 Once we find the error_mark_node, we know that the value of
341 size_directive_output was set
342 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
344 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
345 do \
347 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
349 if (!flag_inhibit_size_directive \
350 && DECL_SIZE (DECL) \
351 && ! AT_END && TOP_LEVEL \
352 && DECL_INITIAL (DECL) == error_mark_node \
353 && !size_directive_output) \
355 size_directive_output = 1; \
356 fprintf (FILE, "%s", SIZE_ASM_OP); \
357 assemble_name (FILE, name); \
358 putc (',', FILE); \
359 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
360 int_size_in_bytes (TREE_TYPE (DECL))); \
361 fputc ('\n', FILE); \
364 while (0)
366 /* This is how to declare the size of a function. */
367 #ifndef ASM_DECLARE_FUNCTION_SIZE
368 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
369 do \
371 if (!flag_inhibit_size_directive) \
373 char label[256]; \
374 static int labelno; \
376 labelno++; \
378 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
379 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
381 fprintf (FILE, "%s", SIZE_ASM_OP); \
382 assemble_name (FILE, (FNAME)); \
383 fprintf (FILE, ","); \
384 assemble_name (FILE, label); \
385 fprintf (FILE, "-"); \
386 assemble_name (FILE, (FNAME)); \
387 putc ('\n', FILE); \
390 while (0)
391 #endif
393 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
394 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
395 corresponds to a particular byte value [0..255]. For any
396 given byte value, if the value in the corresponding table
397 position is zero, the given character can be output directly.
398 If the table value is 1, the byte must be output as a \ooo
399 octal escape. If the tables value is anything else, then the
400 byte value should be output as a \ followed by the value
401 in the table. Note that we can use standard UN*X escape
402 sequences for many control characters, but we don't use
403 \a to represent BEL because some svr4 assemblers (e.g. on
404 the i386) don't know about that. Also, we don't use \v
405 since some versions of gas, such as 2.2 did not accept it. */
407 #define ESCAPES \
408 "\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\
409 \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\
410 \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\
411 \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\
412 \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\
413 \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\
414 \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\
415 \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"
417 /* Some svr4 assemblers have a limit on the number of characters which
418 can appear in the operand of a .string directive. If your assembler
419 has such a limitation, you should define STRING_LIMIT to reflect that
420 limit. Note that at least some svr4 assemblers have a limit on the
421 actual number of bytes in the double-quoted string, and that they
422 count each character in an escape sequence as one byte. Thus, an
423 escape sequence like \377 would count as four bytes.
425 If your target assembler doesn't support the .string directive, you
426 should define this to zero.
429 #define STRING_LIMIT ((unsigned) 256)
431 #define STRING_ASM_OP "\t.string\t"
433 /* The routine used to output NUL terminated strings. We use a special
434 version of this for most svr4 targets because doing so makes the
435 generated assembly code more compact (and thus faster to assemble)
436 as well as more readable, especially for targets like the i386
437 (where the only alternative is to output character sequences as
438 comma separated lists of numbers). */
440 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
441 do \
443 register const unsigned char *_limited_str = \
444 (const unsigned char *) (STR); \
445 register unsigned ch; \
447 fprintf ((FILE), "%s\"", STRING_ASM_OP); \
449 for (; (ch = *_limited_str); _limited_str++) \
451 register int escape; \
453 switch (escape = ESCAPES[ch]) \
455 case 0: \
456 putc (ch, (FILE)); \
457 break; \
458 case 1: \
459 fprintf ((FILE), "\\%03o", ch); \
460 break; \
461 default: \
462 putc ('\\', (FILE)); \
463 putc (escape, (FILE)); \
464 break; \
468 fprintf ((FILE), "\"\n"); \
470 while (0)
472 /* The routine used to output sequences of byte values. We use a special
473 version of this for most svr4 targets because doing so makes the
474 generated assembly code more compact (and thus faster to assemble)
475 as well as more readable. Note that if we find subparts of the
476 character sequence which end with NUL (and which are shorter than
477 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
479 #undef ASM_OUTPUT_ASCII
480 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
481 do \
483 register const unsigned char *_ascii_bytes = \
484 (const unsigned char *) (STR); \
485 register const unsigned char *limit = _ascii_bytes + (LENGTH); \
486 register unsigned bytes_in_chunk = 0; \
488 for (; _ascii_bytes < limit; _ascii_bytes++) \
490 register const unsigned char *p; \
492 if (bytes_in_chunk >= 60) \
494 fprintf ((FILE), "\"\n"); \
495 bytes_in_chunk = 0; \
498 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
499 continue; \
501 if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT) \
503 if (bytes_in_chunk > 0) \
505 fprintf ((FILE), "\"\n"); \
506 bytes_in_chunk = 0; \
509 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
510 _ascii_bytes = p; \
512 else \
514 register int escape; \
515 register unsigned ch; \
517 if (bytes_in_chunk == 0) \
518 fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP); \
520 switch (escape = ESCAPES[ch = *_ascii_bytes]) \
522 case 0: \
523 putc (ch, (FILE)); \
524 bytes_in_chunk++; \
525 break; \
526 case 1: \
527 fprintf ((FILE), "\\%03o", ch); \
528 bytes_in_chunk += 4; \
529 break; \
530 default: \
531 putc ('\\', (FILE)); \
532 putc (escape, (FILE)); \
533 bytes_in_chunk += 2; \
534 break; \
539 if (bytes_in_chunk > 0) \
540 fprintf ((FILE), "\"\n"); \
542 while (0)