freebsd.h revision 114077
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 114077 2003-04-26 19:16:54Z obrien $ */
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 "\
4958478Sobrien %{p:%e`-p' not supported; use `-pg' and 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#undef  TARGET_VERSION
10358478Sobrien#define TARGET_VERSION	fprintf (stderr, " (i386 FreeBSD/ELF)");
10458478Sobrien
10534229Speter#define MASK_PROFILER_EPILOGUE	010000000000
10618349Speter
10734229Speter#define TARGET_PROFILER_EPILOGUE	(target_flags & MASK_PROFILER_EPILOGUE)
108107286Sobrien#define TARGET_ELF			1
10918349Speter
11034229Speter#undef	SUBTARGET_SWITCHES
11152112Sobrien#define SUBTARGET_SWITCHES						\
11268601Sobrien  { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \
113107286Sobrien  { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE, "No function profiler epilogue"},
11418349Speter
11558478Sobrien/* This goes away when the math emulator is fixed.  */
11695810Sobrien#undef  TARGET_SUBTARGET_DEFAULT
11795810Sobrien#define TARGET_SUBTARGET_DEFAULT \
11858478Sobrien  (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
11958478Sobrien
12095349Sobrien/* Don't default to pcc-struct-return, we want to retain compatibility with
12195349Sobrien   older gcc versions AND pcc-struct-return is nonreentrant.
12295349Sobrien   (even though the SVR4 ABI for the i386 says that records and unions are
12395349Sobrien   returned in memory).  */
12418349Speter
12595349Sobrien#undef  DEFAULT_PCC_STRUCT_RETURN
12695349Sobrien#define DEFAULT_PCC_STRUCT_RETURN 0
12795349Sobrien
12858478Sobrien/* Tell final.c that we don't need a label passed to mcount.  */
12995810Sobrien#define NO_PROFILE_COUNTERS	1
13058478Sobrien
13158478Sobrien/* Output assembler code to FILE to begin profiling of the current function.
13258478Sobrien   LABELNO is an optional label.  */
13358478Sobrien
13458478Sobrien#undef  FUNCTION_PROFILER
13558478Sobrien#define FUNCTION_PROFILER(FILE, LABELNO)  \
13658478Sobrien  do {									\
13758478Sobrien    if (flag_pic)							\
138107286Sobrien      fprintf ((FILE), "\tcall *.mcount%s@GOT(%%ebx)\n");		\
13958478Sobrien    else								\
140107286Sobrien      fprintf ((FILE), "\tcall .mcount\n");				\
14158478Sobrien  } while (0)
14258478Sobrien
14358478Sobrien/* Output assembler code to FILE to end profiling of the current function.  */
14458478Sobrien
14595810Sobrien#undef  FUNCTION_PROFILER_EPILOGUE	/* BDE will need to fix this. */
14658478Sobrien
14758478Sobrien
14858478Sobrien/************************[  Assembler stuff  ]********************************/
14958478Sobrien
15095348Sobrien/* Override the default comment-starter of "/" from unix.h.  */
15195348Sobrien#undef  ASM_COMMENT_START
15295348Sobrien#define ASM_COMMENT_START "#"
15395348Sobrien
15496144Sobrien/* Override the default comment-starter of "/APP" from unix.h.  */
15558478Sobrien#undef  ASM_APP_ON
15658478Sobrien#define ASM_APP_ON	"#APP\n"
15758478Sobrien#undef  ASM_APP_OFF
15895349Sobrien#define ASM_APP_OFF	"#NO_APP\n"
15958478Sobrien
160107286Sobrien/* XXX:DEO do we still need this override to defaults.h ?? */
16158478Sobrien/* This is how to output a reference to a user-level label named NAME.  */
16258478Sobrien#undef  ASM_OUTPUT_LABELREF
16358478Sobrien#define ASM_OUTPUT_LABELREF(FILE, NAME)					\
16458478Sobrien  do {									\
16558478Sobrien    char *_name = (NAME);						\
16658478Sobrien    /* Hack to avoid writing lots of rtl in				\
16758478Sobrien       FUNCTION_PROFILER_EPILOGUE ().  */				\
16858478Sobrien    if (*_name == '.' && strcmp(_name + 1, "mexitcount") == 0)		\
16958478Sobrien      {									\
17058478Sobrien	if (flag_pic)							\
17158478Sobrien	  fprintf ((FILE), "*%s@GOT(%%ebx)", _name);			\
17258478Sobrien	else								\
17358478Sobrien	  fprintf ((FILE), "%s", _name);				\
17458478Sobrien      }									\
17558478Sobrien    else								\
176107286Sobrien      fprintf (FILE, "%s", _name);					\
17758478Sobrien} while (0)
17858478Sobrien
17956810Sobrien/* This is how to hack on the symbol code of certain relcalcitrant
18056810Sobrien   symbols to modify their output in output_pic_addr_const ().  */
18156810Sobrien
18295810Sobrien#undef  ASM_HACK_SYMBOLREF_CODE	/* BDE will need to fix this. */
18356810Sobrien
18458478Sobrien#undef  ASM_OUTPUT_ALIGN
18552112Sobrien#define ASM_OUTPUT_ALIGN(FILE, LOG)      				\
18697907Sobrien  do {					     				\
18797907Sobrien    if ((LOG)!=0) {							\
18897907Sobrien      if (in_text_section())						\
18997907Sobrien	fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG));		\
19097907Sobrien      else								\
19197907Sobrien	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
19297907Sobrien    }									\
19396466Sobrien  } while (0)
19418349Speter
19595810Sobrien/* A C statement to output to the stdio stream FILE an assembler
19695810Sobrien   command to advance the location counter to a multiple of 1<<LOG
19795810Sobrien   bytes if it is within MAX_SKIP bytes.
19851408Sobrien
19995810Sobrien   This is used to align code labels according to Intel recommendations.  */
20051408Sobrien
20196447Sobrien/* XXX configuration of this is broken in the same way as HAVE_GAS_SHF_MERGE,
20296447Sobrien   but it is easier to fix in an MD way.  */
20396447Sobrien
20495810Sobrien#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
20596447Sobrien#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)			\
20696466Sobrien  do {									\
20797910Sobrien    if ((LOG) != 0) {							\
208107286Sobrien      if ((MAX_SKIP) == 0)						\
20997910Sobrien	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
21097910Sobrien      else								\
21197910Sobrien	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
21297910Sobrien    }									\
21396466Sobrien  } while (0)
21495810Sobrien#endif
21558478Sobrien
216113420Skan/* If defined, a C expression whose value is a string containing the
217113420Skan   assembler operation to identify the following data as
218113420Skan   uninitialized global data.  If not defined, and neither
219113420Skan   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
220113420Skan   uninitialized global data will be output in the data section if
221113420Skan   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
222113420Skan   used.  */
223113420Skan#undef BSS_SECTION_ASM_OP
224113420Skan#define BSS_SECTION_ASM_OP "\t.section\t.bss"
22573305Sobrien
226113420Skan/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
227113420Skan   separate, explicit argument.  If you define this macro, it is used
228113420Skan   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
229113420Skan   handling the required alignment of the variable.  The alignment is
230113420Skan   specified as the number of bits.
231113420Skan
232113420Skan   Try to use function `asm_output_aligned_bss' defined in file
233113420Skan   `varasm.c' when defining this macro.  */
234113420Skan#undef ASM_OUTPUT_ALIGNED_BSS
235113420Skan#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
236113420Skan  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
237113420Skan
23858478Sobrien/************************[  Debugger stuff  ]*********************************/
23918334Speter
24034229Speter#undef  DBX_REGISTER_NUMBER
24195810Sobrien#define DBX_REGISTER_NUMBER(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
24295810Sobrien				: (write_symbols == DWARF2_DEBUG	\
24393263Sobrien	    			  || write_symbols == DWARF_DEBUG)	\
24495810Sobrien				  ? svr4_dbx_register_map[(n)]		\
24595810Sobrien				  : dbx_register_map[(n)])
24634229Speter
24799884Sobrien/* The same functions are used to creating the DWARF2 debug info and C++
24899884Sobrien   unwind info (except.c).  Regardless of the debug format requested, the
24999884Sobrien   register numbers used in exception unwinding sections still have to be
25099884Sobrien   DWARF compatible.  IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER
25199884Sobrien   macro to mean too much.  */
25299884Sobrien#define DWARF_FRAME_REGNUM(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
25399884Sobrien				: svr4_dbx_register_map[(n)])
25499884Sobrien
25558478Sobrien/* stabs-in-elf has offsets relative to function beginning */
25658478Sobrien#undef  DBX_OUTPUT_LBRAC
25758478Sobrien#define DBX_OUTPUT_LBRAC(FILE, NAME)					\
25858478Sobrien  do {									\
25958478Sobrien    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);		\
26058478Sobrien    assemble_name (asmfile, buf);					\
26158478Sobrien        fputc ('-', asmfile);						\
26258478Sobrien        assemble_name (asmfile,						\
26358478Sobrien	      	 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
26458478Sobrien    fprintf (asmfile, "\n");						\
26558478Sobrien  } while (0)
26652112Sobrien
26758478Sobrien#undef  DBX_OUTPUT_RBRAC
26858478Sobrien#define DBX_OUTPUT_RBRAC(FILE, NAME)					\
26958478Sobrien  do {									\
27058478Sobrien    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);		\
27158478Sobrien    assemble_name (asmfile, buf);					\
27258478Sobrien        fputc ('-', asmfile);						\
27358478Sobrien        assemble_name (asmfile,						\
27458478Sobrien		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
27558478Sobrien    fprintf (asmfile, "\n");						\
27658478Sobrien  } while (0)
277