freebsd.h revision 123715
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 GNU CC.
9
10GNU CC 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
15GNU CC 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 GNU CC; 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 123715 2003-12-22 04:27:17Z 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 /libexec/ld-elf.so.1}} \
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#define TARGET_VERSION	fprintf (stderr, " (i386 FreeBSD/ELF)");
89
90#define MASK_PROFILER_EPILOGUE	010000000000
91
92#define TARGET_PROFILER_EPILOGUE	(target_flags & MASK_PROFILER_EPILOGUE)
93#define TARGET_ELF			1
94
95#undef	SUBTARGET_SWITCHES
96#define SUBTARGET_SWITCHES						\
97  { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \
98  { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE, "No function profiler epilogue"},
99
100/* This goes away when the math emulator is fixed.  */
101#undef  TARGET_SUBTARGET_DEFAULT
102#define TARGET_SUBTARGET_DEFAULT \
103  (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
104
105/* Don't default to pcc-struct-return, we want to retain compatibility with
106   older gcc versions AND pcc-struct-return is nonreentrant.
107   (even though the SVR4 ABI for the i386 says that records and unions are
108   returned in memory).  */
109
110#undef  DEFAULT_PCC_STRUCT_RETURN
111#define DEFAULT_PCC_STRUCT_RETURN 0
112
113/* FreeBSD sets the rounding precision of the FPU to 53 bits.  Let the
114   compiler get the contents of <float.h> and std::numeric_limits correct.  */
115#define SUBTARGET_OVERRIDE_OPTIONS			\
116  do {							\
117    if (!TARGET_64BIT) {				\
118      real_format_for_mode[XFmode - QFmode]		\
119	= &ieee_extended_intel_96_round_53_format;	\
120      real_format_for_mode[TFmode - QFmode]		\
121	= &ieee_extended_intel_96_round_53_format;	\
122    }							\
123  } while (0)
124
125/* Tell final.c that we don't need a label passed to mcount.  */
126#define NO_PROFILE_COUNTERS	1
127
128/* Output assembler code to FILE to begin profiling of the current function.
129   LABELNO is an optional label.  */
130
131#undef MCOUNT_NAME
132#define MCOUNT_NAME ".mcount"
133
134/* Output assembler code to FILE to end profiling of the current function.  */
135
136#undef  FUNCTION_PROFILER_EPILOGUE	/* BDE will need to fix this. */
137
138
139/************************[  Assembler stuff  ]********************************/
140
141/* Override the default comment-starter of "/" from unix.h.  */
142#undef  ASM_COMMENT_START
143#define ASM_COMMENT_START "#"
144
145/* Override the default comment-starter of "/APP" from unix.h.  */
146#undef  ASM_APP_ON
147#define ASM_APP_ON	"#APP\n"
148#undef  ASM_APP_OFF
149#define ASM_APP_OFF	"#NO_APP\n"
150
151/* XXX:DEO do we still need this override to defaults.h ?? */
152/* This is how to output a reference to a user-level label named NAME.  */
153#undef  ASM_OUTPUT_LABELREF
154#define ASM_OUTPUT_LABELREF(FILE, NAME)					\
155  do {									\
156    const char *xname = (NAME);						\
157    /* Hack to avoid writing lots of rtl in				\
158       FUNCTION_PROFILER_EPILOGUE ().  */				\
159    if (*xname == '.' && strcmp(xname + 1, "mexitcount") == 0)		\
160      {									\
161	if (flag_pic)							\
162	  fprintf ((FILE), "*%s@GOT(%%ebx)", xname);			\
163	else								\
164	  fprintf ((FILE), "%s", xname);				\
165      }									\
166    else 								\
167      {									\
168	  if (xname[0] == '%')						\
169	    xname += 2;							\
170	  if (xname[0] == '*')						\
171	    xname += 1;							\
172	  else								\
173	    fputs (user_label_prefix, FILE);				\
174	  fputs (xname, FILE);						\
175      }									\
176} while (0)
177
178/* This is how to hack on the symbol code of certain relcalcitrant
179   symbols to modify their output in output_pic_addr_const ().  */
180
181#undef  ASM_HACK_SYMBOLREF_CODE	/* BDE will need to fix this. */
182
183#undef  ASM_OUTPUT_ALIGN
184#define ASM_OUTPUT_ALIGN(FILE, LOG)      				\
185  do {					     				\
186    if ((LOG)!=0) {							\
187      if (in_text_section())						\
188	fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG));		\
189      else								\
190	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
191    }									\
192  } while (0)
193
194/* A C statement to output to the stdio stream FILE an assembler
195   command to advance the location counter to a multiple of 1<<LOG
196   bytes if it is within MAX_SKIP bytes.
197
198   This is used to align code labels according to Intel recommendations.  */
199
200/* XXX configuration of this is broken in the same way as HAVE_GAS_SHF_MERGE,
201   but it is easier to fix in an MD way.  */
202
203#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
204#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)			\
205  do {									\
206    if ((LOG) != 0) {							\
207      if ((MAX_SKIP) == 0)						\
208	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
209      else								\
210	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
211    }									\
212  } while (0)
213#endif
214
215/* If defined, a C expression whose value is a string containing the
216   assembler operation to identify the following data as
217   uninitialized global data.  If not defined, and neither
218   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
219   uninitialized global data will be output in the data section if
220   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
221   used.  */
222#undef BSS_SECTION_ASM_OP
223#define BSS_SECTION_ASM_OP "\t.section\t.bss"
224
225/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
226   separate, explicit argument.  If you define this macro, it is used
227   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
228   handling the required alignment of the variable.  The alignment is
229   specified as the number of bits.
230
231   Try to use function `asm_output_aligned_bss' defined in file
232   `varasm.c' when defining this macro.  */
233#undef ASM_OUTPUT_ALIGNED_BSS
234#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
235  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
236
237/************************[  Debugger stuff  ]*********************************/
238
239#undef  DBX_REGISTER_NUMBER
240#define DBX_REGISTER_NUMBER(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
241				: (write_symbols == DWARF2_DEBUG	\
242	    			  || write_symbols == DWARF_DEBUG)	\
243				  ? svr4_dbx_register_map[(n)]		\
244				  : dbx_register_map[(n)])
245
246/* The same functions are used to creating the DWARF2 debug info and C++
247   unwind info (except.c).  Regardless of the debug format requested, the
248   register numbers used in exception unwinding sections still have to be
249   DWARF compatible.  IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER
250   macro to mean too much.  */
251#define DWARF_FRAME_REGNUM(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
252				: svr4_dbx_register_map[(n)])
253
254/* stabs-in-elf has offsets relative to function beginning */
255#undef  DBX_OUTPUT_LBRAC
256#define DBX_OUTPUT_LBRAC(FILE, NAME)					\
257  do {									\
258    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);		\
259    assemble_name (asmfile, buf);					\
260        fputc ('-', asmfile);						\
261        assemble_name (asmfile,						\
262	      	 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
263    fprintf (asmfile, "\n");						\
264  } while (0)
265
266#undef  DBX_OUTPUT_RBRAC
267#define DBX_OUTPUT_RBRAC(FILE, NAME)					\
268  do {									\
269    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);		\
270    assemble_name (asmfile, buf);					\
271        fputc ('-', asmfile);						\
272        assemble_name (asmfile,						\
273		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
274    fprintf (asmfile, "\n");						\
275  } while (0)
276