freebsd.h revision 146908
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
8132741SkanThis file is part of GCC.
918334Speter
10132741SkanGCC 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
15132741SkanGCC 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
21132741Skanalong with GCC; see the file COPYING.  If not, write to
2218334Speterthe Free Software Foundation, 59 Temple Place - Suite 330,
2318334SpeterBoston, MA 02111-1307, USA.  */
2418334Speter
25146908Skan-/* $FreeBSD: head/contrib/gcc/config/i386/freebsd.h 146908 2005-06-03 04:02:20Z 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
3358478Sobrien/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
3458478Sobrien   for the special GCC options -static and -shared, which allow us to
3558478Sobrien   link things in one of these three modes by applying the appropriate
3658478Sobrien   combinations of options at link-time. We like to support here for
3758478Sobrien   as many of the other GNU linker options as possible. But I don't
3858478Sobrien   have the time to search for those flags. I am sure how to add
3958478Sobrien   support for -soname shared_object_name. H.J.
4058478Sobrien
4158478Sobrien   When the -shared link option is used a final link is not being
4258478Sobrien   done.  */
4358478Sobrien
4458478Sobrien#undef	LINK_SPEC
4558478Sobrien#define LINK_SPEC "\
46117418Skan %{p:%nconsider using `-pg' instead of `-p' with gprof(1) } \
4758478Sobrien    %{Wl,*:%*} \
4895349Sobrien    %{v:-V} \
4958478Sobrien    %{assert*} %{R*} %{rpath*} %{defsym*} \
5058478Sobrien    %{shared:-Bshareable %{h*} %{soname*}} \
5158478Sobrien    %{!shared: \
5258478Sobrien      %{!static: \
5358478Sobrien	%{rdynamic: -export-dynamic} \
54132741Skan	%{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
5595349Sobrien      %{static:-Bstatic}} \
56107286Sobrien    %{symbolic:-Bsymbolic}"
5758478Sobrien
58119414Sobrien/* Reset our STARTFILE_SPEC which was properly set in config/freebsd.h
59119414Sobrien   but trashed by config/<cpu>/<file.h>. */
6095349Sobrien
6158478Sobrien#undef STARTFILE_SPEC
62119414Sobrien#define STARTFILE_SPEC FBSD_STARTFILE_SPEC
6358478Sobrien
64119414Sobrien/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386.  */
6558478Sobrien
6658478Sobrien#undef  ENDFILE_SPEC
67119414Sobrien#define ENDFILE_SPEC FBSD_ENDFILE_SPEC
6858478Sobrien
6958478Sobrien
7058478Sobrien/************************[  Target stuff  ]***********************************/
7158478Sobrien
7295349Sobrien/* Define the actual types of some ANSI-mandated types.
7358478Sobrien   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
7458478Sobrien   c-common.c, and config/<arch>/<arch>.h.  */
7558478Sobrien
7695349Sobrien#undef  SIZE_TYPE
7798597Sobrien#define SIZE_TYPE	(TARGET_64BIT ? "long unsigned int" : "unsigned int")
7895349Sobrien
7995349Sobrien#undef  PTRDIFF_TYPE
8098597Sobrien#define PTRDIFF_TYPE	(TARGET_64BIT ? "long int" : "int")
8158478Sobrien
8295349Sobrien#undef  WCHAR_TYPE_SIZE
8398597Sobrien#define WCHAR_TYPE_SIZE	(TARGET_64BIT ? 32 : BITS_PER_WORD)
8495349Sobrien
85132741Skan#undef  SUBTARGET_EXTRA_SPECS  /* i386.h bogusly defines it.  */
86132741Skan#define SUBTARGET_EXTRA_SPECS \
87132741Skan  { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }
88132741Skan
8958478Sobrien#define TARGET_VERSION	fprintf (stderr, " (i386 FreeBSD/ELF)");
9058478Sobrien
9134229Speter#define MASK_PROFILER_EPILOGUE	010000000000
9218349Speter
9334229Speter#define TARGET_PROFILER_EPILOGUE	(target_flags & MASK_PROFILER_EPILOGUE)
94107286Sobrien#define TARGET_ELF			1
9518349Speter
9634229Speter#undef	SUBTARGET_SWITCHES
9752112Sobrien#define SUBTARGET_SWITCHES						\
9868601Sobrien  { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \
99107286Sobrien  { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE, "No function profiler epilogue"},
10018349Speter
10158478Sobrien/* This goes away when the math emulator is fixed.  */
10295810Sobrien#undef  TARGET_SUBTARGET_DEFAULT
10395810Sobrien#define TARGET_SUBTARGET_DEFAULT \
10458478Sobrien  (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
10558478Sobrien
10695349Sobrien/* Don't default to pcc-struct-return, we want to retain compatibility with
10795349Sobrien   older gcc versions AND pcc-struct-return is nonreentrant.
10895349Sobrien   (even though the SVR4 ABI for the i386 says that records and unions are
10995349Sobrien   returned in memory).  */
11018349Speter
11195349Sobrien#undef  DEFAULT_PCC_STRUCT_RETURN
11295349Sobrien#define DEFAULT_PCC_STRUCT_RETURN 0
11395349Sobrien
114117418Skan/* FreeBSD sets the rounding precision of the FPU to 53 bits.  Let the
115117418Skan   compiler get the contents of <float.h> and std::numeric_limits correct.  */
116146908Skan#undef TARGET_96_ROUND_53_LONG_DOUBLE
117146908Skan#define TARGET_96_ROUND_53_LONG_DOUBLE (!TARGET_64BIT)
118117418Skan
11958478Sobrien/* Tell final.c that we don't need a label passed to mcount.  */
12095810Sobrien#define NO_PROFILE_COUNTERS	1
12158478Sobrien
12258478Sobrien/* Output assembler code to FILE to begin profiling of the current function.
12358478Sobrien   LABELNO is an optional label.  */
12458478Sobrien
125117418Skan#undef MCOUNT_NAME
126117418Skan#define MCOUNT_NAME ".mcount"
12758478Sobrien
12858478Sobrien/* Output assembler code to FILE to end profiling of the current function.  */
12958478Sobrien
13095810Sobrien#undef  FUNCTION_PROFILER_EPILOGUE	/* BDE will need to fix this. */
13158478Sobrien
13258478Sobrien
13358478Sobrien/************************[  Assembler stuff  ]********************************/
13458478Sobrien
13595348Sobrien/* Override the default comment-starter of "/" from unix.h.  */
13695348Sobrien#undef  ASM_COMMENT_START
13795348Sobrien#define ASM_COMMENT_START "#"
13895348Sobrien
13996144Sobrien/* Override the default comment-starter of "/APP" from unix.h.  */
14058478Sobrien#undef  ASM_APP_ON
14158478Sobrien#define ASM_APP_ON	"#APP\n"
14258478Sobrien#undef  ASM_APP_OFF
14395349Sobrien#define ASM_APP_OFF	"#NO_APP\n"
14458478Sobrien
145107286Sobrien/* XXX:DEO do we still need this override to defaults.h ?? */
14658478Sobrien/* This is how to output a reference to a user-level label named NAME.  */
14758478Sobrien#undef  ASM_OUTPUT_LABELREF
14858478Sobrien#define ASM_OUTPUT_LABELREF(FILE, NAME)					\
14958478Sobrien  do {									\
150123715Skan    const char *xname = (NAME);						\
15158478Sobrien    /* Hack to avoid writing lots of rtl in				\
15258478Sobrien       FUNCTION_PROFILER_EPILOGUE ().  */				\
153123715Skan    if (*xname == '.' && strcmp(xname + 1, "mexitcount") == 0)		\
15458478Sobrien      {									\
15558478Sobrien	if (flag_pic)							\
156123715Skan	  fprintf ((FILE), "*%s@GOT(%%ebx)", xname);			\
15758478Sobrien	else								\
158123715Skan	  fprintf ((FILE), "%s", xname);				\
15958478Sobrien      }									\
160123715Skan    else 								\
161123715Skan      {									\
162123715Skan	  if (xname[0] == '%')						\
163123715Skan	    xname += 2;							\
164123715Skan	  if (xname[0] == '*')						\
165123715Skan	    xname += 1;							\
166123715Skan	  else								\
167123715Skan	    fputs (user_label_prefix, FILE);				\
168123715Skan	  fputs (xname, FILE);						\
169123715Skan      }									\
17058478Sobrien} while (0)
17158478Sobrien
17256810Sobrien/* This is how to hack on the symbol code of certain relcalcitrant
17356810Sobrien   symbols to modify their output in output_pic_addr_const ().  */
17456810Sobrien
17595810Sobrien#undef  ASM_HACK_SYMBOLREF_CODE	/* BDE will need to fix this. */
17656810Sobrien
17758478Sobrien#undef  ASM_OUTPUT_ALIGN
17852112Sobrien#define ASM_OUTPUT_ALIGN(FILE, LOG)      				\
17997907Sobrien  do {					     				\
18097907Sobrien    if ((LOG)!=0) {							\
18197907Sobrien      if (in_text_section())						\
18297907Sobrien	fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG));		\
18397907Sobrien      else								\
18497907Sobrien	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
18597907Sobrien    }									\
18696466Sobrien  } while (0)
18718349Speter
18895810Sobrien/* A C statement to output to the stdio stream FILE an assembler
18995810Sobrien   command to advance the location counter to a multiple of 1<<LOG
19095810Sobrien   bytes if it is within MAX_SKIP bytes.
19151408Sobrien
19295810Sobrien   This is used to align code labels according to Intel recommendations.  */
19351408Sobrien
19496447Sobrien/* XXX configuration of this is broken in the same way as HAVE_GAS_SHF_MERGE,
19596447Sobrien   but it is easier to fix in an MD way.  */
19696447Sobrien
19795810Sobrien#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
198132741Skan#undef  ASM_OUTPUT_MAX_SKIP_ALIGN
19996447Sobrien#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)			\
20096466Sobrien  do {									\
20197910Sobrien    if ((LOG) != 0) {							\
202107286Sobrien      if ((MAX_SKIP) == 0)						\
20397910Sobrien	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
20497910Sobrien      else								\
20597910Sobrien	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
20697910Sobrien    }									\
20796466Sobrien  } while (0)
20895810Sobrien#endif
20958478Sobrien
210113420Skan/* If defined, a C expression whose value is a string containing the
211113420Skan   assembler operation to identify the following data as
212113420Skan   uninitialized global data.  If not defined, and neither
213113420Skan   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
214113420Skan   uninitialized global data will be output in the data section if
215113420Skan   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
216113420Skan   used.  */
217113420Skan#undef BSS_SECTION_ASM_OP
218113420Skan#define BSS_SECTION_ASM_OP "\t.section\t.bss"
21973305Sobrien
220113420Skan/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
221113420Skan   separate, explicit argument.  If you define this macro, it is used
222113420Skan   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
223113420Skan   handling the required alignment of the variable.  The alignment is
224113420Skan   specified as the number of bits.
225113420Skan
226113420Skan   Try to use function `asm_output_aligned_bss' defined in file
227113420Skan   `varasm.c' when defining this macro.  */
228113420Skan#undef ASM_OUTPUT_ALIGNED_BSS
229113420Skan#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
230113420Skan  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
231113420Skan
23258478Sobrien/************************[  Debugger stuff  ]*********************************/
23318334Speter
23434229Speter#undef  DBX_REGISTER_NUMBER
23595810Sobrien#define DBX_REGISTER_NUMBER(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
23695810Sobrien				: (write_symbols == DWARF2_DEBUG	\
23793263Sobrien	    			  || write_symbols == DWARF_DEBUG)	\
23895810Sobrien				  ? svr4_dbx_register_map[(n)]		\
23995810Sobrien				  : dbx_register_map[(n)])
24034229Speter
24199884Sobrien/* The same functions are used to creating the DWARF2 debug info and C++
24299884Sobrien   unwind info (except.c).  Regardless of the debug format requested, the
24399884Sobrien   register numbers used in exception unwinding sections still have to be
24499884Sobrien   DWARF compatible.  IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER
24599884Sobrien   macro to mean too much.  */
24699884Sobrien#define DWARF_FRAME_REGNUM(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
24799884Sobrien				: svr4_dbx_register_map[(n)])
24899884Sobrien
24958478Sobrien/* stabs-in-elf has offsets relative to function beginning */
25058478Sobrien#undef  DBX_OUTPUT_LBRAC
25158478Sobrien#define DBX_OUTPUT_LBRAC(FILE, NAME)					\
25258478Sobrien  do {									\
25358478Sobrien    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);		\
25458478Sobrien    assemble_name (asmfile, buf);					\
25558478Sobrien        fputc ('-', asmfile);						\
25658478Sobrien        assemble_name (asmfile,						\
25758478Sobrien	      	 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
25858478Sobrien    fprintf (asmfile, "\n");						\
25958478Sobrien  } while (0)
26052112Sobrien
26158478Sobrien#undef  DBX_OUTPUT_RBRAC
26258478Sobrien#define DBX_OUTPUT_RBRAC(FILE, NAME)					\
26358478Sobrien  do {									\
26458478Sobrien    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);		\
26558478Sobrien    assemble_name (asmfile, buf);					\
26658478Sobrien        fputc ('-', asmfile);						\
26758478Sobrien        assemble_name (asmfile,						\
26858478Sobrien		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
26958478Sobrien    fprintf (asmfile, "\n");						\
27058478Sobrien  } while (0)
271