Makefile.in: Rebuilt.
[official-gcc.git] / gcc / config / elfos.h
blobe1abfcba444bea9f4625f8431de408f9689313ec
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, 2003, 2004
4 Free Software Foundation, Inc.
5 Based on svr4.h contributed by Ron Guilmette (rfg@netcom.com).
7 This file is part of GCC.
9 GCC 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 GCC 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 GCC; see the file COPYING. If not, write to
21 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
24 #define TARGET_OBJFMT_CPP_BUILTINS() \
25 do \
26 { \
27 builtin_define ("__ELF__"); \
28 } \
29 while (0)
31 /* Define a symbol indicating that we are using elfos.h.
32 Some CPU specific configuration files use this. */
33 #define USING_ELFOS_H
35 /* The prefix to add to user-visible assembler symbols.
37 For ELF systems the convention is *not* to prepend a leading
38 underscore onto user-level symbol names. */
40 #undef USER_LABEL_PREFIX
41 #define USER_LABEL_PREFIX ""
43 /* The biggest alignment supported by ELF in bits. 32-bit ELF
44 supports section alignment up to (0x80000000 * 8), while
45 64-bit ELF supports (0x8000000000000000 * 8). If this macro
46 is not defined, the default is the largest alignment supported
47 by 32-bit ELF and representable on a 32-bit host. Use this
48 macro to limit the alignment which can be specified using
49 the `__attribute__ ((aligned (N)))' construct. */
50 #ifndef MAX_OFILE_ALIGNMENT
51 #define MAX_OFILE_ALIGNMENT (((unsigned int) 1 << 28) * 8)
52 #endif
54 /* Use periods rather than dollar signs in special g++ assembler names. */
56 #define NO_DOLLAR_IN_LABEL
58 /* Writing `int' for a bit-field forces int alignment for the structure. */
60 #ifndef PCC_BITFIELD_TYPE_MATTERS
61 #define PCC_BITFIELD_TYPE_MATTERS 1
62 #endif
64 /* Handle #pragma weak and #pragma pack. */
66 #define HANDLE_SYSV_PRAGMA 1
68 /* All ELF targets can support DWARF-2. */
70 #define DWARF2_DEBUGGING_INFO 1
72 /* The GNU tools operate better with dwarf2, and it is required by some
73 psABI's. Since we don't have any native tools to be compatible with,
74 default to dwarf2. */
76 #ifndef PREFERRED_DEBUGGING_TYPE
77 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
78 #endif
80 /* All SVR4 targets use the ELF object file format. */
81 #define OBJECT_FORMAT_ELF
84 /* Output #ident as a .ident. */
86 #define ASM_OUTPUT_IDENT(FILE, NAME) \
87 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
89 #define IDENT_ASM_OP "\t.ident\t"
91 #undef SET_ASM_OP
92 #define SET_ASM_OP "\t.set\t"
94 /* Most svr4 assemblers want a .file directive at the beginning of
95 their input file. */
96 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
98 /* This is how to allocate empty space in some section. The .zero
99 pseudo-op is used for this on most svr4 assemblers. */
101 #define SKIP_ASM_OP "\t.zero\t"
103 #undef ASM_OUTPUT_SKIP
104 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
105 fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
106 SKIP_ASM_OP, (SIZE))
108 /* This is how to store into the string LABEL
109 the symbol_ref name of an internal numbered label where
110 PREFIX is the class of label and NUM is the number within the class.
111 This is suitable for output with `assemble_name'.
113 For most svr4 systems, the convention is that any symbol which begins
114 with a period is not put into the linker symbol table by the assembler. */
116 #undef ASM_GENERATE_INTERNAL_LABEL
117 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
118 do \
120 sprintf (LABEL, "*.%s%u", PREFIX, (unsigned) (NUM)); \
122 while (0)
124 /* Output the label which precedes a jumptable. Note that for all svr4
125 systems where we actually generate jumptables (which is to say every
126 svr4 target except i386, where we use casesi instead) we put the jump-
127 tables into the .rodata section and since other stuff could have been
128 put into the .rodata section prior to any given jumptable, we have to
129 make sure that the location counter for the .rodata section gets pro-
130 perly re-aligned prior to the actual beginning of the jump table. */
132 #undef ALIGN_ASM_OP
133 #define ALIGN_ASM_OP "\t.align\t"
135 #ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
136 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
137 ASM_OUTPUT_ALIGN ((FILE), 2);
138 #endif
140 #undef ASM_OUTPUT_CASE_LABEL
141 #define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
142 do \
144 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
145 (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); \
147 while (0)
149 /* The standard SVR4 assembler seems to require that certain builtin
150 library routines (e.g. .udiv) be explicitly declared as .globl
151 in each assembly file where they are referenced. */
153 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
154 (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0))
156 /* This says how to output assembler code to declare an
157 uninitialized external linkage data object. Under SVR4,
158 the linker seems to want the alignment of data objects
159 to depend on their types. We do exactly that here. */
161 #define COMMON_ASM_OP "\t.comm\t"
163 #undef ASM_OUTPUT_ALIGNED_COMMON
164 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
165 do \
167 fprintf ((FILE), "%s", COMMON_ASM_OP); \
168 assemble_name ((FILE), (NAME)); \
169 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
170 (SIZE), (ALIGN) / BITS_PER_UNIT); \
172 while (0)
174 /* This says how to output assembler code to declare an
175 uninitialized internal linkage data object. Under SVR4,
176 the linker seems to want the alignment of data objects
177 to depend on their types. We do exactly that here. */
179 #define LOCAL_ASM_OP "\t.local\t"
181 #undef ASM_OUTPUT_ALIGNED_LOCAL
182 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
183 do \
185 fprintf ((FILE), "%s", LOCAL_ASM_OP); \
186 assemble_name ((FILE), (NAME)); \
187 fprintf ((FILE), "\n"); \
188 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
190 while (0)
192 /* This is the pseudo-op used to generate a contiguous sequence of byte
193 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
194 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
196 #undef ASCII_DATA_ASM_OP
197 #define ASCII_DATA_ASM_OP "\t.ascii\t"
199 /* Support a read-only data section. */
200 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
202 /* On svr4, we *do* have support for the .init and .fini sections, and we
203 can put stuff in there to be executed before and after `main'. We let
204 crtstuff.c and other files know this by defining the following symbols.
205 The definitions say how to change sections to the .init and .fini
206 sections. This is the same for all known svr4 assemblers. */
208 #define INIT_SECTION_ASM_OP "\t.section\t.init"
209 #define FINI_SECTION_ASM_OP "\t.section\t.fini"
211 /* Output assembly directive to move to the beginning of current section. */
212 #ifdef HAVE_GAS_SUBSECTION_ORDERING
213 # define ASM_SECTION_START_OP "\t.subsection\t-1"
214 # define ASM_OUTPUT_SECTION_START(FILE) \
215 fprintf ((FILE), "%s\n", ASM_SECTION_START_OP)
216 #endif
218 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
220 /* Switch into a generic section. */
221 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
223 #undef TARGET_ASM_SELECT_RTX_SECTION
224 #define TARGET_ASM_SELECT_RTX_SECTION default_elf_select_rtx_section
225 #undef TARGET_ASM_SELECT_SECTION
226 #define TARGET_ASM_SELECT_SECTION default_elf_select_section
227 #undef TARGET_HAVE_SWITCHABLE_BSS_SECTIONS
228 #define TARGET_HAVE_SWITCHABLE_BSS_SECTIONS true
230 /* Define the strings used for the special svr4 .type and .size directives.
231 These strings generally do not vary from one system running svr4 to
232 another, but if a given system (e.g. m88k running svr) needs to use
233 different pseudo-op names for these, they may be overridden in the
234 file which includes this one. */
236 #define TYPE_ASM_OP "\t.type\t"
237 #define SIZE_ASM_OP "\t.size\t"
239 /* This is how we tell the assembler that a symbol is weak. */
241 #define ASM_WEAKEN_LABEL(FILE, NAME) \
242 do \
244 fputs ("\t.weak\t", (FILE)); \
245 assemble_name ((FILE), (NAME)); \
246 fputc ('\n', (FILE)); \
248 while (0)
250 /* The following macro defines the format used to output the second
251 operand of the .type assembler directive. Different svr4 assemblers
252 expect various different forms for this operand. The one given here
253 is just a default. You may need to override it in your machine-
254 specific tm.h file (depending upon the particulars of your assembler). */
256 #define TYPE_OPERAND_FMT "@%s"
258 /* Write the extra assembler code needed to declare a function's result.
259 Most svr4 assemblers don't require any special declaration of the
260 result value, but there are exceptions. */
262 #ifndef ASM_DECLARE_RESULT
263 #define ASM_DECLARE_RESULT(FILE, RESULT)
264 #endif
266 /* These macros generate the special .type and .size directives which
267 are used to set the corresponding fields of the linker symbol table
268 entries in an ELF object file under SVR4. These macros also output
269 the starting labels for the relevant functions/objects. */
271 /* Write the extra assembler code needed to declare a function properly.
272 Some svr4 assemblers need to also have something extra said about the
273 function's return value. We allow for that here. */
275 #ifndef ASM_DECLARE_FUNCTION_NAME
276 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
277 do \
279 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
280 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
281 ASM_OUTPUT_LABEL (FILE, NAME); \
283 while (0)
284 #endif
286 /* Write the extra assembler code needed to declare an object properly. */
288 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
289 do \
291 HOST_WIDE_INT size; \
293 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
295 size_directive_output = 0; \
296 if (!flag_inhibit_size_directive \
297 && (DECL) && DECL_SIZE (DECL)) \
299 size_directive_output = 1; \
300 size = int_size_in_bytes (TREE_TYPE (DECL)); \
301 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
304 ASM_OUTPUT_LABEL (FILE, NAME); \
306 while (0)
308 /* Output the size directive for a decl in rest_of_decl_compilation
309 in the case where we did not do so before the initializer.
310 Once we find the error_mark_node, we know that the value of
311 size_directive_output was set
312 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
314 #undef ASM_FINISH_DECLARE_OBJECT
315 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
316 do \
318 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
319 HOST_WIDE_INT size; \
321 if (!flag_inhibit_size_directive \
322 && DECL_SIZE (DECL) \
323 && ! AT_END && TOP_LEVEL \
324 && DECL_INITIAL (DECL) == error_mark_node \
325 && !size_directive_output) \
327 size_directive_output = 1; \
328 size = int_size_in_bytes (TREE_TYPE (DECL)); \
329 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
332 while (0)
334 /* This is how to declare the size of a function. */
335 #ifndef ASM_DECLARE_FUNCTION_SIZE
336 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
337 do \
339 if (!flag_inhibit_size_directive) \
340 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \
342 while (0)
343 #endif
345 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
346 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
347 corresponds to a particular byte value [0..255]. For any
348 given byte value, if the value in the corresponding table
349 position is zero, the given character can be output directly.
350 If the table value is 1, the byte must be output as a \ooo
351 octal escape. If the tables value is anything else, then the
352 byte value should be output as a \ followed by the value
353 in the table. Note that we can use standard UN*X escape
354 sequences for many control characters, but we don't use
355 \a to represent BEL because some svr4 assemblers (e.g. on
356 the i386) don't know about that. Also, we don't use \v
357 since some versions of gas, such as 2.2 did not accept it. */
359 #define ESCAPES \
360 "\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\
361 \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\
362 \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\
363 \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\
364 \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\
365 \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\
366 \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\
367 \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"
369 /* Some svr4 assemblers have a limit on the number of characters which
370 can appear in the operand of a .string directive. If your assembler
371 has such a limitation, you should define STRING_LIMIT to reflect that
372 limit. Note that at least some svr4 assemblers have a limit on the
373 actual number of bytes in the double-quoted string, and that they
374 count each character in an escape sequence as one byte. Thus, an
375 escape sequence like \377 would count as four bytes.
377 If your target assembler doesn't support the .string directive, you
378 should define this to zero.
381 #define STRING_LIMIT ((unsigned) 256)
383 #define STRING_ASM_OP "\t.string\t"
385 /* The routine used to output NUL terminated strings. We use a special
386 version of this for most svr4 targets because doing so makes the
387 generated assembly code more compact (and thus faster to assemble)
388 as well as more readable, especially for targets like the i386
389 (where the only alternative is to output character sequences as
390 comma separated lists of numbers). */
392 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
393 do \
395 register const unsigned char *_limited_str = \
396 (const unsigned char *) (STR); \
397 register unsigned ch; \
399 fprintf ((FILE), "%s\"", STRING_ASM_OP); \
401 for (; (ch = *_limited_str); _limited_str++) \
403 register int escape; \
405 switch (escape = ESCAPES[ch]) \
407 case 0: \
408 putc (ch, (FILE)); \
409 break; \
410 case 1: \
411 fprintf ((FILE), "\\%03o", ch); \
412 break; \
413 default: \
414 putc ('\\', (FILE)); \
415 putc (escape, (FILE)); \
416 break; \
420 fprintf ((FILE), "\"\n"); \
422 while (0)
424 /* The routine used to output sequences of byte values. We use a special
425 version of this for most svr4 targets because doing so makes the
426 generated assembly code more compact (and thus faster to assemble)
427 as well as more readable. Note that if we find subparts of the
428 character sequence which end with NUL (and which are shorter than
429 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
431 #undef ASM_OUTPUT_ASCII
432 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
433 do \
435 const unsigned char *_ascii_bytes = \
436 (const unsigned char *) (STR); \
437 const unsigned char *limit = _ascii_bytes + (LENGTH); \
438 const unsigned char *last_null = NULL; \
439 unsigned bytes_in_chunk = 0; \
441 for (; _ascii_bytes < limit; _ascii_bytes++) \
443 const unsigned char *p; \
445 if (bytes_in_chunk >= 60) \
447 fprintf ((FILE), "\"\n"); \
448 bytes_in_chunk = 0; \
451 if (_ascii_bytes > last_null) \
453 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
454 continue; \
455 last_null = p; \
457 else \
458 p = last_null; \
460 if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT) \
462 if (bytes_in_chunk > 0) \
464 fprintf ((FILE), "\"\n"); \
465 bytes_in_chunk = 0; \
468 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
469 _ascii_bytes = p; \
471 else \
473 register int escape; \
474 register unsigned ch; \
476 if (bytes_in_chunk == 0) \
477 fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP); \
479 switch (escape = ESCAPES[ch = *_ascii_bytes]) \
481 case 0: \
482 putc (ch, (FILE)); \
483 bytes_in_chunk++; \
484 break; \
485 case 1: \
486 fprintf ((FILE), "\\%03o", ch); \
487 bytes_in_chunk += 4; \
488 break; \
489 default: \
490 putc ('\\', (FILE)); \
491 putc (escape, (FILE)); \
492 bytes_in_chunk += 2; \
493 break; \
498 if (bytes_in_chunk > 0) \
499 fprintf ((FILE), "\"\n"); \
501 while (0)
503 /* Allow the use of the -frecord-gcc-switches switch via the
504 elf_record_gcc_switches function defined in varasm.c. */
505 #undef TARGET_ASM_RECORD_GCC_SWITCHES
506 #define TARGET_ASM_RECORD_GCC_SWITCHES elf_record_gcc_switches
508 /* A C statement (sans semicolon) to output to the stdio stream STREAM
509 any text necessary for declaring the name of an external symbol
510 named NAME which is referenced in this compilation but not defined.
511 It is needed to properly support non-default visibility. */
513 #ifndef ASM_OUTPUT_EXTERNAL
514 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
515 default_elf_asm_output_external (FILE, DECL, NAME)
516 #endif