1107286Sobrien/* Definitions for Intel 386 running FreeBSD with ELF format
2169706Skan   Copyright (C) 1996, 2000, 2002, 2004 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
22169706Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
23169706SkanBoston, MA 02110-1301, USA.  */
2418334Speter
25146915Skan/* $FreeBSD$ */
2618334Speter
2758478Sobrien#undef  CC1_SPEC
28114077Sobrien#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
2951408Sobrien
3058478Sobrien/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
3158478Sobrien   for the special GCC options -static and -shared, which allow us to
3258478Sobrien   link things in one of these three modes by applying the appropriate
3358478Sobrien   combinations of options at link-time. We like to support here for
3458478Sobrien   as many of the other GNU linker options as possible. But I don't
3558478Sobrien   have the time to search for those flags. I am sure how to add
3658478Sobrien   support for -soname shared_object_name. H.J.
3758478Sobrien
3858478Sobrien   When the -shared link option is used a final link is not being
3958478Sobrien   done.  */
4058478Sobrien
4158478Sobrien#undef	LINK_SPEC
4258478Sobrien#define LINK_SPEC "\
43117418Skan %{p:%nconsider using `-pg' instead of `-p' with gprof(1) } \
4495349Sobrien    %{v:-V} \
4558478Sobrien    %{assert*} %{R*} %{rpath*} %{defsym*} \
4658478Sobrien    %{shared:-Bshareable %{h*} %{soname*}} \
4758478Sobrien    %{!shared: \
4858478Sobrien      %{!static: \
4958478Sobrien	%{rdynamic: -export-dynamic} \
50132741Skan	%{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
5195349Sobrien      %{static:-Bstatic}} \
52238472Skib    %{!static:--hash-style=both --enable-new-dtags} \
53107286Sobrien    %{symbolic:-Bsymbolic}"
5458478Sobrien
55119414Sobrien/* Reset our STARTFILE_SPEC which was properly set in config/freebsd.h
56119414Sobrien   but trashed by config/<cpu>/<file.h>. */
5795349Sobrien
58180079Sobrien#undef  STARTFILE_SPEC
59119414Sobrien#define STARTFILE_SPEC FBSD_STARTFILE_SPEC
6058478Sobrien
61119414Sobrien/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386.  */
6258478Sobrien
6358478Sobrien#undef  ENDFILE_SPEC
64119414Sobrien#define ENDFILE_SPEC FBSD_ENDFILE_SPEC
6558478Sobrien
6658478Sobrien
6758478Sobrien/************************[  Target stuff  ]***********************************/
6858478Sobrien
6995349Sobrien/* Define the actual types of some ANSI-mandated types.
7058478Sobrien   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
7158478Sobrien   c-common.c, and config/<arch>/<arch>.h.  */
7258478Sobrien
7395349Sobrien#undef  SIZE_TYPE
7498597Sobrien#define SIZE_TYPE	(TARGET_64BIT ? "long unsigned int" : "unsigned int")
7595349Sobrien
7695349Sobrien#undef  PTRDIFF_TYPE
7798597Sobrien#define PTRDIFF_TYPE	(TARGET_64BIT ? "long int" : "int")
7858478Sobrien
7995349Sobrien#undef  WCHAR_TYPE_SIZE
8098597Sobrien#define WCHAR_TYPE_SIZE	(TARGET_64BIT ? 32 : BITS_PER_WORD)
8195349Sobrien
82180078Sobrien#undef  SUBTARGET_EXTRA_SPECS	/* i386.h bogusly defines it.  */
83132741Skan#define SUBTARGET_EXTRA_SPECS \
84132741Skan  { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }
85132741Skan
8658478Sobrien#define TARGET_VERSION	fprintf (stderr, " (i386 FreeBSD/ELF)");
8758478Sobrien
88180079Sobrien#define TARGET_ELF	1
8918349Speter
9095349Sobrien/* Don't default to pcc-struct-return, we want to retain compatibility with
9195349Sobrien   older gcc versions AND pcc-struct-return is nonreentrant.
9295349Sobrien   (even though the SVR4 ABI for the i386 says that records and unions are
9395349Sobrien   returned in memory).  */
9418349Speter
9595349Sobrien#undef  DEFAULT_PCC_STRUCT_RETURN
9695349Sobrien#define DEFAULT_PCC_STRUCT_RETURN 0
9795349Sobrien
98117418Skan/* FreeBSD sets the rounding precision of the FPU to 53 bits.  Let the
99117418Skan   compiler get the contents of <float.h> and std::numeric_limits correct.  */
100180079Sobrien#undef  TARGET_96_ROUND_53_LONG_DOUBLE
101146908Skan#define TARGET_96_ROUND_53_LONG_DOUBLE (!TARGET_64BIT)
102117418Skan
10358478Sobrien/* Tell final.c that we don't need a label passed to mcount.  */
10495810Sobrien#define NO_PROFILE_COUNTERS	1
10558478Sobrien
10658478Sobrien/* Output assembler code to FILE to begin profiling of the current function.
10758478Sobrien   LABELNO is an optional label.  */
10858478Sobrien
109180079Sobrien#undef  MCOUNT_NAME
110117418Skan#define MCOUNT_NAME ".mcount"
11158478Sobrien
11258478Sobrien/* Output assembler code to FILE to end profiling of the current function.  */
11358478Sobrien
11495810Sobrien#undef  FUNCTION_PROFILER_EPILOGUE	/* BDE will need to fix this. */
11558478Sobrien
11658478Sobrien
11758478Sobrien/************************[  Assembler stuff  ]********************************/
11858478Sobrien
11995348Sobrien/* Override the default comment-starter of "/" from unix.h.  */
12095348Sobrien#undef  ASM_COMMENT_START
12195348Sobrien#define ASM_COMMENT_START "#"
12295348Sobrien
12396144Sobrien/* Override the default comment-starter of "/APP" from unix.h.  */
12458478Sobrien#undef  ASM_APP_ON
12558478Sobrien#define ASM_APP_ON	"#APP\n"
12658478Sobrien#undef  ASM_APP_OFF
12795349Sobrien#define ASM_APP_OFF	"#NO_APP\n"
12858478Sobrien
129107286Sobrien/* XXX:DEO do we still need this override to defaults.h ?? */
13058478Sobrien/* This is how to output a reference to a user-level label named NAME.  */
13158478Sobrien#undef  ASM_OUTPUT_LABELREF
13258478Sobrien#define ASM_OUTPUT_LABELREF(FILE, NAME)					\
13358478Sobrien  do {									\
134123715Skan    const char *xname = (NAME);						\
13558478Sobrien    /* Hack to avoid writing lots of rtl in				\
13658478Sobrien       FUNCTION_PROFILER_EPILOGUE ().  */				\
137123715Skan    if (*xname == '.' && strcmp(xname + 1, "mexitcount") == 0)		\
13858478Sobrien      {									\
13958478Sobrien	if (flag_pic)							\
140123715Skan	  fprintf ((FILE), "*%s@GOT(%%ebx)", xname);			\
14158478Sobrien	else								\
142123715Skan	  fprintf ((FILE), "%s", xname);				\
14358478Sobrien      }									\
144180079Sobrien    else								\
145123715Skan      {									\
146123715Skan	  if (xname[0] == '%')						\
147123715Skan	    xname += 2;							\
148123715Skan	  if (xname[0] == '*')						\
149123715Skan	    xname += 1;							\
150123715Skan	  else								\
151123715Skan	    fputs (user_label_prefix, FILE);				\
152123715Skan	  fputs (xname, FILE);						\
153123715Skan      }									\
15458478Sobrien} while (0)
15558478Sobrien
15656810Sobrien/* This is how to hack on the symbol code of certain relcalcitrant
15756810Sobrien   symbols to modify their output in output_pic_addr_const ().  */
15856810Sobrien
15995810Sobrien#undef  ASM_HACK_SYMBOLREF_CODE	/* BDE will need to fix this. */
16056810Sobrien
16195810Sobrien/* A C statement to output to the stdio stream FILE an assembler
16295810Sobrien   command to advance the location counter to a multiple of 1<<LOG
16395810Sobrien   bytes if it is within MAX_SKIP bytes.
16451408Sobrien
16595810Sobrien   This is used to align code labels according to Intel recommendations.  */
16651408Sobrien
16796447Sobrien/* XXX configuration of this is broken in the same way as HAVE_GAS_SHF_MERGE,
16896447Sobrien   but it is easier to fix in an MD way.  */
16996447Sobrien
17095810Sobrien#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
171132741Skan#undef  ASM_OUTPUT_MAX_SKIP_ALIGN
17296447Sobrien#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)			\
17396466Sobrien  do {									\
17497910Sobrien    if ((LOG) != 0) {							\
175107286Sobrien      if ((MAX_SKIP) == 0)						\
17697910Sobrien	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
17797910Sobrien      else								\
17897910Sobrien	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
17997910Sobrien    }									\
18096466Sobrien  } while (0)
18195810Sobrien#endif
18258478Sobrien
183113420Skan/* If defined, a C expression whose value is a string containing the
184113420Skan   assembler operation to identify the following data as
185113420Skan   uninitialized global data.  If not defined, and neither
186113420Skan   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
187113420Skan   uninitialized global data will be output in the data section if
188113420Skan   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
189113420Skan   used.  */
190180079Sobrien#undef  BSS_SECTION_ASM_OP
191113420Skan#define BSS_SECTION_ASM_OP "\t.section\t.bss"
19273305Sobrien
193113420Skan/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
194113420Skan   separate, explicit argument.  If you define this macro, it is used
195113420Skan   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
196113420Skan   handling the required alignment of the variable.  The alignment is
197113420Skan   specified as the number of bits.
198113420Skan
199113420Skan   Try to use function `asm_output_aligned_bss' defined in file
200113420Skan   `varasm.c' when defining this macro.  */
201180079Sobrien#undef  ASM_OUTPUT_ALIGNED_BSS
202113420Skan#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
203113420Skan  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
204113420Skan
20558478Sobrien/************************[  Debugger stuff  ]*********************************/
20618334Speter
20734229Speter#undef  DBX_REGISTER_NUMBER
20895810Sobrien#define DBX_REGISTER_NUMBER(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
209169706Skan				: (write_symbols == DWARF2_DEBUG)	\
21095810Sobrien				  ? svr4_dbx_register_map[(n)]		\
21195810Sobrien				  : dbx_register_map[(n)])
21234229Speter
21399884Sobrien/* The same functions are used to creating the DWARF2 debug info and C++
21499884Sobrien   unwind info (except.c).  Regardless of the debug format requested, the
21599884Sobrien   register numbers used in exception unwinding sections still have to be
21699884Sobrien   DWARF compatible.  IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER
21799884Sobrien   macro to mean too much.  */
21899884Sobrien#define DWARF_FRAME_REGNUM(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
21999884Sobrien				: svr4_dbx_register_map[(n)])
22099884Sobrien
22158478Sobrien/* stabs-in-elf has offsets relative to function beginning */
22258478Sobrien#undef  DBX_OUTPUT_LBRAC
22358478Sobrien#define DBX_OUTPUT_LBRAC(FILE, NAME)					\
22458478Sobrien  do {									\
225169706Skan    fprintf (asm_out_file, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);	\
226169706Skan    assemble_name (asm_out_file, NAME);					\
227169706Skan        fputc ('-', asm_out_file);					\
228169706Skan        assemble_name (asm_out_file,					\
229180079Sobrien		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
230169706Skan    fprintf (asm_out_file, "\n");					\
23158478Sobrien  } while (0)
23252112Sobrien
23358478Sobrien#undef  DBX_OUTPUT_RBRAC
23458478Sobrien#define DBX_OUTPUT_RBRAC(FILE, NAME)					\
23558478Sobrien  do {									\
236169706Skan    fprintf (asm_out_file, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);	\
237169706Skan    assemble_name (asm_out_file, NAME);					\
238169706Skan        fputc ('-', asm_out_file);					\
239169706Skan        assemble_name (asm_out_file,					\
24058478Sobrien		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
241169706Skan    fprintf (asm_out_file, "\n");					\
24258478Sobrien  } while (0)
243217098Skib
244217098Skib#undef NEED_INDICATE_EXEC_STACK
245217098Skib#define NEED_INDICATE_EXEC_STACK 1
246