freebsd.h revision 117418
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 117418 2003-07-11 05:03:47Z kan $ */
2618334Speter
2758478Sobrien#undef  CC1_SPEC
28114077Sobrien#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
2951408Sobrien
3058478Sobrien#undef  ASM_SPEC
31107286Sobrien#define ASM_SPEC	"%{v*: -v}"
3258478Sobrien
3395349Sobrien#undef  ASM_FINAL_SPEC
3458478Sobrien#define ASM_FINAL_SPEC	"%|"
3558478Sobrien
3658478Sobrien/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
3758478Sobrien   for the special GCC options -static and -shared, which allow us to
3858478Sobrien   link things in one of these three modes by applying the appropriate
3958478Sobrien   combinations of options at link-time. We like to support here for
4058478Sobrien   as many of the other GNU linker options as possible. But I don't
4158478Sobrien   have the time to search for those flags. I am sure how to add
4258478Sobrien   support for -soname shared_object_name. H.J.
4358478Sobrien
4458478Sobrien   When the -shared link option is used a final link is not being
4558478Sobrien   done.  */
4658478Sobrien
4758478Sobrien#undef	LINK_SPEC
4858478Sobrien#define LINK_SPEC "\
49117418Skan %{p:%nconsider using `-pg' instead of `-p' with gprof(1) } \
5058478Sobrien    %{Wl,*:%*} \
5195349Sobrien    %{v:-V} \
5258478Sobrien    %{assert*} %{R*} %{rpath*} %{defsym*} \
5358478Sobrien    %{shared:-Bshareable %{h*} %{soname*}} \
5458478Sobrien    %{!shared: \
5558478Sobrien      %{!static: \
5658478Sobrien	%{rdynamic: -export-dynamic} \
5758478Sobrien	%{!dynamic-linker: -dynamic-linker /usr/libexec/ld-elf.so.1}} \
5895349Sobrien      %{static:-Bstatic}} \
59107286Sobrien    %{symbolic:-Bsymbolic}"
6058478Sobrien
6195349Sobrien/* Provide a STARTFILE_SPEC appropriate for FreeBSD.  Here we add the magical
6295349Sobrien   crtbegin.o file (see crtstuff.c) which provides part of the support for
6395349Sobrien   getting C++ file-scope static object constructed before entering `main'.  */
6495349Sobrien
6558478Sobrien#undef STARTFILE_SPEC
6658478Sobrien#define STARTFILE_SPEC "\
6758478Sobrien    %{!shared: \
6858478Sobrien      %{pg:gcrt1.o%s} \
6958478Sobrien      %{!pg: \
7058478Sobrien	%{p:gcrt1.o%s} \
7158478Sobrien	%{!p:crt1.o%s}}} \
7295349Sobrien    crti.o%s \
7395349Sobrien    %{!shared:crtbegin.o%s} \
74107286Sobrien    %{shared:crtbeginS.o%s}"
7558478Sobrien
7658478Sobrien/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386.  Here we tack on our
7795349Sobrien   own magical crtend.o file (see crtstuff.c) which provides part of the
7858478Sobrien   support for getting C++ file-scope static object constructed before
7958478Sobrien   entering `main', followed by the normal "finalizer" file, `crtn.o'.  */
8058478Sobrien
8158478Sobrien#undef  ENDFILE_SPEC
8258478Sobrien#define ENDFILE_SPEC "\
8358478Sobrien    %{!shared:crtend.o%s} \
84107286Sobrien    %{shared:crtendS.o%s} crtn.o%s"
8558478Sobrien
8658478Sobrien
8758478Sobrien/************************[  Target stuff  ]***********************************/
8858478Sobrien
8995349Sobrien/* Define the actual types of some ANSI-mandated types.
9058478Sobrien   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
9158478Sobrien   c-common.c, and config/<arch>/<arch>.h.  */
9258478Sobrien
9395349Sobrien#undef  SIZE_TYPE
9498597Sobrien#define SIZE_TYPE	(TARGET_64BIT ? "long unsigned int" : "unsigned int")
9595349Sobrien
9695349Sobrien#undef  PTRDIFF_TYPE
9798597Sobrien#define PTRDIFF_TYPE	(TARGET_64BIT ? "long int" : "int")
9858478Sobrien
9995349Sobrien#undef  WCHAR_TYPE_SIZE
10098597Sobrien#define WCHAR_TYPE_SIZE	(TARGET_64BIT ? 32 : BITS_PER_WORD)
10195349Sobrien
10258478Sobrien#define TARGET_VERSION	fprintf (stderr, " (i386 FreeBSD/ELF)");
10358478Sobrien
10434229Speter#define MASK_PROFILER_EPILOGUE	010000000000
10518349Speter
10634229Speter#define TARGET_PROFILER_EPILOGUE	(target_flags & MASK_PROFILER_EPILOGUE)
107107286Sobrien#define TARGET_ELF			1
10818349Speter
10934229Speter#undef	SUBTARGET_SWITCHES
11052112Sobrien#define SUBTARGET_SWITCHES						\
11168601Sobrien  { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \
112107286Sobrien  { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE, "No function profiler epilogue"},
11318349Speter
11458478Sobrien/* This goes away when the math emulator is fixed.  */
11595810Sobrien#undef  TARGET_SUBTARGET_DEFAULT
11695810Sobrien#define TARGET_SUBTARGET_DEFAULT \
11758478Sobrien  (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
11858478Sobrien
11995349Sobrien/* Don't default to pcc-struct-return, we want to retain compatibility with
12095349Sobrien   older gcc versions AND pcc-struct-return is nonreentrant.
12195349Sobrien   (even though the SVR4 ABI for the i386 says that records and unions are
12295349Sobrien   returned in memory).  */
12318349Speter
12495349Sobrien#undef  DEFAULT_PCC_STRUCT_RETURN
12595349Sobrien#define DEFAULT_PCC_STRUCT_RETURN 0
12695349Sobrien
127117418Skan/* FreeBSD sets the rounding precision of the FPU to 53 bits.  Let the
128117418Skan   compiler get the contents of <float.h> and std::numeric_limits correct.  */
129117418Skan#define SUBTARGET_OVERRIDE_OPTIONS			\
130117418Skan  do {							\
131117418Skan    real_format_for_mode[XFmode - QFmode]		\
132117418Skan      = &ieee_extended_intel_96_round_53_format;	\
133117418Skan    real_format_for_mode[TFmode - QFmode]		\
134117418Skan      = &ieee_extended_intel_96_round_53_format;	\
135117418Skan  } while (0)
136117418Skan
13758478Sobrien/* Tell final.c that we don't need a label passed to mcount.  */
13895810Sobrien#define NO_PROFILE_COUNTERS	1
13958478Sobrien
14058478Sobrien/* Output assembler code to FILE to begin profiling of the current function.
14158478Sobrien   LABELNO is an optional label.  */
14258478Sobrien
143117418Skan#undef MCOUNT_NAME
144117418Skan#define MCOUNT_NAME ".mcount"
14558478Sobrien
14658478Sobrien/* Output assembler code to FILE to end profiling of the current function.  */
14758478Sobrien
14895810Sobrien#undef  FUNCTION_PROFILER_EPILOGUE	/* BDE will need to fix this. */
14958478Sobrien
15058478Sobrien
15158478Sobrien/************************[  Assembler stuff  ]********************************/
15258478Sobrien
15395348Sobrien/* Override the default comment-starter of "/" from unix.h.  */
15495348Sobrien#undef  ASM_COMMENT_START
15595348Sobrien#define ASM_COMMENT_START "#"
15695348Sobrien
15796144Sobrien/* Override the default comment-starter of "/APP" from unix.h.  */
15858478Sobrien#undef  ASM_APP_ON
15958478Sobrien#define ASM_APP_ON	"#APP\n"
16058478Sobrien#undef  ASM_APP_OFF
16195349Sobrien#define ASM_APP_OFF	"#NO_APP\n"
16258478Sobrien
163107286Sobrien/* XXX:DEO do we still need this override to defaults.h ?? */
16458478Sobrien/* This is how to output a reference to a user-level label named NAME.  */
16558478Sobrien#undef  ASM_OUTPUT_LABELREF
16658478Sobrien#define ASM_OUTPUT_LABELREF(FILE, NAME)					\
16758478Sobrien  do {									\
16858478Sobrien    char *_name = (NAME);						\
16958478Sobrien    /* Hack to avoid writing lots of rtl in				\
17058478Sobrien       FUNCTION_PROFILER_EPILOGUE ().  */				\
17158478Sobrien    if (*_name == '.' && strcmp(_name + 1, "mexitcount") == 0)		\
17258478Sobrien      {									\
17358478Sobrien	if (flag_pic)							\
17458478Sobrien	  fprintf ((FILE), "*%s@GOT(%%ebx)", _name);			\
17558478Sobrien	else								\
17658478Sobrien	  fprintf ((FILE), "%s", _name);				\
17758478Sobrien      }									\
17858478Sobrien    else								\
179107286Sobrien      fprintf (FILE, "%s", _name);					\
18058478Sobrien} while (0)
18158478Sobrien
18256810Sobrien/* This is how to hack on the symbol code of certain relcalcitrant
18356810Sobrien   symbols to modify their output in output_pic_addr_const ().  */
18456810Sobrien
18595810Sobrien#undef  ASM_HACK_SYMBOLREF_CODE	/* BDE will need to fix this. */
18656810Sobrien
18758478Sobrien#undef  ASM_OUTPUT_ALIGN
18852112Sobrien#define ASM_OUTPUT_ALIGN(FILE, LOG)      				\
18997907Sobrien  do {					     				\
19097907Sobrien    if ((LOG)!=0) {							\
19197907Sobrien      if (in_text_section())						\
19297907Sobrien	fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG));		\
19397907Sobrien      else								\
19497907Sobrien	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
19597907Sobrien    }									\
19696466Sobrien  } while (0)
19718349Speter
19895810Sobrien/* A C statement to output to the stdio stream FILE an assembler
19995810Sobrien   command to advance the location counter to a multiple of 1<<LOG
20095810Sobrien   bytes if it is within MAX_SKIP bytes.
20151408Sobrien
20295810Sobrien   This is used to align code labels according to Intel recommendations.  */
20351408Sobrien
20496447Sobrien/* XXX configuration of this is broken in the same way as HAVE_GAS_SHF_MERGE,
20596447Sobrien   but it is easier to fix in an MD way.  */
20696447Sobrien
20795810Sobrien#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
20896447Sobrien#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)			\
20996466Sobrien  do {									\
21097910Sobrien    if ((LOG) != 0) {							\
211107286Sobrien      if ((MAX_SKIP) == 0)						\
21297910Sobrien	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
21397910Sobrien      else								\
21497910Sobrien	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
21597910Sobrien    }									\
21696466Sobrien  } while (0)
21795810Sobrien#endif
21858478Sobrien
219113420Skan/* If defined, a C expression whose value is a string containing the
220113420Skan   assembler operation to identify the following data as
221113420Skan   uninitialized global data.  If not defined, and neither
222113420Skan   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
223113420Skan   uninitialized global data will be output in the data section if
224113420Skan   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
225113420Skan   used.  */
226113420Skan#undef BSS_SECTION_ASM_OP
227113420Skan#define BSS_SECTION_ASM_OP "\t.section\t.bss"
22873305Sobrien
229113420Skan/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
230113420Skan   separate, explicit argument.  If you define this macro, it is used
231113420Skan   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
232113420Skan   handling the required alignment of the variable.  The alignment is
233113420Skan   specified as the number of bits.
234113420Skan
235113420Skan   Try to use function `asm_output_aligned_bss' defined in file
236113420Skan   `varasm.c' when defining this macro.  */
237113420Skan#undef ASM_OUTPUT_ALIGNED_BSS
238113420Skan#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
239113420Skan  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
240113420Skan
24158478Sobrien/************************[  Debugger stuff  ]*********************************/
24218334Speter
24334229Speter#undef  DBX_REGISTER_NUMBER
24495810Sobrien#define DBX_REGISTER_NUMBER(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
24595810Sobrien				: (write_symbols == DWARF2_DEBUG	\
24693263Sobrien	    			  || write_symbols == DWARF_DEBUG)	\
24795810Sobrien				  ? svr4_dbx_register_map[(n)]		\
24895810Sobrien				  : dbx_register_map[(n)])
24934229Speter
25099884Sobrien/* The same functions are used to creating the DWARF2 debug info and C++
25199884Sobrien   unwind info (except.c).  Regardless of the debug format requested, the
25299884Sobrien   register numbers used in exception unwinding sections still have to be
25399884Sobrien   DWARF compatible.  IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER
25499884Sobrien   macro to mean too much.  */
25599884Sobrien#define DWARF_FRAME_REGNUM(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
25699884Sobrien				: svr4_dbx_register_map[(n)])
25799884Sobrien
25858478Sobrien/* stabs-in-elf has offsets relative to function beginning */
25958478Sobrien#undef  DBX_OUTPUT_LBRAC
26058478Sobrien#define DBX_OUTPUT_LBRAC(FILE, NAME)					\
26158478Sobrien  do {									\
26258478Sobrien    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);		\
26358478Sobrien    assemble_name (asmfile, buf);					\
26458478Sobrien        fputc ('-', asmfile);						\
26558478Sobrien        assemble_name (asmfile,						\
26658478Sobrien	      	 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
26758478Sobrien    fprintf (asmfile, "\n");						\
26858478Sobrien  } while (0)
26952112Sobrien
27058478Sobrien#undef  DBX_OUTPUT_RBRAC
27158478Sobrien#define DBX_OUTPUT_RBRAC(FILE, NAME)					\
27258478Sobrien  do {									\
27358478Sobrien    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);		\
27458478Sobrien    assemble_name (asmfile, buf);					\
27558478Sobrien        fputc ('-', asmfile);						\
27658478Sobrien        assemble_name (asmfile,						\
27758478Sobrien		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
27858478Sobrien    fprintf (asmfile, "\n");						\
27958478Sobrien  } while (0)
280