freebsd.h revision 123715
1100966Siwasaki/* Definitions for Intel 386 running FreeBSD with ELF format
2100966Siwasaki   Copyright (C) 1996, 2000, 2002 Free Software Foundation, Inc.
3100966Siwasaki   Contributed by Eric Youngdale.
4100966Siwasaki   Modified for stabs-in-ELF by H.J. Lu.
5100966Siwasaki   Adapted from GNU/Linux version by John Polstra.
6100966Siwasaki   Continued development by David O'Brien <obrien@freebsd.org>
7217365Sjkim
8229989SjkimThis file is part of GNU CC.
9100966Siwasaki
10100966SiwasakiGNU CC is free software; you can redistribute it and/or modify
11217365Sjkimit under the terms of the GNU General Public License as published by
12217365Sjkimthe Free Software Foundation; either version 2, or (at your option)
13217365Sjkimany later version.
14217365Sjkim
15217365SjkimGNU CC is distributed in the hope that it will be useful,
16217365Sjkimbut WITHOUT ANY WARRANTY; without even the implied warranty of
17217365SjkimMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18217365SjkimGNU General Public License for more details.
19217365Sjkim
20217365SjkimYou should have received a copy of the GNU General Public License
21217365Sjkimalong with GNU CC; see the file COPYING.  If not, write to
22217365Sjkimthe Free Software Foundation, 59 Temple Place - Suite 330,
23217365SjkimBoston, MA 02111-1307, USA.  */
24217365Sjkim
25100966Siwasaki/* $FreeBSD: head/contrib/gcc/config/i386/freebsd.h 123715 2003-12-22 04:27:17Z kan $ */
26217365Sjkim
27217365Sjkim#undef  CC1_SPEC
28217365Sjkim#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
29100966Siwasaki
30217365Sjkim#undef  ASM_SPEC
31217365Sjkim#define ASM_SPEC	"%{v*: -v}"
32217365Sjkim
33217365Sjkim#undef  ASM_FINAL_SPEC
34217365Sjkim#define ASM_FINAL_SPEC	"%|"
35217365Sjkim
36217365Sjkim/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
37217365Sjkim   for the special GCC options -static and -shared, which allow us to
38217365Sjkim   link things in one of these three modes by applying the appropriate
39217365Sjkim   combinations of options at link-time. We like to support here for
40217365Sjkim   as many of the other GNU linker options as possible. But I don't
41217365Sjkim   have the time to search for those flags. I am sure how to add
42217365Sjkim   support for -soname shared_object_name. H.J.
43100966Siwasaki
44193341Sjkim   When the -shared link option is used a final link is not being
45193341Sjkim   done.  */
46193341Sjkim
47193341Sjkim#undef	LINK_SPEC
48193341Sjkim#define LINK_SPEC "\
49237412Sjkim %{p:%nconsider using `-pg' instead of `-p' with gprof(1) } \
50100966Siwasaki    %{Wl,*:%*} \
51100966Siwasaki    %{v:-V} \
52100966Siwasaki    %{assert*} %{R*} %{rpath*} %{defsym*} \
53102550Siwasaki    %{shared:-Bshareable %{h*} %{soname*}} \
54100966Siwasaki    %{!shared: \
55100966Siwasaki      %{!static: \
56151937Sjkim	%{rdynamic: -export-dynamic} \
57100966Siwasaki	%{!dynamic-linker: -dynamic-linker /libexec/ld-elf.so.1}} \
58151937Sjkim      %{static:-Bstatic}} \
59151937Sjkim    %{symbolic:-Bsymbolic}"
60151937Sjkim
61151937Sjkim/* Reset our STARTFILE_SPEC which was properly set in config/freebsd.h
62151937Sjkim   but trashed by config/<cpu>/<file.h>. */
63100966Siwasaki
64100966Siwasaki#undef STARTFILE_SPEC
65237412Sjkim#define STARTFILE_SPEC FBSD_STARTFILE_SPEC
66237412Sjkim
67237412Sjkim/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386.  */
68237412Sjkim
69237412Sjkim#undef  ENDFILE_SPEC
70237412Sjkim#define ENDFILE_SPEC FBSD_ENDFILE_SPEC
71237412Sjkim
72237412Sjkim
73237412Sjkim/************************[  Target stuff  ]***********************************/
74237412Sjkim
75237412Sjkim/* Define the actual types of some ANSI-mandated types.
76237412Sjkim   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
77237412Sjkim   c-common.c, and config/<arch>/<arch>.h.  */
78237412Sjkim
79237412Sjkim#undef  SIZE_TYPE
80237412Sjkim#define SIZE_TYPE	(TARGET_64BIT ? "long unsigned int" : "unsigned int")
81237412Sjkim
82237412Sjkim#undef  PTRDIFF_TYPE
83237412Sjkim#define PTRDIFF_TYPE	(TARGET_64BIT ? "long int" : "int")
84237412Sjkim
85237412Sjkim#undef  WCHAR_TYPE_SIZE
86237412Sjkim#define WCHAR_TYPE_SIZE	(TARGET_64BIT ? 32 : BITS_PER_WORD)
87237412Sjkim
88237412Sjkim#define TARGET_VERSION	fprintf (stderr, " (i386 FreeBSD/ELF)");
89237412Sjkim
90237412Sjkim#define MASK_PROFILER_EPILOGUE	010000000000
91237412Sjkim
92237412Sjkim#define TARGET_PROFILER_EPILOGUE	(target_flags & MASK_PROFILER_EPILOGUE)
93237412Sjkim#define TARGET_ELF			1
94237412Sjkim
95237412Sjkim#undef	SUBTARGET_SWITCHES
96237412Sjkim#define SUBTARGET_SWITCHES						\
97237412Sjkim  { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \
98237412Sjkim  { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE, "No function profiler epilogue"},
99237412Sjkim
100237412Sjkim/* This goes away when the math emulator is fixed.  */
101237412Sjkim#undef  TARGET_SUBTARGET_DEFAULT
102237412Sjkim#define TARGET_SUBTARGET_DEFAULT \
103237412Sjkim  (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
104237412Sjkim
105237412Sjkim/* Don't default to pcc-struct-return, we want to retain compatibility with
106237412Sjkim   older gcc versions AND pcc-struct-return is nonreentrant.
107237412Sjkim   (even though the SVR4 ABI for the i386 says that records and unions are
108237412Sjkim   returned in memory).  */
109237412Sjkim
110237412Sjkim#undef  DEFAULT_PCC_STRUCT_RETURN
111237412Sjkim#define DEFAULT_PCC_STRUCT_RETURN 0
112237412Sjkim
113237412Sjkim/* FreeBSD sets the rounding precision of the FPU to 53 bits.  Let the
114237412Sjkim   compiler get the contents of <float.h> and std::numeric_limits correct.  */
115237412Sjkim#define SUBTARGET_OVERRIDE_OPTIONS			\
116237412Sjkim  do {							\
117237412Sjkim    if (!TARGET_64BIT) {				\
118237412Sjkim      real_format_for_mode[XFmode - QFmode]		\
119237412Sjkim	= &ieee_extended_intel_96_round_53_format;	\
120237412Sjkim      real_format_for_mode[TFmode - QFmode]		\
121237412Sjkim	= &ieee_extended_intel_96_round_53_format;	\
122237412Sjkim    }							\
123237412Sjkim  } while (0)
124237412Sjkim
125237412Sjkim/* Tell final.c that we don't need a label passed to mcount.  */
126237412Sjkim#define NO_PROFILE_COUNTERS	1
127237412Sjkim
128237412Sjkim/* Output assembler code to FILE to begin profiling of the current function.
129237412Sjkim   LABELNO is an optional label.  */
130237412Sjkim
131237412Sjkim#undef MCOUNT_NAME
132237412Sjkim#define MCOUNT_NAME ".mcount"
133237412Sjkim
134237412Sjkim/* Output assembler code to FILE to end profiling of the current function.  */
135237412Sjkim
136237412Sjkim#undef  FUNCTION_PROFILER_EPILOGUE	/* BDE will need to fix this. */
137237412Sjkim
138237412Sjkim
139237412Sjkim/************************[  Assembler stuff  ]********************************/
140237412Sjkim
141237412Sjkim/* Override the default comment-starter of "/" from unix.h.  */
142237412Sjkim#undef  ASM_COMMENT_START
143237412Sjkim#define ASM_COMMENT_START "#"
144237412Sjkim
145237412Sjkim/* Override the default comment-starter of "/APP" from unix.h.  */
146237412Sjkim#undef  ASM_APP_ON
147237412Sjkim#define ASM_APP_ON	"#APP\n"
148237412Sjkim#undef  ASM_APP_OFF
149237412Sjkim#define ASM_APP_OFF	"#NO_APP\n"
150237412Sjkim
151237412Sjkim/* XXX:DEO do we still need this override to defaults.h ?? */
152237412Sjkim/* This is how to output a reference to a user-level label named NAME.  */
153237412Sjkim#undef  ASM_OUTPUT_LABELREF
154237412Sjkim#define ASM_OUTPUT_LABELREF(FILE, NAME)					\
155237412Sjkim  do {									\
156237412Sjkim    const char *xname = (NAME);						\
157237412Sjkim    /* Hack to avoid writing lots of rtl in				\
158237412Sjkim       FUNCTION_PROFILER_EPILOGUE ().  */				\
159237412Sjkim    if (*xname == '.' && strcmp(xname + 1, "mexitcount") == 0)		\
160237412Sjkim      {									\
161237412Sjkim	if (flag_pic)							\
162237412Sjkim	  fprintf ((FILE), "*%s@GOT(%%ebx)", xname);			\
163237412Sjkim	else								\
164237412Sjkim	  fprintf ((FILE), "%s", xname);				\
165237412Sjkim      }									\
166237412Sjkim    else 								\
167237412Sjkim      {									\
168237412Sjkim	  if (xname[0] == '%')						\
169237412Sjkim	    xname += 2;							\
170237412Sjkim	  if (xname[0] == '*')						\
171237412Sjkim	    xname += 1;							\
172237412Sjkim	  else								\
173237412Sjkim	    fputs (user_label_prefix, FILE);				\
174237412Sjkim	  fputs (xname, FILE);						\
175237412Sjkim      }									\
176237412Sjkim} while (0)
177237412Sjkim
178237412Sjkim/* This is how to hack on the symbol code of certain relcalcitrant
179237412Sjkim   symbols to modify their output in output_pic_addr_const ().  */
180237412Sjkim
181237412Sjkim#undef  ASM_HACK_SYMBOLREF_CODE	/* BDE will need to fix this. */
182237412Sjkim
183237412Sjkim#undef  ASM_OUTPUT_ALIGN
184237412Sjkim#define ASM_OUTPUT_ALIGN(FILE, LOG)      				\
185237412Sjkim  do {					     				\
186237412Sjkim    if ((LOG)!=0) {							\
187237412Sjkim      if (in_text_section())						\
188237412Sjkim	fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG));		\
189237412Sjkim      else								\
190237412Sjkim	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
191237412Sjkim    }									\
192237412Sjkim  } while (0)
193237412Sjkim
194237412Sjkim/* A C statement to output to the stdio stream FILE an assembler
195237412Sjkim   command to advance the location counter to a multiple of 1<<LOG
196237412Sjkim   bytes if it is within MAX_SKIP bytes.
197237412Sjkim
198237412Sjkim   This is used to align code labels according to Intel recommendations.  */
199237412Sjkim
200237412Sjkim/* XXX configuration of this is broken in the same way as HAVE_GAS_SHF_MERGE,
201237412Sjkim   but it is easier to fix in an MD way.  */
202237412Sjkim
203237412Sjkim#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
204237412Sjkim#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)			\
205237412Sjkim  do {									\
206237412Sjkim    if ((LOG) != 0) {							\
207237412Sjkim      if ((MAX_SKIP) == 0)						\
208237412Sjkim	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
209237412Sjkim      else								\
210237412Sjkim	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
211237412Sjkim    }									\
212237412Sjkim  } while (0)
213237412Sjkim#endif
214237412Sjkim
215237412Sjkim/* If defined, a C expression whose value is a string containing the
216237412Sjkim   assembler operation to identify the following data as
217237412Sjkim   uninitialized global data.  If not defined, and neither
218237412Sjkim   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
219237412Sjkim   uninitialized global data will be output in the data section if
220237412Sjkim   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
221237412Sjkim   used.  */
222237412Sjkim#undef BSS_SECTION_ASM_OP
223237412Sjkim#define BSS_SECTION_ASM_OP "\t.section\t.bss"
224237412Sjkim
225237412Sjkim/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
226237412Sjkim   separate, explicit argument.  If you define this macro, it is used
227237412Sjkim   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
228237412Sjkim   handling the required alignment of the variable.  The alignment is
229237412Sjkim   specified as the number of bits.
230237412Sjkim
231237412Sjkim   Try to use function `asm_output_aligned_bss' defined in file
232237412Sjkim   `varasm.c' when defining this macro.  */
233237412Sjkim#undef ASM_OUTPUT_ALIGNED_BSS
234237412Sjkim#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
235237412Sjkim  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
236237412Sjkim
237237412Sjkim/************************[  Debugger stuff  ]*********************************/
238237412Sjkim
239237412Sjkim#undef  DBX_REGISTER_NUMBER
240237412Sjkim#define DBX_REGISTER_NUMBER(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
241237412Sjkim				: (write_symbols == DWARF2_DEBUG	\
242237412Sjkim	    			  || write_symbols == DWARF_DEBUG)	\
243237412Sjkim				  ? svr4_dbx_register_map[(n)]		\
244237412Sjkim				  : dbx_register_map[(n)])
245237412Sjkim
246237412Sjkim/* The same functions are used to creating the DWARF2 debug info and C++
247237412Sjkim   unwind info (except.c).  Regardless of the debug format requested, the
248237412Sjkim   register numbers used in exception unwinding sections still have to be
249237412Sjkim   DWARF compatible.  IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER
250237412Sjkim   macro to mean too much.  */
251237412Sjkim#define DWARF_FRAME_REGNUM(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
252237412Sjkim				: svr4_dbx_register_map[(n)])
253237412Sjkim
254237412Sjkim/* stabs-in-elf has offsets relative to function beginning */
255237412Sjkim#undef  DBX_OUTPUT_LBRAC
256237412Sjkim#define DBX_OUTPUT_LBRAC(FILE, NAME)					\
257240716Sjkim  do {									\
258240716Sjkim    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);		\
259240716Sjkim    assemble_name (asmfile, buf);					\
260240716Sjkim        fputc ('-', asmfile);						\
261237412Sjkim        assemble_name (asmfile,						\
262237412Sjkim	      	 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
263237412Sjkim    fprintf (asmfile, "\n");						\
264237412Sjkim  } while (0)
265237412Sjkim
266237412Sjkim#undef  DBX_OUTPUT_RBRAC
267237412Sjkim#define DBX_OUTPUT_RBRAC(FILE, NAME)					\
268237412Sjkim  do {									\
269237412Sjkim    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);		\
270237412Sjkim    assemble_name (asmfile, buf);					\
271237412Sjkim        fputc ('-', asmfile);						\
272237412Sjkim        assemble_name (asmfile,						\
273237412Sjkim		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
274237412Sjkim    fprintf (asmfile, "\n");						\
275237412Sjkim  } while (0)
276237412Sjkim