freebsd.h revision 132741
1/* Definitions for Intel 386 running FreeBSD with ELF format
2   Copyright (C) 1996, 2000, 2002 Free Software Foundation, Inc.
3   Contributed by Eric Youngdale.
4   Modified for stabs-in-ELF by H.J. Lu.
5   Adapted from GNU/Linux version by John Polstra.
6   Continued development by David O'Brien <obrien@freebsd.org>
7
8This file is part of GCC.
9
10GCC is free software; you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by
12the Free Software Foundation; either version 2, or (at your option)
13any later version.
14
15GCC is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with GCC; see the file COPYING.  If not, write to
22the Free Software Foundation, 59 Temple Place - Suite 330,
23Boston, MA 02111-1307, USA.  */
24
25/* $FreeBSD: head/contrib/gcc/config/i386/freebsd.h 132741 2004-07-28 04:41:42Z kan $ */
26
27#undef  CC1_SPEC
28#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
29
30#undef  ASM_SPEC
31#define ASM_SPEC	"%{v*: -v}"
32
33#undef  ASM_FINAL_SPEC
34#define ASM_FINAL_SPEC	"%|"
35
36/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
37   for the special GCC options -static and -shared, which allow us to
38   link things in one of these three modes by applying the appropriate
39   combinations of options at link-time. We like to support here for
40   as many of the other GNU linker options as possible. But I don't
41   have the time to search for those flags. I am sure how to add
42   support for -soname shared_object_name. H.J.
43
44   When the -shared link option is used a final link is not being
45   done.  */
46
47#undef	LINK_SPEC
48#define LINK_SPEC "\
49 %{p:%nconsider using `-pg' instead of `-p' with gprof(1) } \
50    %{Wl,*:%*} \
51    %{v:-V} \
52    %{assert*} %{R*} %{rpath*} %{defsym*} \
53    %{shared:-Bshareable %{h*} %{soname*}} \
54    %{!shared: \
55      %{!static: \
56	%{rdynamic: -export-dynamic} \
57	%{!dynamic-linker:-dynamic-linker %(fbsd_dynamic_linker) }} \
58      %{static:-Bstatic}} \
59    %{symbolic:-Bsymbolic}"
60
61/* Reset our STARTFILE_SPEC which was properly set in config/freebsd.h
62   but trashed by config/<cpu>/<file.h>. */
63
64#undef STARTFILE_SPEC
65#define STARTFILE_SPEC FBSD_STARTFILE_SPEC
66
67/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386.  */
68
69#undef  ENDFILE_SPEC
70#define ENDFILE_SPEC FBSD_ENDFILE_SPEC
71
72
73/************************[  Target stuff  ]***********************************/
74
75/* Define the actual types of some ANSI-mandated types.
76   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
77   c-common.c, and config/<arch>/<arch>.h.  */
78
79#undef  SIZE_TYPE
80#define SIZE_TYPE	(TARGET_64BIT ? "long unsigned int" : "unsigned int")
81
82#undef  PTRDIFF_TYPE
83#define PTRDIFF_TYPE	(TARGET_64BIT ? "long int" : "int")
84
85#undef  WCHAR_TYPE_SIZE
86#define WCHAR_TYPE_SIZE	(TARGET_64BIT ? 32 : BITS_PER_WORD)
87
88#undef  SUBTARGET_EXTRA_SPECS  /* i386.h bogusly defines it.  */
89#define SUBTARGET_EXTRA_SPECS \
90  { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }
91
92#define TARGET_VERSION	fprintf (stderr, " (i386 FreeBSD/ELF)");
93
94#define MASK_PROFILER_EPILOGUE	010000000000
95
96#define TARGET_PROFILER_EPILOGUE	(target_flags & MASK_PROFILER_EPILOGUE)
97#define TARGET_ELF			1
98
99#undef	SUBTARGET_SWITCHES
100#define SUBTARGET_SWITCHES						\
101  { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \
102  { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE, "No function profiler epilogue"},
103
104/* This goes away when the math emulator is fixed.  */
105#undef  TARGET_SUBTARGET_DEFAULT
106#define TARGET_SUBTARGET_DEFAULT \
107  (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
108
109/* Don't default to pcc-struct-return, we want to retain compatibility with
110   older gcc versions AND pcc-struct-return is nonreentrant.
111   (even though the SVR4 ABI for the i386 says that records and unions are
112   returned in memory).  */
113
114#undef  DEFAULT_PCC_STRUCT_RETURN
115#define DEFAULT_PCC_STRUCT_RETURN 0
116
117/* FreeBSD sets the rounding precision of the FPU to 53 bits.  Let the
118   compiler get the contents of <float.h> and std::numeric_limits correct.  */
119#define SUBTARGET_OVERRIDE_OPTIONS			\
120  do {							\
121    if (!TARGET_64BIT) {				\
122      REAL_MODE_FORMAT (XFmode)				\
123	= &ieee_extended_intel_96_round_53_format;	\
124      REAL_MODE_FORMAT (TFmode)				\
125	= &ieee_extended_intel_96_round_53_format;	\
126    }							\
127  } while (0)
128
129/* Tell final.c that we don't need a label passed to mcount.  */
130#define NO_PROFILE_COUNTERS	1
131
132/* Output assembler code to FILE to begin profiling of the current function.
133   LABELNO is an optional label.  */
134
135#undef MCOUNT_NAME
136#define MCOUNT_NAME ".mcount"
137
138/* Output assembler code to FILE to end profiling of the current function.  */
139
140#undef  FUNCTION_PROFILER_EPILOGUE	/* BDE will need to fix this. */
141
142
143/************************[  Assembler stuff  ]********************************/
144
145/* Override the default comment-starter of "/" from unix.h.  */
146#undef  ASM_COMMENT_START
147#define ASM_COMMENT_START "#"
148
149/* Override the default comment-starter of "/APP" from unix.h.  */
150#undef  ASM_APP_ON
151#define ASM_APP_ON	"#APP\n"
152#undef  ASM_APP_OFF
153#define ASM_APP_OFF	"#NO_APP\n"
154
155/* XXX:DEO do we still need this override to defaults.h ?? */
156/* This is how to output a reference to a user-level label named NAME.  */
157#undef  ASM_OUTPUT_LABELREF
158#define ASM_OUTPUT_LABELREF(FILE, NAME)					\
159  do {									\
160    const char *xname = (NAME);						\
161    /* Hack to avoid writing lots of rtl in				\
162       FUNCTION_PROFILER_EPILOGUE ().  */				\
163    if (*xname == '.' && strcmp(xname + 1, "mexitcount") == 0)		\
164      {									\
165	if (flag_pic)							\
166	  fprintf ((FILE), "*%s@GOT(%%ebx)", xname);			\
167	else								\
168	  fprintf ((FILE), "%s", xname);				\
169      }									\
170    else 								\
171      {									\
172	  if (xname[0] == '%')						\
173	    xname += 2;							\
174	  if (xname[0] == '*')						\
175	    xname += 1;							\
176	  else								\
177	    fputs (user_label_prefix, FILE);				\
178	  fputs (xname, FILE);						\
179      }									\
180} while (0)
181
182/* This is how to hack on the symbol code of certain relcalcitrant
183   symbols to modify their output in output_pic_addr_const ().  */
184
185#undef  ASM_HACK_SYMBOLREF_CODE	/* BDE will need to fix this. */
186
187#undef  ASM_OUTPUT_ALIGN
188#define ASM_OUTPUT_ALIGN(FILE, LOG)      				\
189  do {					     				\
190    if ((LOG)!=0) {							\
191      if (in_text_section())						\
192	fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG));		\
193      else								\
194	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
195    }									\
196  } while (0)
197
198/* A C statement to output to the stdio stream FILE an assembler
199   command to advance the location counter to a multiple of 1<<LOG
200   bytes if it is within MAX_SKIP bytes.
201
202   This is used to align code labels according to Intel recommendations.  */
203
204/* XXX configuration of this is broken in the same way as HAVE_GAS_SHF_MERGE,
205   but it is easier to fix in an MD way.  */
206
207#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
208#undef  ASM_OUTPUT_MAX_SKIP_ALIGN
209#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)			\
210  do {									\
211    if ((LOG) != 0) {							\
212      if ((MAX_SKIP) == 0)						\
213	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
214      else								\
215	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
216    }									\
217  } while (0)
218#endif
219
220/* If defined, a C expression whose value is a string containing the
221   assembler operation to identify the following data as
222   uninitialized global data.  If not defined, and neither
223   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
224   uninitialized global data will be output in the data section if
225   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
226   used.  */
227#undef BSS_SECTION_ASM_OP
228#define BSS_SECTION_ASM_OP "\t.section\t.bss"
229
230/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
231   separate, explicit argument.  If you define this macro, it is used
232   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
233   handling the required alignment of the variable.  The alignment is
234   specified as the number of bits.
235
236   Try to use function `asm_output_aligned_bss' defined in file
237   `varasm.c' when defining this macro.  */
238#undef ASM_OUTPUT_ALIGNED_BSS
239#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
240  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
241
242/************************[  Debugger stuff  ]*********************************/
243
244#undef  DBX_REGISTER_NUMBER
245#define DBX_REGISTER_NUMBER(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
246				: (write_symbols == DWARF2_DEBUG	\
247	    			  || write_symbols == DWARF_DEBUG)	\
248				  ? svr4_dbx_register_map[(n)]		\
249				  : dbx_register_map[(n)])
250
251/* The same functions are used to creating the DWARF2 debug info and C++
252   unwind info (except.c).  Regardless of the debug format requested, the
253   register numbers used in exception unwinding sections still have to be
254   DWARF compatible.  IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER
255   macro to mean too much.  */
256#define DWARF_FRAME_REGNUM(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
257				: svr4_dbx_register_map[(n)])
258
259/* stabs-in-elf has offsets relative to function beginning */
260#undef  DBX_OUTPUT_LBRAC
261#define DBX_OUTPUT_LBRAC(FILE, NAME)					\
262  do {									\
263    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);		\
264    assemble_name (asmfile, buf);					\
265        fputc ('-', asmfile);						\
266        assemble_name (asmfile,						\
267	      	 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
268    fprintf (asmfile, "\n");						\
269  } while (0)
270
271#undef  DBX_OUTPUT_RBRAC
272#define DBX_OUTPUT_RBRAC(FILE, NAME)					\
273  do {									\
274    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);		\
275    assemble_name (asmfile, buf);					\
276        fputc ('-', asmfile);						\
277        assemble_name (asmfile,						\
278		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
279    fprintf (asmfile, "\n");						\
280  } while (0)
281