freebsd.h revision 117418
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 117418 2003-07-11 05:03:47Z 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 /usr/libexec/ld-elf.so.1}} \
58      %{static:-Bstatic}} \
59    %{symbolic:-Bsymbolic}"
60
61/* Provide a STARTFILE_SPEC appropriate for FreeBSD.  Here we add the magical
62   crtbegin.o file (see crtstuff.c) which provides part of the support for
63   getting C++ file-scope static object constructed before entering `main'.  */
64
65#undef STARTFILE_SPEC
66#define STARTFILE_SPEC "\
67    %{!shared: \
68      %{pg:gcrt1.o%s} \
69      %{!pg: \
70	%{p:gcrt1.o%s} \
71	%{!p:crt1.o%s}}} \
72    crti.o%s \
73    %{!shared:crtbegin.o%s} \
74    %{shared:crtbeginS.o%s}"
75
76/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386.  Here we tack on our
77   own magical crtend.o file (see crtstuff.c) which provides part of the
78   support for getting C++ file-scope static object constructed before
79   entering `main', followed by the normal "finalizer" file, `crtn.o'.  */
80
81#undef  ENDFILE_SPEC
82#define ENDFILE_SPEC "\
83    %{!shared:crtend.o%s} \
84    %{shared:crtendS.o%s} crtn.o%s"
85
86
87/************************[  Target stuff  ]***********************************/
88
89/* Define the actual types of some ANSI-mandated types.
90   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
91   c-common.c, and config/<arch>/<arch>.h.  */
92
93#undef  SIZE_TYPE
94#define SIZE_TYPE	(TARGET_64BIT ? "long unsigned int" : "unsigned int")
95
96#undef  PTRDIFF_TYPE
97#define PTRDIFF_TYPE	(TARGET_64BIT ? "long int" : "int")
98
99#undef  WCHAR_TYPE_SIZE
100#define WCHAR_TYPE_SIZE	(TARGET_64BIT ? 32 : BITS_PER_WORD)
101
102#define TARGET_VERSION	fprintf (stderr, " (i386 FreeBSD/ELF)");
103
104#define MASK_PROFILER_EPILOGUE	010000000000
105
106#define TARGET_PROFILER_EPILOGUE	(target_flags & MASK_PROFILER_EPILOGUE)
107#define TARGET_ELF			1
108
109#undef	SUBTARGET_SWITCHES
110#define SUBTARGET_SWITCHES						\
111  { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \
112  { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE, "No function profiler epilogue"},
113
114/* This goes away when the math emulator is fixed.  */
115#undef  TARGET_SUBTARGET_DEFAULT
116#define TARGET_SUBTARGET_DEFAULT \
117  (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
118
119/* Don't default to pcc-struct-return, we want to retain compatibility with
120   older gcc versions AND pcc-struct-return is nonreentrant.
121   (even though the SVR4 ABI for the i386 says that records and unions are
122   returned in memory).  */
123
124#undef  DEFAULT_PCC_STRUCT_RETURN
125#define DEFAULT_PCC_STRUCT_RETURN 0
126
127/* FreeBSD sets the rounding precision of the FPU to 53 bits.  Let the
128   compiler get the contents of <float.h> and std::numeric_limits correct.  */
129#define SUBTARGET_OVERRIDE_OPTIONS			\
130  do {							\
131    real_format_for_mode[XFmode - QFmode]		\
132      = &ieee_extended_intel_96_round_53_format;	\
133    real_format_for_mode[TFmode - QFmode]		\
134      = &ieee_extended_intel_96_round_53_format;	\
135  } while (0)
136
137/* Tell final.c that we don't need a label passed to mcount.  */
138#define NO_PROFILE_COUNTERS	1
139
140/* Output assembler code to FILE to begin profiling of the current function.
141   LABELNO is an optional label.  */
142
143#undef MCOUNT_NAME
144#define MCOUNT_NAME ".mcount"
145
146/* Output assembler code to FILE to end profiling of the current function.  */
147
148#undef  FUNCTION_PROFILER_EPILOGUE	/* BDE will need to fix this. */
149
150
151/************************[  Assembler stuff  ]********************************/
152
153/* Override the default comment-starter of "/" from unix.h.  */
154#undef  ASM_COMMENT_START
155#define ASM_COMMENT_START "#"
156
157/* Override the default comment-starter of "/APP" from unix.h.  */
158#undef  ASM_APP_ON
159#define ASM_APP_ON	"#APP\n"
160#undef  ASM_APP_OFF
161#define ASM_APP_OFF	"#NO_APP\n"
162
163/* XXX:DEO do we still need this override to defaults.h ?? */
164/* This is how to output a reference to a user-level label named NAME.  */
165#undef  ASM_OUTPUT_LABELREF
166#define ASM_OUTPUT_LABELREF(FILE, NAME)					\
167  do {									\
168    char *_name = (NAME);						\
169    /* Hack to avoid writing lots of rtl in				\
170       FUNCTION_PROFILER_EPILOGUE ().  */				\
171    if (*_name == '.' && strcmp(_name + 1, "mexitcount") == 0)		\
172      {									\
173	if (flag_pic)							\
174	  fprintf ((FILE), "*%s@GOT(%%ebx)", _name);			\
175	else								\
176	  fprintf ((FILE), "%s", _name);				\
177      }									\
178    else								\
179      fprintf (FILE, "%s", _name);					\
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#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)			\
209  do {									\
210    if ((LOG) != 0) {							\
211      if ((MAX_SKIP) == 0)						\
212	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
213      else								\
214	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
215    }									\
216  } while (0)
217#endif
218
219/* If defined, a C expression whose value is a string containing the
220   assembler operation to identify the following data as
221   uninitialized global data.  If not defined, and neither
222   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
223   uninitialized global data will be output in the data section if
224   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
225   used.  */
226#undef BSS_SECTION_ASM_OP
227#define BSS_SECTION_ASM_OP "\t.section\t.bss"
228
229/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
230   separate, explicit argument.  If you define this macro, it is used
231   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
232   handling the required alignment of the variable.  The alignment is
233   specified as the number of bits.
234
235   Try to use function `asm_output_aligned_bss' defined in file
236   `varasm.c' when defining this macro.  */
237#undef ASM_OUTPUT_ALIGNED_BSS
238#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
239  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
240
241/************************[  Debugger stuff  ]*********************************/
242
243#undef  DBX_REGISTER_NUMBER
244#define DBX_REGISTER_NUMBER(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
245				: (write_symbols == DWARF2_DEBUG	\
246	    			  || write_symbols == DWARF_DEBUG)	\
247				  ? svr4_dbx_register_map[(n)]		\
248				  : dbx_register_map[(n)])
249
250/* The same functions are used to creating the DWARF2 debug info and C++
251   unwind info (except.c).  Regardless of the debug format requested, the
252   register numbers used in exception unwinding sections still have to be
253   DWARF compatible.  IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER
254   macro to mean too much.  */
255#define DWARF_FRAME_REGNUM(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
256				: svr4_dbx_register_map[(n)])
257
258/* stabs-in-elf has offsets relative to function beginning */
259#undef  DBX_OUTPUT_LBRAC
260#define DBX_OUTPUT_LBRAC(FILE, NAME)					\
261  do {									\
262    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);		\
263    assemble_name (asmfile, buf);					\
264        fputc ('-', asmfile);						\
265        assemble_name (asmfile,						\
266	      	 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
267    fprintf (asmfile, "\n");						\
268  } while (0)
269
270#undef  DBX_OUTPUT_RBRAC
271#define DBX_OUTPUT_RBRAC(FILE, NAME)					\
272  do {									\
273    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);		\
274    assemble_name (asmfile, buf);					\
275        fputc ('-', asmfile);						\
276        assemble_name (asmfile,						\
277		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
278    fprintf (asmfile, "\n");						\
279  } while (0)
280