freebsd.h revision 113420
1107286Sobrien/* Definitions for Intel 386 running FreeBSD with ELF format 295349Sobrien Copyright (C) 1996, 2000, 2002 Free Software Foundation, Inc. 334229Speter Contributed by Eric Youngdale. 434229Speter Modified for stabs-in-ELF by H.J. Lu. 551408Sobrien Adapted from GNU/Linux version by John Polstra. 652112Sobrien Continued development by David O'Brien <obrien@freebsd.org> 718334Speter 818334SpeterThis file is part of GNU CC. 918334Speter 1018334SpeterGNU CC is free software; you can redistribute it and/or modify 1118334Speterit under the terms of the GNU General Public License as published by 1218334Speterthe Free Software Foundation; either version 2, or (at your option) 1318334Speterany later version. 1418334Speter 1518334SpeterGNU CC is distributed in the hope that it will be useful, 1618334Speterbut WITHOUT ANY WARRANTY; without even the implied warranty of 1718334SpeterMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1818334SpeterGNU General Public License for more details. 1918334Speter 2018334SpeterYou should have received a copy of the GNU General Public License 2118334Speteralong with GNU CC; see the file COPYING. If not, write to 2218334Speterthe Free Software Foundation, 59 Temple Place - Suite 330, 2318334SpeterBoston, MA 02111-1307, USA. */ 2418334Speter 2551408Sobrien/* $FreeBSD: head/contrib/gcc/config/i386/freebsd.h 113420 2003-04-13 01:04:01Z kan $ */ 2618334Speter 2758478Sobrien#undef CC1_SPEC 2895810Sobrien#define CC1_SPEC "%(cc1_cpu) %{profile:-p} \ 2958478Sobrien %{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \ 30107286Sobrien " 3151408Sobrien 3258478Sobrien#undef ASM_SPEC 33107286Sobrien#define ASM_SPEC "%{v*: -v}" 3458478Sobrien 3595349Sobrien#undef ASM_FINAL_SPEC 3658478Sobrien#define ASM_FINAL_SPEC "%|" 3758478Sobrien 3858478Sobrien/* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support 3958478Sobrien for the special GCC options -static and -shared, which allow us to 4058478Sobrien link things in one of these three modes by applying the appropriate 4158478Sobrien combinations of options at link-time. We like to support here for 4258478Sobrien as many of the other GNU linker options as possible. But I don't 4358478Sobrien have the time to search for those flags. I am sure how to add 4458478Sobrien support for -soname shared_object_name. H.J. 4558478Sobrien 4658478Sobrien When the -shared link option is used a final link is not being 4758478Sobrien done. */ 4858478Sobrien 4958478Sobrien#undef LINK_SPEC 5058478Sobrien#define LINK_SPEC "\ 5158478Sobrien %{p:%e`-p' not supported; use `-pg' and gprof(1)} \ 5258478Sobrien %{Wl,*:%*} \ 5395349Sobrien %{v:-V} \ 5458478Sobrien %{assert*} %{R*} %{rpath*} %{defsym*} \ 5558478Sobrien %{shared:-Bshareable %{h*} %{soname*}} \ 5658478Sobrien %{!shared: \ 5758478Sobrien %{!static: \ 5858478Sobrien %{rdynamic: -export-dynamic} \ 5958478Sobrien %{!dynamic-linker: -dynamic-linker /usr/libexec/ld-elf.so.1}} \ 6095349Sobrien %{static:-Bstatic}} \ 61107286Sobrien %{symbolic:-Bsymbolic}" 6258478Sobrien 6395349Sobrien/* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add the magical 6495349Sobrien crtbegin.o file (see crtstuff.c) which provides part of the support for 6595349Sobrien getting C++ file-scope static object constructed before entering `main'. */ 6695349Sobrien 6758478Sobrien#undef STARTFILE_SPEC 6858478Sobrien#define STARTFILE_SPEC "\ 6958478Sobrien %{!shared: \ 7058478Sobrien %{pg:gcrt1.o%s} \ 7158478Sobrien %{!pg: \ 7258478Sobrien %{p:gcrt1.o%s} \ 7358478Sobrien %{!p:crt1.o%s}}} \ 7495349Sobrien crti.o%s \ 7595349Sobrien %{!shared:crtbegin.o%s} \ 76107286Sobrien %{shared:crtbeginS.o%s}" 7758478Sobrien 7858478Sobrien/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386. Here we tack on our 7995349Sobrien own magical crtend.o file (see crtstuff.c) which provides part of the 8058478Sobrien support for getting C++ file-scope static object constructed before 8158478Sobrien entering `main', followed by the normal "finalizer" file, `crtn.o'. */ 8258478Sobrien 8358478Sobrien#undef ENDFILE_SPEC 8458478Sobrien#define ENDFILE_SPEC "\ 8558478Sobrien %{!shared:crtend.o%s} \ 86107286Sobrien %{shared:crtendS.o%s} crtn.o%s" 8758478Sobrien 8858478Sobrien 8958478Sobrien/************************[ Target stuff ]***********************************/ 9058478Sobrien 9195349Sobrien/* Define the actual types of some ANSI-mandated types. 9258478Sobrien Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c, 9358478Sobrien c-common.c, and config/<arch>/<arch>.h. */ 9458478Sobrien 9595349Sobrien#undef SIZE_TYPE 9698597Sobrien#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") 9795349Sobrien 9895349Sobrien#undef PTRDIFF_TYPE 9998597Sobrien#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") 10058478Sobrien 10195349Sobrien#undef WCHAR_TYPE_SIZE 10298597Sobrien#define WCHAR_TYPE_SIZE (TARGET_64BIT ? 32 : BITS_PER_WORD) 10395349Sobrien 10458478Sobrien#undef TARGET_VERSION 10558478Sobrien#define TARGET_VERSION fprintf (stderr, " (i386 FreeBSD/ELF)"); 10658478Sobrien 10734229Speter#define MASK_PROFILER_EPILOGUE 010000000000 10818349Speter 10934229Speter#define TARGET_PROFILER_EPILOGUE (target_flags & MASK_PROFILER_EPILOGUE) 110107286Sobrien#define TARGET_ELF 1 11118349Speter 11234229Speter#undef SUBTARGET_SWITCHES 11352112Sobrien#define SUBTARGET_SWITCHES \ 11468601Sobrien { "profiler-epilogue", MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \ 115107286Sobrien { "no-profiler-epilogue", -MASK_PROFILER_EPILOGUE, "No function profiler epilogue"}, 11618349Speter 11758478Sobrien/* This goes away when the math emulator is fixed. */ 11895810Sobrien#undef TARGET_SUBTARGET_DEFAULT 11995810Sobrien#define TARGET_SUBTARGET_DEFAULT \ 12058478Sobrien (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387) 12158478Sobrien 12295349Sobrien/* Don't default to pcc-struct-return, we want to retain compatibility with 12395349Sobrien older gcc versions AND pcc-struct-return is nonreentrant. 12495349Sobrien (even though the SVR4 ABI for the i386 says that records and unions are 12595349Sobrien returned in memory). */ 12618349Speter 12795349Sobrien#undef DEFAULT_PCC_STRUCT_RETURN 12895349Sobrien#define DEFAULT_PCC_STRUCT_RETURN 0 12995349Sobrien 13058478Sobrien/* Tell final.c that we don't need a label passed to mcount. */ 13195810Sobrien#define NO_PROFILE_COUNTERS 1 13258478Sobrien 13358478Sobrien/* Output assembler code to FILE to begin profiling of the current function. 13458478Sobrien LABELNO is an optional label. */ 13558478Sobrien 13658478Sobrien#undef FUNCTION_PROFILER 13758478Sobrien#define FUNCTION_PROFILER(FILE, LABELNO) \ 13858478Sobrien do { \ 13958478Sobrien if (flag_pic) \ 140107286Sobrien fprintf ((FILE), "\tcall *.mcount%s@GOT(%%ebx)\n"); \ 14158478Sobrien else \ 142107286Sobrien fprintf ((FILE), "\tcall .mcount\n"); \ 14358478Sobrien } while (0) 14458478Sobrien 14558478Sobrien/* Output assembler code to FILE to end profiling of the current function. */ 14658478Sobrien 14795810Sobrien#undef FUNCTION_PROFILER_EPILOGUE /* BDE will need to fix this. */ 14858478Sobrien 14958478Sobrien 15058478Sobrien/************************[ Assembler stuff ]********************************/ 15158478Sobrien 15295348Sobrien/* Override the default comment-starter of "/" from unix.h. */ 15395348Sobrien#undef ASM_COMMENT_START 15495348Sobrien#define ASM_COMMENT_START "#" 15595348Sobrien 15696144Sobrien/* Override the default comment-starter of "/APP" from unix.h. */ 15758478Sobrien#undef ASM_APP_ON 15858478Sobrien#define ASM_APP_ON "#APP\n" 15958478Sobrien#undef ASM_APP_OFF 16095349Sobrien#define ASM_APP_OFF "#NO_APP\n" 16158478Sobrien 162107286Sobrien/* XXX:DEO do we still need this override to defaults.h ?? */ 16358478Sobrien/* This is how to output a reference to a user-level label named NAME. */ 16458478Sobrien#undef ASM_OUTPUT_LABELREF 16558478Sobrien#define ASM_OUTPUT_LABELREF(FILE, NAME) \ 16658478Sobrien do { \ 16758478Sobrien char *_name = (NAME); \ 16858478Sobrien /* Hack to avoid writing lots of rtl in \ 16958478Sobrien FUNCTION_PROFILER_EPILOGUE (). */ \ 17058478Sobrien if (*_name == '.' && strcmp(_name + 1, "mexitcount") == 0) \ 17158478Sobrien { \ 17258478Sobrien if (flag_pic) \ 17358478Sobrien fprintf ((FILE), "*%s@GOT(%%ebx)", _name); \ 17458478Sobrien else \ 17558478Sobrien fprintf ((FILE), "%s", _name); \ 17658478Sobrien } \ 17758478Sobrien else \ 178107286Sobrien fprintf (FILE, "%s", _name); \ 17958478Sobrien} while (0) 18058478Sobrien 18156810Sobrien/* This is how to hack on the symbol code of certain relcalcitrant 18256810Sobrien symbols to modify their output in output_pic_addr_const (). */ 18356810Sobrien 18495810Sobrien#undef ASM_HACK_SYMBOLREF_CODE /* BDE will need to fix this. */ 18556810Sobrien 18658478Sobrien#undef ASM_OUTPUT_ALIGN 18752112Sobrien#define ASM_OUTPUT_ALIGN(FILE, LOG) \ 18897907Sobrien do { \ 18997907Sobrien if ((LOG)!=0) { \ 19097907Sobrien if (in_text_section()) \ 19197907Sobrien fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG)); \ 19297907Sobrien else \ 19397907Sobrien fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ 19497907Sobrien } \ 19596466Sobrien } while (0) 19618349Speter 19795810Sobrien/* A C statement to output to the stdio stream FILE an assembler 19895810Sobrien command to advance the location counter to a multiple of 1<<LOG 19995810Sobrien bytes if it is within MAX_SKIP bytes. 20051408Sobrien 20195810Sobrien This is used to align code labels according to Intel recommendations. */ 20251408Sobrien 20396447Sobrien/* XXX configuration of this is broken in the same way as HAVE_GAS_SHF_MERGE, 20496447Sobrien but it is easier to fix in an MD way. */ 20596447Sobrien 20695810Sobrien#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN 20796447Sobrien#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ 20896466Sobrien do { \ 20997910Sobrien if ((LOG) != 0) { \ 210107286Sobrien if ((MAX_SKIP) == 0) \ 21197910Sobrien fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ 21297910Sobrien else \ 21397910Sobrien fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ 21497910Sobrien } \ 21596466Sobrien } while (0) 21695810Sobrien#endif 21758478Sobrien 218113420Skan/* If defined, a C expression whose value is a string containing the 219113420Skan assembler operation to identify the following data as 220113420Skan uninitialized global data. If not defined, and neither 221113420Skan `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined, 222113420Skan uninitialized global data will be output in the data section if 223113420Skan `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be 224113420Skan used. */ 225113420Skan#undef BSS_SECTION_ASM_OP 226113420Skan#define BSS_SECTION_ASM_OP "\t.section\t.bss" 22773305Sobrien 228113420Skan/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a 229113420Skan separate, explicit argument. If you define this macro, it is used 230113420Skan in place of `ASM_OUTPUT_BSS', and gives you more flexibility in 231113420Skan handling the required alignment of the variable. The alignment is 232113420Skan specified as the number of bits. 233113420Skan 234113420Skan Try to use function `asm_output_aligned_bss' defined in file 235113420Skan `varasm.c' when defining this macro. */ 236113420Skan#undef ASM_OUTPUT_ALIGNED_BSS 237113420Skan#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 238113420Skan asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 239113420Skan 24058478Sobrien/************************[ Debugger stuff ]*********************************/ 24118334Speter 24234229Speter#undef DBX_REGISTER_NUMBER 24395810Sobrien#define DBX_REGISTER_NUMBER(n) (TARGET_64BIT ? dbx64_register_map[n] \ 24495810Sobrien : (write_symbols == DWARF2_DEBUG \ 24593263Sobrien || write_symbols == DWARF_DEBUG) \ 24695810Sobrien ? svr4_dbx_register_map[(n)] \ 24795810Sobrien : dbx_register_map[(n)]) 24834229Speter 24999884Sobrien/* The same functions are used to creating the DWARF2 debug info and C++ 25099884Sobrien unwind info (except.c). Regardless of the debug format requested, the 25199884Sobrien register numbers used in exception unwinding sections still have to be 25299884Sobrien DWARF compatible. IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER 25399884Sobrien macro to mean too much. */ 25499884Sobrien#define DWARF_FRAME_REGNUM(n) (TARGET_64BIT ? dbx64_register_map[n] \ 25599884Sobrien : svr4_dbx_register_map[(n)]) 25699884Sobrien 25758478Sobrien/* stabs-in-elf has offsets relative to function beginning */ 25858478Sobrien#undef DBX_OUTPUT_LBRAC 25958478Sobrien#define DBX_OUTPUT_LBRAC(FILE, NAME) \ 26058478Sobrien do { \ 26158478Sobrien fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC); \ 26258478Sobrien assemble_name (asmfile, buf); \ 26358478Sobrien fputc ('-', asmfile); \ 26458478Sobrien assemble_name (asmfile, \ 26558478Sobrien XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \ 26658478Sobrien fprintf (asmfile, "\n"); \ 26758478Sobrien } while (0) 26852112Sobrien 26958478Sobrien#undef DBX_OUTPUT_RBRAC 27058478Sobrien#define DBX_OUTPUT_RBRAC(FILE, NAME) \ 27158478Sobrien do { \ 27258478Sobrien fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC); \ 27358478Sobrien assemble_name (asmfile, buf); \ 27458478Sobrien fputc ('-', asmfile); \ 27558478Sobrien assemble_name (asmfile, \ 27658478Sobrien XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \ 27758478Sobrien fprintf (asmfile, "\n"); \ 27858478Sobrien } while (0) 279