freebsd.h revision 107286
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 107286 2002-11-26 18:25:20Z obrien $ */
26
27#undef  CC1_SPEC
28#define CC1_SPEC "%(cc1_cpu) %{profile:-p} \
29  %{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \
30  "
31
32#undef  ASM_SPEC
33#define ASM_SPEC	"%{v*: -v}"
34
35#undef  ASM_FINAL_SPEC
36#define ASM_FINAL_SPEC	"%|"
37
38/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
39   for the special GCC options -static and -shared, which allow us to
40   link things in one of these three modes by applying the appropriate
41   combinations of options at link-time. We like to support here for
42   as many of the other GNU linker options as possible. But I don't
43   have the time to search for those flags. I am sure how to add
44   support for -soname shared_object_name. H.J.
45
46   When the -shared link option is used a final link is not being
47   done.  */
48
49#undef	LINK_SPEC
50#define LINK_SPEC "\
51 %{p:%e`-p' not supported; use `-pg' and gprof(1)} \
52    %{Wl,*:%*} \
53    %{v:-V} \
54    %{assert*} %{R*} %{rpath*} %{defsym*} \
55    %{shared:-Bshareable %{h*} %{soname*}} \
56    %{!shared: \
57      %{!static: \
58	%{rdynamic: -export-dynamic} \
59	%{!dynamic-linker: -dynamic-linker /usr/libexec/ld-elf.so.1}} \
60      %{static:-Bstatic}} \
61    %{symbolic:-Bsymbolic}"
62
63/* Provide a STARTFILE_SPEC appropriate for FreeBSD.  Here we add the magical
64   crtbegin.o file (see crtstuff.c) which provides part of the support for
65   getting C++ file-scope static object constructed before entering `main'.  */
66
67#undef STARTFILE_SPEC
68#define STARTFILE_SPEC "\
69    %{!shared: \
70      %{pg:gcrt1.o%s} \
71      %{!pg: \
72	%{p:gcrt1.o%s} \
73	%{!p:crt1.o%s}}} \
74    crti.o%s \
75    %{!shared:crtbegin.o%s} \
76    %{shared:crtbeginS.o%s}"
77
78/* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386.  Here we tack on our
79   own magical crtend.o file (see crtstuff.c) which provides part of the
80   support for getting C++ file-scope static object constructed before
81   entering `main', followed by the normal "finalizer" file, `crtn.o'.  */
82
83#undef  ENDFILE_SPEC
84#define ENDFILE_SPEC "\
85    %{!shared:crtend.o%s} \
86    %{shared:crtendS.o%s} crtn.o%s"
87
88
89/************************[  Target stuff  ]***********************************/
90
91/* Define the actual types of some ANSI-mandated types.
92   Needs to agree with <machine/ansi.h>.  GCC defaults come from c-decl.c,
93   c-common.c, and config/<arch>/<arch>.h.  */
94
95#undef  SIZE_TYPE
96#define SIZE_TYPE	(TARGET_64BIT ? "long unsigned int" : "unsigned int")
97
98#undef  PTRDIFF_TYPE
99#define PTRDIFF_TYPE	(TARGET_64BIT ? "long int" : "int")
100
101#undef  WCHAR_TYPE_SIZE
102#define WCHAR_TYPE_SIZE	(TARGET_64BIT ? 32 : BITS_PER_WORD)
103
104#undef  TARGET_VERSION
105#define TARGET_VERSION	fprintf (stderr, " (i386 FreeBSD/ELF)");
106
107#define MASK_PROFILER_EPILOGUE	010000000000
108
109#define TARGET_PROFILER_EPILOGUE	(target_flags & MASK_PROFILER_EPILOGUE)
110#define TARGET_ELF			1
111
112#undef	SUBTARGET_SWITCHES
113#define SUBTARGET_SWITCHES						\
114  { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \
115  { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE, "No function profiler epilogue"},
116
117/* This goes away when the math emulator is fixed.  */
118#undef  TARGET_SUBTARGET_DEFAULT
119#define TARGET_SUBTARGET_DEFAULT \
120  (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
121
122/* Don't default to pcc-struct-return, we want to retain compatibility with
123   older gcc versions AND pcc-struct-return is nonreentrant.
124   (even though the SVR4 ABI for the i386 says that records and unions are
125   returned in memory).  */
126
127#undef  DEFAULT_PCC_STRUCT_RETURN
128#define DEFAULT_PCC_STRUCT_RETURN 0
129
130/* Tell final.c that we don't need a label passed to mcount.  */
131#define NO_PROFILE_COUNTERS	1
132
133/* Output assembler code to FILE to begin profiling of the current function.
134   LABELNO is an optional label.  */
135
136#undef  FUNCTION_PROFILER
137#define FUNCTION_PROFILER(FILE, LABELNO)  \
138  do {									\
139    if (flag_pic)							\
140      fprintf ((FILE), "\tcall *.mcount%s@GOT(%%ebx)\n");		\
141    else								\
142      fprintf ((FILE), "\tcall .mcount\n");				\
143  } while (0)
144
145/* Output assembler code to FILE to end profiling of the current function.  */
146
147#undef  FUNCTION_PROFILER_EPILOGUE	/* BDE will need to fix this. */
148
149
150/************************[  Assembler stuff  ]********************************/
151
152/* Override the default comment-starter of "/" from unix.h.  */
153#undef  ASM_COMMENT_START
154#define ASM_COMMENT_START "#"
155
156/* Override the default comment-starter of "/APP" from unix.h.  */
157#undef  ASM_APP_ON
158#define ASM_APP_ON	"#APP\n"
159#undef  ASM_APP_OFF
160#define ASM_APP_OFF	"#NO_APP\n"
161
162/* XXX:DEO do we still need this override to defaults.h ?? */
163/* This is how to output a reference to a user-level label named NAME.  */
164#undef  ASM_OUTPUT_LABELREF
165#define ASM_OUTPUT_LABELREF(FILE, NAME)					\
166  do {									\
167    char *_name = (NAME);						\
168    /* Hack to avoid writing lots of rtl in				\
169       FUNCTION_PROFILER_EPILOGUE ().  */				\
170    if (*_name == '.' && strcmp(_name + 1, "mexitcount") == 0)		\
171      {									\
172	if (flag_pic)							\
173	  fprintf ((FILE), "*%s@GOT(%%ebx)", _name);			\
174	else								\
175	  fprintf ((FILE), "%s", _name);				\
176      }									\
177    else								\
178      fprintf (FILE, "%s", _name);					\
179} while (0)
180
181/* This is how to hack on the symbol code of certain relcalcitrant
182   symbols to modify their output in output_pic_addr_const ().  */
183
184#undef  ASM_HACK_SYMBOLREF_CODE	/* BDE will need to fix this. */
185
186#undef  ASM_OUTPUT_ALIGN
187#define ASM_OUTPUT_ALIGN(FILE, LOG)      				\
188  do {					     				\
189    if ((LOG)!=0) {							\
190      if (in_text_section())						\
191	fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG));		\
192      else								\
193	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
194    }									\
195  } while (0)
196
197/* A C statement to output to the stdio stream FILE an assembler
198   command to advance the location counter to a multiple of 1<<LOG
199   bytes if it is within MAX_SKIP bytes.
200
201   This is used to align code labels according to Intel recommendations.  */
202
203/* XXX configuration of this is broken in the same way as HAVE_GAS_SHF_MERGE,
204   but it is easier to fix in an MD way.  */
205
206#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
207#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)			\
208  do {									\
209    if ((LOG) != 0) {							\
210      if ((MAX_SKIP) == 0)						\
211	fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
212      else								\
213	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
214    }									\
215  } while (0)
216#endif
217
218
219/************************[  Debugger stuff  ]*********************************/
220
221#undef  DBX_REGISTER_NUMBER
222#define DBX_REGISTER_NUMBER(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
223				: (write_symbols == DWARF2_DEBUG	\
224	    			  || write_symbols == DWARF_DEBUG)	\
225				  ? svr4_dbx_register_map[(n)]		\
226				  : dbx_register_map[(n)])
227
228/* The same functions are used to creating the DWARF2 debug info and C++
229   unwind info (except.c).  Regardless of the debug format requested, the
230   register numbers used in exception unwinding sections still have to be
231   DWARF compatible.  IMO the GCC folks may be abusing the DBX_REGISTER_NUMBER
232   macro to mean too much.  */
233#define DWARF_FRAME_REGNUM(n)	(TARGET_64BIT ? dbx64_register_map[n]	\
234				: svr4_dbx_register_map[(n)])
235
236/* stabs-in-elf has offsets relative to function beginning */
237#undef  DBX_OUTPUT_LBRAC
238#define DBX_OUTPUT_LBRAC(FILE, NAME)					\
239  do {									\
240    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);		\
241    assemble_name (asmfile, buf);					\
242        fputc ('-', asmfile);						\
243        assemble_name (asmfile,						\
244	      	 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
245    fprintf (asmfile, "\n");						\
246  } while (0)
247
248#undef  DBX_OUTPUT_RBRAC
249#define DBX_OUTPUT_RBRAC(FILE, NAME)					\
250  do {									\
251    fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);		\
252    assemble_name (asmfile, buf);					\
253        fputc ('-', asmfile);						\
254        assemble_name (asmfile,						\
255		 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));	\
256    fprintf (asmfile, "\n");						\
257  } while (0)
258