freebsd.h revision 73304
1/* Base configuration file for all FreeBSD targets. 2 Copyright (C) 1999, 2000 Free Software Foundation, Inc. 3 4This file is part of GNU CC. 5 6GNU CC is free software; you can redistribute it and/or modify 7it under the terms of the GNU General Public License as published by 8the Free Software Foundation; either version 2, or (at your option) 9any later version. 10 11GNU CC is distributed in the hope that it will be useful, 12but WITHOUT ANY WARRANTY; without even the implied warranty of 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14GNU General Public License for more details. 15 16You should have received a copy of the GNU General Public License 17along with GNU CC; see the file COPYING. If not, write to 18the Free Software Foundation, 59 Temple Place - Suite 330, 19Boston, MA 02111-1307, USA. */ 20 21/* Common FreeBSD configuration. 22 All FreeBSD architectures should include this file, which will specify 23 their commonalities. 24 Adapted from /usr/src/contrib/gcc/config/i386/freebsd.h, 25 /usr/src/contrib/gcc/config/svr4.h & 26 egcs/gcc/config/i386/freebsd-elf.h by 27 David O'Brien <obrien@FreeBSD.org>. */ 28 29/* $FreeBSD: head/contrib/gcc/config/freebsd.h 73304 2001-03-02 02:42:42Z obrien $ */ 30 31 32/* Cpp, assembler, linker, library, and startfile spec's. */ 33 34/* This defines which switch letters take arguments. On FreeBSD, most of 35 the normal cases (defined in gcc.c) apply, and we also have -h* and 36 -z* options (for the linker) (coming from SVR4). 37 We also have -R (alias --rpath), no -z, --soname (-h), --assert etc. */ 38 39#define FBSD_SWITCH_TAKES_ARG(CHAR) \ 40 (DEFAULT_SWITCH_TAKES_ARG (CHAR) \ 41 || (CHAR) == 'h' \ 42 || (CHAR) == 'z' /* ignored by ld */ \ 43 || (CHAR) == 'R') 44 45#undef SWITCH_TAKES_ARG 46#define SWITCH_TAKES_ARG(CHAR) (FBSD_SWITCH_TAKES_ARG(CHAR)) 47 48/* This defines which multi-letter switches take arguments. */ 49 50#define FBSD_WORD_SWITCH_TAKES_ARG(STR) \ 51 (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \ 52 || !strcmp ((STR), "rpath") || !strcmp ((STR), "rpath-link") \ 53 || !strcmp ((STR), "soname") || !strcmp ((STR), "defsym") \ 54 || !strcmp ((STR), "assert") || !strcmp ((STR), "dynamic-linker")) 55 56#undef WORD_SWITCH_TAKES_ARG 57#define WORD_SWITCH_TAKES_ARG(STR) (FBSD_WORD_SWITCH_TAKES_ARG(STR)) 58 59/* Place spaces around this string. We depend on string splicing to produce 60 the final CPP_PREDEFINES value. */ 61 62#define FBSD_CPP_PREDEFINES \ 63 " -D__FreeBSD__=5 -D__FreeBSD_cc_version=500002 -Dunix -Asystem(unix) -Asystem(FreeBSD) " 64 65#define FBSD_CPP_SPEC " \ 66 %(cpp_cpu) \ 67 %{!maout: -D__ELF__} \ 68 %{munderscores: -D__UNDERSCORES__} \ 69 %{maout: %{!mno-underscores: -D__UNDERSCORES__}} \ 70 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \ 71 %{posix:-D_POSIX_SOURCE}" 72 73#undef CPP_SPEC 74#define CPP_SPEC FBSD_CPP_SPEC 75 76/* Provide a LIB_SPEC appropriate for FreeBSD. Just select the appropriate 77 libc, depending on whether we're doing profiling or need threads support. 78 (simular to the default, except no -lg, and no -p). */ 79 80#undef LIB_SPEC 81#define LIB_SPEC " \ 82 %{!shared: \ 83 %{!pg: %{pthread:-lc_r} -lc} \ 84 %{pg: %{pthread:-lc_r_p} -lc_p} \ 85 }" 86 87 88/************************[ Target stuff ]***********************************/ 89 90/* All FreeBSD Architectures support the ELF object file format. */ 91#undef OBJECT_FORMAT_ELF 92#define OBJECT_FORMAT_ELF 93 94/* Don't assume anything about the header files. */ 95#undef NO_IMPLICIT_EXTERN_C 96#define NO_IMPLICIT_EXTERN_C 97 98/* Implicit library calls should use memcpy, not bcopy, etc. */ 99#undef TARGET_MEM_FUNCTIONS 100#define TARGET_MEM_FUNCTIONS 101 102/* Allow #sccs in preprocessor. */ 103#undef SCCS_DIRECTIVE 104#define SCCS_DIRECTIVE 105 106#undef HAVE_ATEXIT 107#define HAVE_ATEXIT 108 109/* Code generation parameters. */ 110 111/* Don't default to pcc-struct-return, because gcc is the only compiler, and 112 we want to retain compatibility with older gcc versions 113 (even though the SVR4 ABI for the i386 says that records and unions are 114 returned in memory). */ 115#undef DEFAULT_PCC_STRUCT_RETURN 116#define DEFAULT_PCC_STRUCT_RETURN 0 117 118/* Writing `int' for a bitfield forces int alignment for the structure. */ 119/* XXX: ok for Alpha?? */ 120#undef PCC_BITFIELD_TYPE_MATTERS 121#define PCC_BITFIELD_TYPE_MATTERS 1 122 123/* Use periods rather than dollar signs in special g++ assembler names. 124 This ensures the configuration knows our system correctly so we can link 125 with libraries compiled with the native cc. */ 126#undef NO_DOLLAR_IN_LABEL 127 128/* The prefix to add to user-visible assembler symbols. 129 For System V Release 4 & ELF the convention is *not* to prepend a leading 130 underscore onto user-level symbol names. */ 131 132#undef USER_LABEL_PREFIX 133#define USER_LABEL_PREFIX "" 134 135/* Handle #pragma weak and #pragma pack. */ 136#undef HANDLE_SYSV_PRAGMA 137#define HANDLE_SYSV_PRAGMA 138 139/* FreeBSD ELF uses across the board will now use DWARF2 unwinding as the IA-64 140 psABI requires it. */ 141#define DWARF2_UNWIND_INFO 0 142 143/* Do not use ``thunks'' to implement C++ vtables. This method still has 144 fatal bugs. Also, GCC 3.0 will have a new C++ ABI that may not even 145 support `thunks'. */ 146#undef DEFAULT_VTABLE_THUNKS 147 148 149/************************[ Assembler stuff ]********************************/ 150 151/* Override the default comment-starter of "/". */ 152#undef ASM_COMMENT_START 153#define ASM_COMMENT_START "#" 154 155/* Attach a special .ident directive to the end of the file to identify 156 the version of GCC which compiled this code. The format of the .ident 157 string is patterned after the ones produced by native SVR4 C compilers. */ 158 159#undef IDENT_ASM_OP 160#define IDENT_ASM_OP "\t.ident\t" 161 162/* Output #ident as a .ident. */ 163 164#undef ASM_OUTPUT_IDENT 165#define ASM_OUTPUT_IDENT(FILE, NAME) \ 166 fprintf ((FILE), "%s\"%s\"\n", IDENT_ASM_OP, (NAME)); 167 168/* Identify the front-end which produced this file. To keep symbol 169 space down, and not confuse kdb, only do this if the language is 170 not C. (svr4.h defines ASM_IDENTIFY_GCC but neglects this) */ 171 172#undef ASM_IDENTIFY_LANGUAGE 173#define ASM_IDENTIFY_LANGUAGE(FILE) \ 174 { \ 175 if (strcmp (lang_identify (), "c") != 0) \ 176 output_lang_identify (FILE); \ 177 } 178 179#undef ASM_FILE_END 180#define ASM_FILE_END(FILE) \ 181 do { \ 182 if (!flag_no_ident) \ 183 fprintf ((FILE), "%s\"[ASM_FILE_END]GCC: (%s) %s\"\n", \ 184 IDENT_ASM_OP, lang_identify(), version_string); \ 185 } while (0) 186 187/* This is the pseudo-op used to generate a contiguous sequence of byte 188 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL 189 AUTOMATICALLY APPENDED. This is the same for most SVR4 assemblers. */ 190 191#undef ASCII_DATA_ASM_OP 192#define ASCII_DATA_ASM_OP "\t.ascii\t" 193 194#undef ASM_BYTE_OP 195#define ASM_BYTE_OP "\t.byte\t" 196 197/* This is how to allocate empty space in some section. The .zero 198 pseudo-op is used for this on most ELF assemblers. */ 199 200#undef SKIP_ASM_OP 201#define SKIP_ASM_OP "\t.zero\t" 202 203/* A table of bytes codes used by the ASM_OUTPUT_ASCII and 204 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table 205 corresponds to a particular byte value [0..255]. For any 206 given byte value, if the value in the corresponding table 207 position is zero, the given character can be output directly. 208 If the table value is 1, the byte must be output as a \ooo 209 octal escape. If the tables value is anything else, then the 210 byte value should be output as a \ followed by the value 211 in the table. Note that we can use standard UN*X escape 212 sequences for many control characters, but we don't use 213 \a to represent BEL because some SVR4 assemblers (e.g. on 214 the i386) don't know about that. Also, we don't use \v 215 since some versions of gas, such as 2.2 did not accept it. */ 216 217#define ESCAPES \ 218"\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\ 219\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\ 220\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\ 221\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\ 222\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\ 223\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\ 224\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\ 225\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" 226 227/* Some SVR4 assemblers have a limit on the number of characters which 228 can appear in the operand of a .string directive. If your assembler 229 has such a limitation, you should define STRING_LIMIT to reflect that 230 limit. Note that at least some SVR4 assemblers have a limit on the 231 actual number of bytes in the double-quoted string, and that they 232 count each character in an escape sequence as one byte. Thus, an 233 escape sequence like \377 would count as four bytes. 234 235 If your target assembler doesn't support the .string directive, you 236 should define this to zero. 237*/ 238 239#undef STRING_LIMIT 240#define STRING_LIMIT ((unsigned) 256) 241 242#undef STRING_ASM_OP 243#define STRING_ASM_OP "\t.string\t" 244 245/* Output the label which precedes a jumptable. Note that for all svr4/ELF 246 systems where we actually generate jumptables (which is to say every 247 SVR4 target except i386, where we use casesi instead) we put the jump- 248 tables into the .rodata section and since other stuff could have been 249 put into the .rodata section prior to any given jumptable, we have to 250 make sure that the location counter for the .rodata section gets pro- 251 perly re-aligned prior to the actual beginning of the jump table. */ 252 253#undef ALIGN_ASM_OP 254#define ALIGN_ASM_OP "\t.align\t" 255 256/* This says how to output assembler code to declare an 257 uninitialized external linkage data object. Under SVR4/ELF, 258 the linker seems to want the alignment of data objects 259 to depend on their types. We do exactly that here. */ 260 261#undef COMMON_ASM_OP 262#define COMMON_ASM_OP "\t.comm\t" 263 264/* This says how to output assembler code to declare an 265 uninitialized internal linkage data object. Under SVR4/ELF, 266 the linker seems to want the alignment of data objects 267 to depend on their types. We do exactly that here. */ 268 269#undef LOCAL_ASM_OP 270#define LOCAL_ASM_OP "\t.local\t" 271 272#undef ASM_OUTPUT_BEFORE_CASE_LABEL 273#define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \ 274 ASM_OUTPUT_ALIGN ((FILE), 2); 275 276#undef ASM_OUTPUT_CASE_LABEL 277#define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \ 278 do { \ 279 ASM_OUTPUT_BEFORE_CASE_LABEL ((FILE), (PREFIX), (NUM), (JUMPTABLE)) \ 280 ASM_OUTPUT_INTERNAL_LABEL ((FILE), (PREFIX), (NUM)); \ 281 } while (0) 282 283/* The standard SVR4/ELF assembler seems to require that certain builtin 284 library routines (e.g. .udiv) be explicitly declared as .globl 285 in each assembly file where they are referenced. */ 286 287#undef ASM_OUTPUT_EXTERNAL_LIBCALL 288#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ 289 ASM_GLOBALIZE_LABEL ((FILE), XSTR ((FUN), 0)) 290 291/* Support const sections and the ctors and dtors sections for g++. 292 Note that there appears to be two different ways to support const 293 sections at the moment. You can either #define the symbol 294 READONLY_DATA_SECTION (giving it some code which switches to the 295 readonly data section) or else you can #define the symbols 296 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and 297 SELECT_RTX_SECTION. We do both here just to be on the safe side. 298 FreeBSD conditionalizes the use of ".section rodata" depending on 299 ELF mode - otherwise .text. */ 300 301#undef USE_CONST_SECTION 302#define USE_CONST_SECTION TARGET_ELF 303 304#undef CONST_SECTION_ASM_OP 305#define CONST_SECTION_ASM_OP "\t.section\t.rodata" 306 307/* Define the pseudo-ops used to switch to the .ctors and .dtors sections. 308 309 Note that we want to give these sections the SHF_WRITE attribute 310 because these sections will actually contain data (i.e. tables of 311 addresses of functions in the current root executable or shared library 312 file) and, in the case of a shared library, the relocatable addresses 313 will have to be properly resolved/relocated (and then written into) by 314 the dynamic linker when it actually attaches the given shared library 315 to the executing process. (Note that on SVR4, you may wish to use the 316 `-z text' option to the ELF linker, when building a shared library, as 317 an additional check that you are doing everything right. But if you do 318 use the `-z text' option when building a shared library, you will get 319 errors unless the .ctors and .dtors sections are marked as writable 320 via the SHF_WRITE attribute.) */ 321 322#undef CTORS_SECTION_ASM_OP 323#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\"" 324#undef DTORS_SECTION_ASM_OP 325#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\"" 326 327/* On SVR4, we *do* have support for the .init and .fini sections, and we 328 can put stuff in there to be executed before and after `main'. We let 329 crtstuff.c and other files know this by defining the following symbols. 330 The definitions say how to change sections to the .init and .fini 331 sections. This is the same for all known SVR4 assemblers. */ 332 333#undef INIT_SECTION_ASM_OP 334#define INIT_SECTION_ASM_OP "\t.section\t.init" 335#undef FINI_SECTION_ASM_OP 336#define FINI_SECTION_ASM_OP "\t.section\t.fini" 337 338/* A default list of other sections which we might be "in" at any given 339 time. For targets that use additional sections (e.g. .tdesc) you 340 should override this definition in the target-specific file which 341 includes this file. */ 342 343#undef EXTRA_SECTIONS 344#define EXTRA_SECTIONS in_const, in_ctors, in_dtors 345 346/* A default list of extra section function definitions. For targets 347 that use additional sections (e.g. .tdesc) you should override this 348 definition in the target-specific file which includes this file. */ 349 350#undef EXTRA_SECTION_FUNCTIONS 351#define EXTRA_SECTION_FUNCTIONS \ 352 CONST_SECTION_FUNCTION \ 353 CTORS_SECTION_FUNCTION \ 354 DTORS_SECTION_FUNCTION 355 356#undef READONLY_DATA_SECTION 357#define READONLY_DATA_SECTION() const_section () 358 359extern void text_section (); 360 361#undef CONST_SECTION_FUNCTION 362#define CONST_SECTION_FUNCTION \ 363 void \ 364 const_section () \ 365 { \ 366 if (!USE_CONST_SECTION) \ 367 text_section(); \ 368 else if (in_section != in_const) \ 369 { \ 370 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \ 371 in_section = in_const; \ 372 } \ 373 } 374 375#undef CTORS_SECTION_FUNCTION 376#define CTORS_SECTION_FUNCTION \ 377 void \ 378 ctors_section () \ 379 { \ 380 if (in_section != in_ctors) \ 381 { \ 382 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \ 383 in_section = in_ctors; \ 384 } \ 385 } 386 387#undef DTORS_SECTION_FUNCTION 388#define DTORS_SECTION_FUNCTION \ 389 void \ 390 dtors_section () \ 391 { \ 392 if (in_section != in_dtors) \ 393 { \ 394 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \ 395 in_section = in_dtors; \ 396 } \ 397 } 398 399/* A C statement or statements to switch to the appropriate 400 section for output of RTX in mode MODE. RTX is some kind 401 of constant in RTL. The argument MODE is redundant except 402 in the case of a `const_int' rtx. Currently, these always 403 go into the const section. */ 404 405#undef SELECT_RTX_SECTION 406#define SELECT_RTX_SECTION(MODE, RTX) const_section() 407 408/* Define the strings used for the special svr4/ELF .type and .size 409 directives. These strings generally do not vary from one svr4/ELF 410 system to another. */ 411 412#undef TYPE_ASM_OP 413#define TYPE_ASM_OP "\t.type\t" 414#undef SIZE_ASM_OP 415#define SIZE_ASM_OP "\t.size\t" 416 417/* This is how we tell the assembler that a symbol is weak. */ 418 419#undef ASM_WEAKEN_LABEL 420#define ASM_WEAKEN_LABEL(FILE, NAME) \ 421 do { \ 422 fputs ("\t.globl\t", (FILE)); assemble_name ((FILE), (NAME)); \ 423 fputc ('\n', (FILE)); \ 424 fputs ("\t.weak\t", (FILE)); assemble_name ((FILE), (NAME)); \ 425 fputc ('\n', (FILE)); \ 426 } while (0) 427 428/* The following macro defines the [default] format used with ELF to output 429 the second operand of the .type assembler directive. */ 430 431#undef TYPE_OPERAND_FMT 432#define TYPE_OPERAND_FMT "@%s" 433 434/* Write the extra assembler code needed to declare a function's result. 435 Most svr4/ELF assemblers don't require any special declaration of the 436 result value. */ 437 438#undef ASM_DECLARE_RESULT 439#define ASM_DECLARE_RESULT(FILE, RESULT) 440 441/* These macros generate the special .type and .size directives which 442 are used to set the corresponding fields of the linker symbol table 443 entries in an ELF object file under SVR4/ELF. These macros also output 444 the starting labels for the relevant functions/objects. */ 445 446/* Write the extra assembler code needed to declare an object properly. */ 447 448#undef ASM_DECLARE_OBJECT_NAME 449#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ 450 do { \ 451 fprintf (FILE, "%s ", TYPE_ASM_OP); \ 452 assemble_name (FILE, NAME); \ 453 putc (',', FILE); \ 454 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \ 455 putc ('\n', FILE); \ 456 size_directive_output = 0; \ 457 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \ 458 { \ 459 size_directive_output = 1; \ 460 fprintf (FILE, "%s ", SIZE_ASM_OP); \ 461 assemble_name (FILE, NAME); \ 462 putc (',', FILE); \ 463 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \ 464 int_size_in_bytes (TREE_TYPE (DECL))); \ 465 fputc ('\n', FILE); \ 466 } \ 467 ASM_OUTPUT_LABEL(FILE, NAME); \ 468 } while (0) 469 470/* Output the size directive for a decl in rest_of_decl_compilation 471 in the case where we did not do so before the initializer. 472 Once we find the error_mark_node, we know that the value of 473 size_directive_output was set 474 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ 475 476#undef ASM_FINISH_DECLARE_OBJECT 477#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ 478 do { \ 479 char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ 480 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \ 481 && ! AT_END && TOP_LEVEL \ 482 && DECL_INITIAL (DECL) == error_mark_node \ 483 && !size_directive_output) \ 484 { \ 485 size_directive_output = 1; \ 486 fprintf (FILE, "%s ", SIZE_ASM_OP); \ 487 assemble_name (FILE, name); \ 488 putc (',', FILE); \ 489 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \ 490 int_size_in_bytes (TREE_TYPE (DECL))); \ 491 fputc ('\n', FILE); \ 492 } \ 493 } while (0) 494 495 496/************************[ Debugger stuff ]*********************************/ 497 498/* All ELF targets can support DWARF-2. */ 499#undef DWARF2_DEBUGGING_INFO 500#define DWARF2_DEBUGGING_INFO 501 502/* This is BSD, so we want the DBX format. */ 503#undef DBX_DEBUGGING_INFO 504#define DBX_DEBUGGING_INFO 505 506/* This is BSD, so use stabs instead of DWARF debug format. */ 507#undef PREFERRED_DEBUGGING_TYPE 508#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG 509 510/* But allow STABS to be supported as well. 511 Note that we want to override some definition settings done for some 512 architecture's native OS's tools that don't apply to us. */ 513#undef ASM_IDENTIFY_GCC 514#undef ASM_IDENTIFY_LANGUAGE 515