freebsd.h revision 76601
1/* Base configuration file for all FreeBSD targets.
2   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING.  If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA.  */
20
21/* Common FreeBSD configuration.
22   All FreeBSD architectures should include this file, which will specify
23   their commonalities.
24   Adapted from /usr/src/contrib/gcc/config/i386/freebsd.h,
25   /usr/src/contrib/gcc/config/svr4.h &
26   egcs/gcc/config/i386/freebsd-elf.h by
27   David O'Brien <obrien@FreeBSD.org>.  */
28
29/* $FreeBSD: head/contrib/gcc/config/freebsd.h 76601 2001-05-14 22:45:26Z obrien $ */
30
31
32/* Cpp, assembler, linker, library, and startfile spec's.  */
33
34/* This defines which switch letters take arguments.  On FreeBSD, most of
35   the normal cases (defined in gcc.c) apply, and we also have -h* and
36   -z* options (for the linker) (coming from SVR4).
37   We also have -R (alias --rpath), no -z, --soname (-h), --assert etc.  */
38
39#define FBSD_SWITCH_TAKES_ARG(CHAR)					\
40  (DEFAULT_SWITCH_TAKES_ARG (CHAR)					\
41    || (CHAR) == 'h'							\
42    || (CHAR) == 'z' /* ignored by ld */				\
43    || (CHAR) == 'R')
44
45#undef  SWITCH_TAKES_ARG
46#define SWITCH_TAKES_ARG(CHAR) (FBSD_SWITCH_TAKES_ARG(CHAR))
47
48/* This defines which multi-letter switches take arguments.  */
49
50#define FBSD_WORD_SWITCH_TAKES_ARG(STR)					\
51  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)					\
52   || !strcmp ((STR), "rpath") || !strcmp ((STR), "rpath-link")		\
53   || !strcmp ((STR), "soname") || !strcmp ((STR), "defsym") 		\
54   || !strcmp ((STR), "assert") || !strcmp ((STR), "dynamic-linker"))
55
56#undef  WORD_SWITCH_TAKES_ARG
57#define WORD_SWITCH_TAKES_ARG(STR) (FBSD_WORD_SWITCH_TAKES_ARG(STR))
58
59/* Place spaces around this string.  We depend on string splicing to produce
60   the final CPP_PREDEFINES value.  */
61
62#define FBSD_CPP_PREDEFINES \
63  " -D__FreeBSD__=5 -D__FreeBSD_cc_version=500002 -Dunix -Asystem(unix) -Asystem(FreeBSD) "
64
65#define FBSD_CPP_SPEC "							\
66  %(cpp_cpu)								\
67  %{!maout: -D__ELF__}							\
68  %{munderscores: -D__UNDERSCORES__}					\
69  %{maout: %{!mno-underscores: -D__UNDERSCORES__}}			\
70  %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__}		\
71  %{posix:-D_POSIX_SOURCE}"
72
73#undef  CPP_SPEC
74#define CPP_SPEC FBSD_CPP_SPEC
75
76/* Provide a LIB_SPEC appropriate for FreeBSD.  Before
77   __FreeBSD_version 500016, select the appropriate libc, depending on
78   whether we're doing profiling or need threads support.  (similar to
79   the default, except no -lg, and no -p).  At __FreeBSD_version
80   500016 and later, when threads support is requested include both
81   -lc and -lc_r instead of only -lc_r.  */
82
83#undef  LIB_SPEC
84#include <sys/param.h>
85#if __FreeBSD_version >= 500016
86#define LIB_SPEC "							\
87  %{!shared:								\
88    %{!pg: %{pthread:-lc_r} -lc}					\
89    %{pg:  %{pthread:-lc_r_p} -lc_p}					\
90  }"
91#else
92#define LIB_SPEC "							\
93  %{!shared:								\
94    %{!pg:								\
95      %{!pthread:-lc}							\
96      %{pthread:-lc_r}}							\
97    %{pg:								\
98      %{!pthread:-lc_p}							\
99      %{pthread:-lc_r_p}}						\
100  }"
101#endif
102
103
104/************************[  Target stuff  ]***********************************/
105
106/* All FreeBSD Architectures support the ELF object file format.  */
107#undef  OBJECT_FORMAT_ELF
108#define OBJECT_FORMAT_ELF
109
110/* Don't assume anything about the header files.  */
111#undef  NO_IMPLICIT_EXTERN_C
112#define NO_IMPLICIT_EXTERN_C
113
114/* Implicit library calls should use memcpy, not bcopy, etc.  */
115#undef  TARGET_MEM_FUNCTIONS
116#define TARGET_MEM_FUNCTIONS
117
118/* Allow #sccs in preprocessor.  */
119#undef  SCCS_DIRECTIVE
120#define SCCS_DIRECTIVE
121
122#undef  HAVE_ATEXIT
123#define HAVE_ATEXIT
124
125/* Code generation parameters.  */
126
127/* Don't default to pcc-struct-return, because gcc is the only compiler, and
128   we want to retain compatibility with older gcc versions
129   (even though the SVR4 ABI for the i386 says that records and unions are
130   returned in memory).  */
131#undef  DEFAULT_PCC_STRUCT_RETURN
132#define DEFAULT_PCC_STRUCT_RETURN 0
133
134/* Writing `int' for a bitfield forces int alignment for the structure.  */
135/* XXX: ok for Alpha??  */
136#undef  PCC_BITFIELD_TYPE_MATTERS
137#define PCC_BITFIELD_TYPE_MATTERS 1
138
139/* Use periods rather than dollar signs in special g++ assembler names.
140   This ensures the configuration knows our system correctly so we can link
141   with libraries compiled with the native cc.  */
142#undef NO_DOLLAR_IN_LABEL
143
144/* The prefix to add to user-visible assembler symbols.
145   For System V Release 4 & ELF the convention is *not* to prepend a leading
146   underscore onto user-level symbol names.  */
147
148#undef  USER_LABEL_PREFIX
149#define USER_LABEL_PREFIX ""
150
151/* Handle #pragma weak and #pragma pack.  */
152#undef  HANDLE_SYSV_PRAGMA
153#define HANDLE_SYSV_PRAGMA
154
155#ifdef WANT_DWARF2_UNWIND
156/* FreeBSD ELF uses across the board will now use DWARF2 unwinding as the IA-64
157   psABI requires it.  */
158#define DWARF2_UNWIND_INFO 1
159#else
160/* Maintain compatibility with the FreeBSD {3,4}.x C++ ABI.  */
161#define DWARF2_UNWIND_INFO 0
162#endif
163
164/* Do not use ``thunks'' to implement C++ vtables.  This method still has
165   fatal bugs.  Also, GCC 3.0 will have a new C++ ABI that may not even
166   support `thunks'.  */
167#undef DEFAULT_VTABLE_THUNKS
168
169
170/************************[  Assembler stuff  ]********************************/
171
172/* Override the default comment-starter of "/".  */
173#undef  ASM_COMMENT_START
174#define ASM_COMMENT_START	"#"
175
176/* Attach a special .ident directive to the end of the file to identify
177   the version of GCC which compiled this code.  The format of the .ident
178   string is patterned after the ones produced by native SVR4 C compilers.  */
179
180#undef  IDENT_ASM_OP
181#define IDENT_ASM_OP	"\t.ident\t"
182
183/* Output #ident as a .ident.  */
184
185#undef  ASM_OUTPUT_IDENT
186#define ASM_OUTPUT_IDENT(FILE, NAME)					\
187  fprintf ((FILE), "%s\"%s\"\n", IDENT_ASM_OP, (NAME));
188
189/* Identify the front-end which produced this file.  To keep symbol
190   space down, and not confuse kdb, only do this if the language is
191   not C. (svr4.h defines ASM_IDENTIFY_GCC but neglects this) */
192
193#undef  ASM_IDENTIFY_LANGUAGE
194#define ASM_IDENTIFY_LANGUAGE(FILE)					\
195  {									\
196    if (strcmp (lang_identify (), "c") != 0)				\
197        output_lang_identify (FILE);					\
198  }
199
200#undef  ASM_FILE_END
201#define ASM_FILE_END(FILE)						\
202  do {				 					\
203    if (!flag_no_ident)							\
204      fprintf ((FILE), "%s\"[ASM_FILE_END]GCC: (%s) %s\"\n",		\
205		IDENT_ASM_OP, lang_identify(), version_string);		\
206  } while (0)
207
208/* This is the pseudo-op used to generate a contiguous sequence of byte
209   values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
210   AUTOMATICALLY APPENDED.  This is the same for most SVR4 assemblers.  */
211
212#undef  ASCII_DATA_ASM_OP
213#define ASCII_DATA_ASM_OP	"\t.ascii\t"
214
215#undef  ASM_BYTE_OP
216#define ASM_BYTE_OP		"\t.byte\t"
217
218/* This is how to allocate empty space in some section.  The .zero
219   pseudo-op is used for this on most ELF assemblers.  */
220
221#undef  SKIP_ASM_OP
222#define SKIP_ASM_OP		"\t.zero\t"
223
224/* A table of bytes codes used by the ASM_OUTPUT_ASCII and
225   ASM_OUTPUT_LIMITED_STRING macros.  Each byte in the table
226   corresponds to a particular byte value [0..255].  For any
227   given byte value, if the value in the corresponding table
228   position is zero, the given character can be output directly.
229   If the table value is 1, the byte must be output as a \ooo
230   octal escape.  If the tables value is anything else, then the
231   byte value should be output as a \ followed by the value
232   in the table.  Note that we can use standard UN*X escape
233   sequences for many control characters, but we don't use
234   \a to represent BEL because some SVR4 assemblers (e.g. on
235   the i386) don't know about that.  Also, we don't use \v
236   since some versions of gas, such as 2.2 did not accept it.  */
237
238#define ESCAPES \
239"\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
240\0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
241\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\
242\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\
243\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
244\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
245\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
246\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"
247
248/* Some SVR4 assemblers have a limit on the number of characters which
249   can appear in the operand of a .string directive.  If your assembler
250   has such a limitation, you should define STRING_LIMIT to reflect that
251   limit.  Note that at least some SVR4 assemblers have a limit on the
252   actual number of bytes in the double-quoted string, and that they
253   count each character in an escape sequence as one byte.  Thus, an
254   escape sequence like \377 would count as four bytes.
255
256   If your target assembler doesn't support the .string directive, you
257   should define this to zero.
258*/
259
260#undef  STRING_LIMIT
261#define STRING_LIMIT	((unsigned) 256)
262
263#undef  STRING_ASM_OP
264#define STRING_ASM_OP	"\t.string\t"
265
266/* Output the label which precedes a jumptable.  Note that for all svr4/ELF
267   systems where we actually generate jumptables (which is to say every
268   SVR4 target except i386, where we use casesi instead) we put the jump-
269   tables into the .rodata section and since other stuff could have been
270   put into the .rodata section prior to any given jumptable, we have to
271   make sure that the location counter for the .rodata section gets pro-
272   perly re-aligned prior to the actual beginning of the jump table.  */
273
274#undef  ALIGN_ASM_OP
275#define ALIGN_ASM_OP	"\t.align\t"
276
277/* This says how to output assembler code to declare an
278   uninitialized external linkage data object.  Under SVR4/ELF,
279   the linker seems to want the alignment of data objects
280   to depend on their types.  We do exactly that here.  */
281
282#undef  COMMON_ASM_OP
283#define COMMON_ASM_OP	"\t.comm\t"
284
285/* This says how to output assembler code to declare an
286   uninitialized internal linkage data object.  Under SVR4/ELF,
287   the linker seems to want the alignment of data objects
288   to depend on their types.  We do exactly that here.  */
289
290#undef  LOCAL_ASM_OP
291#define LOCAL_ASM_OP	"\t.local\t"
292
293#undef  ASM_OUTPUT_BEFORE_CASE_LABEL
294#define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE)		\
295  ASM_OUTPUT_ALIGN ((FILE), 2);
296
297#undef  ASM_OUTPUT_CASE_LABEL
298#define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)		\
299  do {									\
300    ASM_OUTPUT_BEFORE_CASE_LABEL ((FILE), (PREFIX), (NUM), (JUMPTABLE))	\
301    ASM_OUTPUT_INTERNAL_LABEL ((FILE), (PREFIX), (NUM));		\
302  } while (0)
303
304/* The standard SVR4/ELF assembler seems to require that certain builtin
305   library routines (e.g. .udiv) be explicitly declared as .globl
306   in each assembly file where they are referenced.  */
307
308#undef  ASM_OUTPUT_EXTERNAL_LIBCALL
309#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)				\
310  ASM_GLOBALIZE_LABEL ((FILE), XSTR ((FUN), 0))
311
312/* Support const sections and the ctors and dtors sections for g++.
313   Note that there appears to be two different ways to support const
314   sections at the moment.  You can either #define the symbol
315   READONLY_DATA_SECTION (giving it some code which switches to the
316   readonly data section) or else you can #define the symbols
317   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
318   SELECT_RTX_SECTION.  We do both here just to be on the safe side.
319   FreeBSD conditionalizes the use of ".section rodata" depending on
320   ELF mode - otherwise .text.  */
321
322#undef  USE_CONST_SECTION
323#define USE_CONST_SECTION	TARGET_ELF
324
325#undef  CONST_SECTION_ASM_OP
326#define CONST_SECTION_ASM_OP	"\t.section\t.rodata"
327
328/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
329
330   Note that we want to give these sections the SHF_WRITE attribute
331   because these sections will actually contain data (i.e. tables of
332   addresses of functions in the current root executable or shared library
333   file) and, in the case of a shared library, the relocatable addresses
334   will have to be properly resolved/relocated (and then written into) by
335   the dynamic linker when it actually attaches the given shared library
336   to the executing process.  (Note that on SVR4, you may wish to use the
337   `-z text' option to the ELF linker, when building a shared library, as
338   an additional check that you are doing everything right.  But if you do
339   use the `-z text' option when building a shared library, you will get
340   errors unless the .ctors and .dtors sections are marked as writable
341   via the SHF_WRITE attribute.)  */
342
343#undef  CTORS_SECTION_ASM_OP
344#define CTORS_SECTION_ASM_OP	"\t.section\t.ctors,\"aw\""
345#undef  DTORS_SECTION_ASM_OP
346#define DTORS_SECTION_ASM_OP	"\t.section\t.dtors,\"aw\""
347
348/* On SVR4, we *do* have support for the .init and .fini sections, and we
349   can put stuff in there to be executed before and after `main'.  We let
350   crtstuff.c and other files know this by defining the following symbols.
351   The definitions say how to change sections to the .init and .fini
352   sections.  This is the same for all known SVR4 assemblers.  */
353
354#undef  INIT_SECTION_ASM_OP
355#define INIT_SECTION_ASM_OP	"\t.section\t.init"
356#undef  FINI_SECTION_ASM_OP
357#define FINI_SECTION_ASM_OP	"\t.section\t.fini"
358
359/* A default list of other sections which we might be "in" at any given
360   time.  For targets that use additional sections (e.g. .tdesc) you
361   should override this definition in the target-specific file which
362   includes this file.  */
363
364#undef  EXTRA_SECTIONS
365#define EXTRA_SECTIONS	in_const, in_ctors, in_dtors
366
367/* A default list of extra section function definitions.  For targets
368   that use additional sections (e.g. .tdesc) you should override this
369   definition in the target-specific file which includes this file.  */
370
371#undef  EXTRA_SECTION_FUNCTIONS
372#define EXTRA_SECTION_FUNCTIONS						\
373  CONST_SECTION_FUNCTION						\
374  CTORS_SECTION_FUNCTION						\
375  DTORS_SECTION_FUNCTION
376
377#undef  READONLY_DATA_SECTION
378#define READONLY_DATA_SECTION()	const_section ()
379
380extern void text_section ();
381
382#undef  CONST_SECTION_FUNCTION
383#define CONST_SECTION_FUNCTION						\
384  void									\
385  const_section ()							\
386  {									\
387    if (!USE_CONST_SECTION)						\
388      text_section();							\
389    else if (in_section != in_const)					\
390      {									\
391	fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);		\
392	in_section = in_const;						\
393      }									\
394  }
395
396#undef  CTORS_SECTION_FUNCTION
397#define CTORS_SECTION_FUNCTION						\
398  void									\
399  ctors_section ()							\
400  {									\
401    if (in_section != in_ctors)						\
402      {									\
403	fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);		\
404	in_section = in_ctors;						\
405      }									\
406  }
407
408#undef  DTORS_SECTION_FUNCTION
409#define DTORS_SECTION_FUNCTION						\
410  void									\
411  dtors_section ()							\
412  {									\
413    if (in_section != in_dtors)						\
414      {									\
415 	fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);		\
416	in_section = in_dtors;						\
417      }									\
418  }
419
420/* A C statement or statements to switch to the appropriate
421   section for output of RTX in mode MODE.  RTX is some kind
422   of constant in RTL.  The argument MODE is redundant except
423   in the case of a `const_int' rtx.  Currently, these always
424   go into the const section.  */
425
426#undef  SELECT_RTX_SECTION
427#define SELECT_RTX_SECTION(MODE, RTX)	const_section()
428
429/* Define the strings used for the special svr4/ELF .type and .size
430   directives.  These strings generally do not vary from one svr4/ELF
431   system to another.  */
432
433#undef  TYPE_ASM_OP
434#define TYPE_ASM_OP	"\t.type\t"
435#undef  SIZE_ASM_OP
436#define SIZE_ASM_OP	"\t.size\t"
437
438/* This is how we tell the assembler that a symbol is weak.  */
439
440#undef  ASM_WEAKEN_LABEL
441#define ASM_WEAKEN_LABEL(FILE, NAME)					\
442  do {									\
443    fputs ("\t.globl\t", (FILE)); assemble_name ((FILE), (NAME));	\
444    fputc ('\n', (FILE));						\
445    fputs ("\t.weak\t", (FILE)); assemble_name ((FILE), (NAME));	\
446    fputc ('\n', (FILE));						\
447  } while (0)
448
449/* The following macro defines the [default] format used with ELF to output
450   the second operand of the .type assembler directive.  */
451
452#undef  TYPE_OPERAND_FMT
453#define TYPE_OPERAND_FMT	"@%s"
454
455/* Write the extra assembler code needed to declare a function's result.
456   Most svr4/ELF assemblers don't require any special declaration of the
457   result value.  */
458
459#undef  ASM_DECLARE_RESULT
460#define ASM_DECLARE_RESULT(FILE, RESULT)
461
462/* These macros generate the special .type and .size directives which
463   are used to set the corresponding fields of the linker symbol table
464   entries in an ELF object file under SVR4/ELF.  These macros also output
465   the starting labels for the relevant functions/objects.  */
466
467/* Write the extra assembler code needed to declare an object properly.  */
468
469#undef  ASM_DECLARE_OBJECT_NAME
470#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)			\
471  do {									\
472    fprintf (FILE, "%s ", TYPE_ASM_OP);					\
473    assemble_name (FILE, NAME);						\
474    putc (',', FILE);							\
475    fprintf (FILE, TYPE_OPERAND_FMT, "object");				\
476    putc ('\n', FILE);							\
477    size_directive_output = 0;						\
478    if (!flag_inhibit_size_directive && DECL_SIZE (DECL))		\
479      {									\
480	size_directive_output = 1;					\
481	fprintf (FILE, "%s ", SIZE_ASM_OP);				\
482	assemble_name (FILE, NAME);					\
483	putc (',', FILE);						\
484	fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,				\
485		 int_size_in_bytes (TREE_TYPE (DECL)));			\
486	fputc ('\n', FILE);						\
487      }									\
488    ASM_OUTPUT_LABEL(FILE, NAME);					\
489  } while (0)
490
491/* Output the size directive for a decl in rest_of_decl_compilation
492   in the case where we did not do so before the initializer.
493   Once we find the error_mark_node, we know that the value of
494   size_directive_output was set
495   by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
496
497#undef  ASM_FINISH_DECLARE_OBJECT
498#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)	\
499  do {									\
500    char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);			\
501    if (!flag_inhibit_size_directive && DECL_SIZE (DECL)		\
502	&& ! AT_END && TOP_LEVEL					\
503	&& DECL_INITIAL (DECL) == error_mark_node			\
504	&& !size_directive_output)					\
505      {									\
506	size_directive_output = 1;					\
507	fprintf (FILE, "%s ", SIZE_ASM_OP);				\
508	assemble_name (FILE, name);					\
509	putc (',', FILE);						\
510	fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,				\
511		int_size_in_bytes (TREE_TYPE (DECL))); 			\
512	fputc ('\n', FILE);						\
513      }									\
514  } while (0)
515
516
517/************************[  Debugger stuff  ]*********************************/
518
519/* All ELF targets can support DWARF-2.  */
520#undef  DWARF2_DEBUGGING_INFO
521#define DWARF2_DEBUGGING_INFO
522
523/* This is BSD, so we want the DBX format.  */
524#undef  DBX_DEBUGGING_INFO
525#define DBX_DEBUGGING_INFO
526
527/* This is BSD, so use stabs instead of DWARF debug format.  */
528#undef  PREFERRED_DEBUGGING_TYPE
529#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
530
531/* But allow STABS to be supported as well.
532   	Note that we want to override some definition settings done for some
533   	architecture's native OS's tools that don't apply to us.  */
534#undef ASM_IDENTIFY_GCC
535#undef ASM_IDENTIFY_LANGUAGE
536