freebsd.h revision 18604
1/* Definitions of target machine for GNU compiler for Intel 80386
2   running FreeBSD.
3   Copyright (C) 1988, 1992, 1994 Free Software Foundation, Inc.
4   Contributed by Poul-Henning Kamp <phk@login.dkuug.dk>
5
6This file is part of GNU CC.
7
8GNU CC is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2, or (at your option)
11any later version.
12
13GNU CC is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with GNU CC; see the file COPYING.  If not, write to
20the Free Software Foundation, 59 Temple Place - Suite 330,
21Boston, MA 02111-1307, USA.  */
22
23/* This is tested by i386gas.h.  */
24#define YES_UNDERSCORES
25
26/* Don't assume anything about the header files. */
27#define NO_IMPLICIT_EXTERN_C
28
29#include "i386/gstabs.h"
30
31/* Get perform_* macros to build libgcc.a.  */
32#include "i386/perform.h"
33
34/* This was cloned from ../netbsd.h.  It and several other things in
35   this file should be in ../freebsd.h.  */
36/* FREEBSD_NATIVE is defined when gcc is integrated into the FreeBSD
37   source tree so it can be configured appropriately without using
38   the GNU configure/build mechanism. */
39
40#ifdef FREEBSD_NATIVE
41
42/* Look for the include files in the system-defined places.  */
43
44#define GPLUSPLUS_INCLUDE_DIR		"/usr/include/g++"
45
46#define GCC_INCLUDE_DIR			"/usr/include"
47
48/* FreeBSD has GCC_INCLUDE_DIR first.  */
49#define INCLUDE_DEFAULTS		\
50  {					\
51    { GCC_INCLUDE_DIR, 0, 0 },		\
52    { GPLUSPLUS_INCLUDE_DIR, 1, 1 },	\
53    { 0, 0, 0 }				\
54  }
55
56/* Under FreeBSD, the normal location of the compiler back ends is the
57   /usr/libexec directory.  */
58
59#define STANDARD_EXEC_PREFIX		"/usr/libexec/"
60
61/* Under FreeBSD, the normal location of the various *crt*.o files is the
62   /usr/lib directory.  */
63
64#define STANDARD_STARTFILE_PREFIX	"/usr/lib/"
65
66/* On FreeBSD, gcc is called 'cc' */
67#define GCC_NAME			"cc"
68
69/* FreeBSD is 4.4BSD derived */
70#define bsd4_4
71
72#endif /* FREEBSD_NATIVE */
73
74#define MASK_PROFILER_EPILOGUE	010000000000
75
76#define TARGET_PROFILER_EPILOGUE (target_flags & MASK_PROFILER_EPILOGUE)
77
78#undef	SUBTARGET_SWITCHES
79#define SUBTARGET_SWITCHES						\
80     { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE},		\
81     { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE},
82
83
84#undef CPP_PREDEFINES
85#define CPP_PREDEFINES "-Dunix -Di386 -D__FreeBSD__=2 -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)"
86
87#define ASM_SPEC   " %| %{fpic:-k} %{fPIC:-k}"
88
89/* Like the default, except no -lg.  */
90#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
91
92#define LINK_SPEC \
93  "%{!nostdlib:%{!r:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} %{assert*} \
94   %{p:-Bstatic} %{pg:-Bstatic} %{Z} %{R*}"
95
96#define LINK_LIBGCC_SPECIAL_1	1
97
98#define STARTFILE_SPEC  \
99  "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:%{static:scrt0.o%s}%{!static:crt0.o%s}}}"
100
101/* This goes away when the math emulator is fixed.  */
102#undef TARGET_DEFAULT
103#define TARGET_DEFAULT	(MASK_NO_FANCY_MATH_387 | 0301)
104
105#undef SIZE_TYPE
106#define SIZE_TYPE "unsigned int"
107
108#undef PTRDIFF_TYPE
109#define PTRDIFF_TYPE "int"
110
111#undef WCHAR_TYPE
112#define WCHAR_TYPE "int"
113
114#define WCHAR_UNSIGNED 0
115
116#undef WCHAR_TYPE_SIZE
117#define WCHAR_TYPE_SIZE BITS_PER_WORD
118
119#define HAVE_ATEXIT
120
121#define HAVE_PUTENV
122
123/* Override the default comment-starter of "/".  */
124
125#undef ASM_COMMENT_START
126#define ASM_COMMENT_START "#"
127
128#undef ASM_APP_ON
129#define ASM_APP_ON "#APP\n"
130
131#undef ASM_APP_OFF
132#define ASM_APP_OFF "#NO_APP\n"
133
134/* The following macros are stolen from i386v4.h */
135/* These have to be defined to get PIC code correct */
136
137/* This is how to output an element of a case-vector that is relative.
138   This is only used for PIC code.  See comments by the `casesi' insn in
139   i386.md for an explanation of the expression this outputs. */
140
141#undef ASM_OUTPUT_ADDR_DIFF_ELT
142#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
143  fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
144
145/* Indicate that jump tables go in the text section.  This is
146   necessary when compiling PIC code.  */
147
148#define JUMP_TABLES_IN_TEXT_SECTION
149
150/* Don't default to pcc-struct-return, because gcc is the only compiler, and
151   we want to retain compatibility with older gcc versions.  */
152#define DEFAULT_PCC_STRUCT_RETURN 0
153
154/* Tell final.c that we don't need a label passed to mcount.  */
155
156#define NO_PROFILE_DATA
157
158/* Redefine this to not pass an unused label in %edx.  */
159
160#undef FUNCTION_PROFILER
161#define FUNCTION_PROFILER(FILE, LABELNO)  \
162{									\
163  if (flag_pic)								\
164    fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");			\
165  else									\
166    fprintf (FILE, "\tcall mcount\n");					\
167}
168
169#define FUNCTION_PROFILER_EPILOGUE(FILE)  \
170{									\
171  if (TARGET_PROFILER_EPILOGUE)						\
172    {									\
173      if (flag_pic)							\
174	fprintf (FILE, "\tcall *mexitcount@GOT(%%ebx)\n");		\
175      else								\
176	fprintf (FILE, "\tcall mexitcount\n");				\
177    }									\
178}
179
180/*
181 * Some imports from svr4.h in support of shared libraries.
182 * Currently, we need the DECLARE_OBJECT_SIZE stuff.
183 */
184
185#define HANDLE_SYSV_PRAGMA
186
187/* Define the strings used for the special svr4 .type and .size directives.
188   These strings generally do not vary from one system running svr4 to
189   another, but if a given system (e.g. m88k running svr) needs to use
190   different pseudo-op names for these, they may be overridden in the
191   file which includes this one.  */
192
193#define TYPE_ASM_OP	".type"
194#define SIZE_ASM_OP	".size"
195#define SET_ASM_OP	".set"
196
197/* This is how we tell the assembler that a symbol is weak.  */
198#define ASM_WEAKEN_LABEL(FILE,NAME) \
199  do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
200       fputc ('\n', FILE); } while (0)
201
202/* The following macro defines the format used to output the second
203   operand of the .type assembler directive.  Different svr4 assemblers
204   expect various different forms for this operand.  The one given here
205   is just a default.  You may need to override it in your machine-
206   specific tm.h file (depending upon the particulars of your assembler).  */
207
208#define TYPE_OPERAND_FMT	"@%s"
209
210/* Write the extra assembler code needed to declare a function's result.
211   Most svr4 assemblers don't require any special declaration of the
212   result value, but there are exceptions.  */
213
214#ifndef ASM_DECLARE_RESULT
215#define ASM_DECLARE_RESULT(FILE, RESULT)
216#endif
217
218/* These macros generate the special .type and .size directives which
219   are used to set the corresponding fields of the linker symbol table
220   entries in an ELF object file under SVR4.  These macros also output
221   the starting labels for the relevant functions/objects.  */
222
223/* Write the extra assembler code needed to declare a function properly.
224   Some svr4 assemblers need to also have something extra said about the
225   function's return value.  We allow for that here.  */
226
227#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
228  do {									\
229    fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);				\
230    assemble_name (FILE, NAME);						\
231    putc (',', FILE);							\
232    fprintf (FILE, TYPE_OPERAND_FMT, "function");			\
233    putc ('\n', FILE);							\
234    ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));			\
235    ASM_OUTPUT_LABEL(FILE, NAME);					\
236  } while (0)
237
238/* Write the extra assembler code needed to declare an object properly.  */
239
240#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)			\
241  do {									\
242    fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);				\
243    assemble_name (FILE, NAME);						\
244    putc (',', FILE);							\
245    fprintf (FILE, TYPE_OPERAND_FMT, "object");				\
246    putc ('\n', FILE);							\
247    size_directive_output = 0;						\
248    if (!flag_inhibit_size_directive && DECL_SIZE (DECL))		\
249      {									\
250        size_directive_output = 1;					\
251	fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);				\
252	assemble_name (FILE, NAME);					\
253	fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL)));	\
254      }									\
255    ASM_OUTPUT_LABEL(FILE, NAME);					\
256  } while (0)
257
258/* Output the size directive for a decl in rest_of_decl_compilation
259   in the case where we did not do so before the initializer.
260   Once we find the error_mark_node, we know that the value of
261   size_directive_output was set
262   by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
263
264#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)        \
265do {                                                                    \
266     char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);                  \
267     if (!flag_inhibit_size_directive && DECL_SIZE (DECL)	        \
268         && ! AT_END && TOP_LEVEL                                       \
269         && DECL_INITIAL (DECL) == error_mark_node                      \
270         && !size_directive_output)                                     \
271       {                                                                \
272         fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                        \
273	 assemble_name (FILE, name);                                    \
274	 fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL)));\
275	}								\
276   } while (0)
277
278
279/* This is how to declare the size of a function.  */
280
281#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)			\
282  do {									\
283    if (!flag_inhibit_size_directive)					\
284      {									\
285        char label[256];						\
286	static int labelno;						\
287	labelno++;							\
288	ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);		\
289	ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);		\
290	fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);				\
291	assemble_name (FILE, (FNAME));					\
292        fprintf (FILE, ",");						\
293	assemble_name (FILE, label);					\
294        fprintf (FILE, "-");						\
295	assemble_name (FILE, (FNAME));					\
296	putc ('\n', FILE);						\
297      }									\
298  } while (0)
299