freebsd.h revision 60731
168349Sobrien/* Base configuration file for all FreeBSD targets.
268349Sobrien   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
368349Sobrien
468349SobrienThis file is part of GNU CC.
568349Sobrien
668349SobrienGNU CC is free software; you can redistribute it and/or modify
768349Sobrienit under the terms of the GNU General Public License as published by
868349Sobrienthe Free Software Foundation; either version 2, or (at your option)
968349Sobrienany later version.
1068349Sobrien
1168349SobrienGNU CC is distributed in the hope that it will be useful,
1268349Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1368349SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1468349SobrienGNU General Public License for more details.
1568349Sobrien
1668349SobrienYou should have received a copy of the GNU General Public License
1768349Sobrienalong with GNU CC; see the file COPYING.  If not, write to
1868349Sobrienthe Free Software Foundation, 59 Temple Place - Suite 330,
1968349SobrienBoston, MA 02111-1307, USA.  */
2068349Sobrien
2168349Sobrien/* Common FreeBSD configuration.
2268349Sobrien   All FreeBSD architectures should include this file, which will specify
2368349Sobrien   their commonalities.
2468349Sobrien   Adapted from /usr/src/contrib/gcc/config/i386/freebsd.h,
2568349Sobrien   /usr/src/contrib/gcc/config/svr4.h &
2668349Sobrien   egcs/gcc/config/i386/freebsd-elf.h version by David O'Brien  */
2768349Sobrien
28110949Sobrien/* $FreeBSD: head/contrib/gcc/config/freebsd.h 60731 2000-05-20 10:14:43Z obrien $ */
2968349Sobrien
30103373Sobrien
31103373Sobrien/* Cpp, assembler, linker, library, and startfile spec's.  */
32103373Sobrien
33103373Sobrien/* This defines which switch letters take arguments.  On FreeBSD, most of
3468349Sobrien   the normal cases (defined in gcc.c) apply, and we also have -h* and
35110949Sobrien   -z* options (for the linker) (comming from svr4).
36110949Sobrien   We also have -R (alias --rpath), no -z, --soname (-h), --assert etc.  */
37110949Sobrien
38110949Sobrien#define FBSD_SWITCH_TAKES_ARG(CHAR) \
39110949Sobrien  (DEFAULT_SWITCH_TAKES_ARG (CHAR) \
40110949Sobrien   || (CHAR) == 'h' \
41110949Sobrien   || (CHAR) == 'z' /* ignored by ld */ \
42110949Sobrien   || (CHAR) == 'R')
43110949Sobrien
44110949Sobrien#undef  SWITCH_TAKES_ARG
45110949Sobrien#define SWITCH_TAKES_ARG(CHAR)	(FBSD_SWITCH_TAKES_ARG(CHAR))
46110949Sobrien
47110949Sobrien/* This defines which multi-letter switches take arguments.  */
48110949Sobrien
49110949Sobrien#define FBSD_WORD_SWITCH_TAKES_ARG(STR)					\
50110949Sobrien  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)					\
51110949Sobrien   || !strcmp ((STR), "rpath") || !strcmp ((STR), "rpath-link")		\
52110949Sobrien   || !strcmp ((STR), "soname") || !strcmp ((STR), "defsym") 		\
53110949Sobrien   || !strcmp ((STR), "assert") || !strcmp ((STR), "dynamic-linker"))
54110949Sobrien
55110949Sobrien#undef  WORD_SWITCH_TAKES_ARG
56110949Sobrien#define WORD_SWITCH_TAKES_ARG(STR)	(FBSD_WORD_SWITCH_TAKES_ARG(STR))
57110949Sobrien
58110949Sobrien/* Place spaces around this string.  We depend on string splicing to produce
59110949Sobrien   the final CPP_PREDEFINES value.  */
60110949Sobrien#define FBSD_CPP_PREDEFINES " -Dunix -D__FreeBSD__=5 -D__FreeBSD_cc_version=500001 -Asystem(unix) -Asystem(FreeBSD) "
61110949Sobrien
62110949Sobrien#define FBSD_CPP_SPEC "\
63110949Sobrien  %(cpp_cpu) \
64110949Sobrien  %{!maout: -D__ELF__} \
65110949Sobrien  %{munderscores: -D__UNDERSCORES__} \
66110949Sobrien  %{maout: %{!mno-underscores: -D__UNDERSCORES__}} \
67110949Sobrien  %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
68110949Sobrien  %{posix:-D_POSIX_SOURCE}"
69110949Sobrien
70110949Sobrien#undef  CPP_SPEC
71110949Sobrien#define CPP_SPEC FBSD_CPP_SPEC
72110949Sobrien
73110949Sobrien/* Provide a LIB_SPEC appropriate for FreeBSD.  Just select the appropriate
74110949Sobrien   libc, depending on whether we're doing profiling.
75110949Sobrien   (like the default, except no -lg, and no -p).  */
76110949Sobrien#undef  LIB_SPEC
77110949Sobrien#define LIB_SPEC "\
78110949Sobrien  %{!shared: \
79110949Sobrien    %{!pg: \
80110949Sobrien      %{!pthread:%{!kthread:-lc}%{kthread:-lpthread -lc}} \
81110949Sobrien      %{pthread:-lc_r}} \
82110949Sobrien    %{pg: \
83110949Sobrien      %{!pthread:%{!kthread:-lc_p}%{kthread:-lpthread_p -lc_p}} \
84110949Sobrien      %{pthread:-lc_r_p}}}"
85110949Sobrien
86110949Sobrien
87110949Sobrien/************************[  Target stuff  ]***********************************/
88110949Sobrien
89110949Sobrien/* All FreeBSD Architectures support the ELF object file format.  */
90110949Sobrien#undef  OBJECT_FORMAT_ELF
91110949Sobrien#define OBJECT_FORMAT_ELF
92110949Sobrien
93110949Sobrien/* Don't assume anything about the header files.  */
94110949Sobrien#undef  NO_IMPLICIT_EXTERN_C
95110949Sobrien#define NO_IMPLICIT_EXTERN_C
96110949Sobrien
97110949Sobrien/* Implicit library calls should use memcpy, not bcopy, etc.  */
98110949Sobrien#undef  TARGET_MEM_FUNCTIONS
99110949Sobrien#define TARGET_MEM_FUNCTIONS
100110949Sobrien
101110949Sobrien/* Allow #sccs in preprocessor.  */
102110949Sobrien#undef  SCCS_DIRECTIVE
103110949Sobrien#define SCCS_DIRECTIVE
104110949Sobrien
105110949Sobrien/* Tell libgcc2.c that FreeBSD targets support atexit(3).  */
106110949Sobrien#undef  HAVE_ATEXIT
107110949Sobrien#define HAVE_ATEXIT
108110949Sobrien
109110949Sobrien/* Code generation parameters.  */
110110949Sobrien
111110949Sobrien/* Don't default to pcc-struct-return, because gcc is the only compiler, and
112110949Sobrien   we want to retain compatibility with older gcc versions
113110949Sobrien   (even though the svr4 ABI for the i386 says that records and unions are
114110949Sobrien   returned in memory).  */
115110949Sobrien#undef  DEFAULT_PCC_STRUCT_RETURN
116110949Sobrien#define DEFAULT_PCC_STRUCT_RETURN 0
117110949Sobrien
118110949Sobrien/* Writing `int' for a bitfield forces int alignment for the structure.  */
119110949Sobrien/* XXX: ok for Alpha??  */
120110949Sobrien#undef  PCC_BITFIELD_TYPE_MATTERS
121110949Sobrien#define PCC_BITFIELD_TYPE_MATTERS 1
122110949Sobrien
123110949Sobrien/* Use periods rather than dollar signs in special g++ assembler names.
124110949Sobrien   This ensures the configuration knows our system correctly so we can link
125110949Sobrien   with libraries compiled with the native cc.  */
126110949Sobrien#undef NO_DOLLAR_IN_LABEL
127110949Sobrien
12868349Sobrien/* The prefix to add to user-visible assembler symbols.
12968349Sobrien   For System V Release 4 & ELF the convention is *not* to prepend a leading
13068349Sobrien   underscore onto user-level symbol names.  */
13168349Sobrien
132103373Sobrien#undef  USER_LABEL_PREFIX
133103373Sobrien#define USER_LABEL_PREFIX ""
134103373Sobrien
13568349Sobrien/* Handle #pragma weak and #pragma pack.  */
13668349Sobrien#undef  HANDLE_SYSV_PRAGMA
13768349Sobrien#define HANDLE_SYSV_PRAGMA
13868349Sobrien
13968349Sobrien/* Do not use ``thunks'' to implement C++ vtables.  This method still has
14068349Sobrien   fatal bugs.  Also, GCC 3.0 will have a new C++ ABI that may not even
14168349Sobrien   support `thunks'.  */
14268349Sobrien#undef DEFAULT_VTABLE_THUNKS
14368349Sobrien
14468349Sobrien
14568349Sobrien/************************[  Assembler stuff  ]********************************/
14668349Sobrien
14768349Sobrien/* Override the default comment-starter of "/".  */
14868349Sobrien#undef  ASM_COMMENT_START
14968349Sobrien#define ASM_COMMENT_START	"#"
15068349Sobrien
15168349Sobrien/* Attach a special .ident directive to the end of the file to identify
15268349Sobrien   the version of GCC which compiled this code.  The format of the
15380588Sobrien   .ident string is patterned after the ones produced by native svr4
15468349Sobrien   C compilers.  */
15584685Sobrien
15684685Sobrien#undef  IDENT_ASM_OP
15784685Sobrien#define IDENT_ASM_OP	".ident"
15868349Sobrien
15968349Sobrien/* Output #ident as a .ident.  */
16068349Sobrien
16184685Sobrien#undef  ASM_OUTPUT_IDENT
16284685Sobrien#define ASM_OUTPUT_IDENT(FILE, NAME) \
16384685Sobrien  fprintf ((FILE), "\t%s\t\"%s\"\n", IDENT_ASM_OP, (NAME));
16484685Sobrien
16584685Sobrien/* Identify the front-end which produced this file.  To keep symbol
16668349Sobrien   space down, and not confuse kdb, only do this if the language is
16768349Sobrien   not C. (svr4.h defines ASM_IDENTIFY_GCC but neglects this) */
16868349Sobrien
16984685Sobrien#undef  ASM_IDENTIFY_LANGUAGE
170111658Sobrien#define ASM_IDENTIFY_LANGUAGE(FILE)					\
171111658Sobrien  {									\
172111658Sobrien    if (strcmp (lang_identify (), "c") != 0)				\
173111658Sobrien        output_lang_identify (FILE);					\
17480588Sobrien  }
17584685Sobrien
17684685Sobrien#undef  ASM_FILE_END
17784685Sobrien#define ASM_FILE_END(FILE)						\
17880588Sobrien  do {				 					\
17980588Sobrien    if (!flag_no_ident)							\
18080588Sobrien      fprintf ((FILE), "\t%s\t\"[ASM_FILE_END]GCC: (%s) %s\"\n",	\
18184685Sobrien		IDENT_ASM_OP, lang_identify(), version_string);		\
18284685Sobrien  } while (0)
18384685Sobrien
18484685Sobrien/* This is the pseudo-op used to generate a contiguous sequence of byte
18584685Sobrien   values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
18680588Sobrien   AUTOMATICALLY APPENDED.  This is the same for most svr4 assemblers.  */
18780588Sobrien
18880588Sobrien#undef  ASCII_DATA_ASM_OP
18968349Sobrien#define ASCII_DATA_ASM_OP	".ascii"
19068349Sobrien
19168349Sobrien#undef  ASM_BYTE_OP
19268349Sobrien#define ASM_BYTE_OP		".byte"
19368349Sobrien
19468349Sobrien/* This is how to allocate empty space in some section.  The .zero
19568349Sobrien   pseudo-op is used for this on most ELF assemblers.  */
19668349Sobrien
19768349Sobrien#undef  SKIP_ASM_OP
19868349Sobrien#define SKIP_ASM_OP		".zero"
19968349Sobrien
20068349Sobrien/* How to output some space.  The rules are different depending on the
20168349Sobrien   object format.  */
20284685Sobrien#undef  ASM_OUTPUT_SKIP
20384685Sobrien#define ASM_OUTPUT_SKIP(FILE, SIZE) 					\
20484685Sobrien  do {									\
20584685Sobrien    if (TARGET_ELF)							\
20684685Sobrien      {									\
20784685Sobrien        fprintf ((FILE), "\t%s\t%u\n", SKIP_ASM_OP, (SIZE));		\
20884685Sobrien      }									\
20984685Sobrien    else								\
21084685Sobrien      {									\
21184685Sobrien        fprintf ((FILE), "\t.space %u\n", (SIZE));			\
212103373Sobrien      }									\
213103373Sobrien  } while (0)
214103373Sobrien
215103373Sobrien/* A table of bytes codes used by the ASM_OUTPUT_ASCII and
216103373Sobrien   ASM_OUTPUT_LIMITED_STRING macros.  Each byte in the table
217103373Sobrien   corresponds to a particular byte value [0..255].  For any
218103373Sobrien   given byte value, if the value in the corresponding table
219103373Sobrien   position is zero, the given character can be output directly.
220103373Sobrien   If the table value is 1, the byte must be output as a \ooo
221103373Sobrien   octal escape.  If the tables value is anything else, then the
222103373Sobrien   byte value should be output as a \ followed by the value
223103373Sobrien   in the table.  Note that we can use standard UN*X escape
224103373Sobrien   sequences for many control characters, but we don't use
225103373Sobrien   \a to represent BEL because some svr4 assemblers (e.g. on
226103373Sobrien   the i386) don't know about that.  Also, we don't use \v
227103373Sobrien   since some versions of gas, such as 2.2 did not accept it.  */
228103373Sobrien
229103373Sobrien#define ESCAPES \
230103373Sobrien"\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\
231103373Sobrien\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\
232103373Sobrien\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\
233103373Sobrien\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\
234103373Sobrien\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\
235103373Sobrien\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\
236103373Sobrien\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\
237103373Sobrien\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"
238103373Sobrien
239103373Sobrien/* Some svr4 assemblers have a limit on the number of characters which
240103373Sobrien   can appear in the operand of a .string directive.  If your assembler
241103373Sobrien   has such a limitation, you should define STRING_LIMIT to reflect that
242103373Sobrien   limit.  Note that at least some svr4 assemblers have a limit on the
243103373Sobrien   actual number of bytes in the double-quoted string, and that they
244103373Sobrien   count each character in an escape sequence as one byte.  Thus, an
245103373Sobrien   escape sequence like \377 would count as four bytes.
246103373Sobrien
247103373Sobrien   If your target assembler doesn't support the .string directive, you
248103373Sobrien   should define this to zero.
249103373Sobrien*/
250103373Sobrien
251103373Sobrien#undef  STRING_LIMIT
252103373Sobrien#define STRING_LIMIT	((unsigned) 256)
253103373Sobrien
254103373Sobrien#undef  STRING_ASM_OP
255103373Sobrien#define STRING_ASM_OP	".string"
256103373Sobrien
257103373Sobrien/* Output the label which precedes a jumptable.  Note that for all svr4/ELF
258103373Sobrien   systems where we actually generate jumptables (which is to say every
259103373Sobrien   svr4 target except i386, where we use casesi instead) we put the jump-
260103373Sobrien   tables into the .rodata section and since other stuff could have been
261103373Sobrien   put into the .rodata section prior to any given jumptable, we have to
262103373Sobrien   make sure that the location counter for the .rodata section gets pro-
263103373Sobrien   perly re-aligned prior to the actual beginning of the jump table.  */
264103373Sobrien
265103373Sobrien#undef  ALIGN_ASM_OP
266103373Sobrien#define ALIGN_ASM_OP	".align"
267103373Sobrien
268103373Sobrien/* This says how to output assembler code to declare an
269103373Sobrien   uninitialized external linkage data object.  Under SVR4/ELF,
270103373Sobrien   the linker seems to want the alignment of data objects
271103373Sobrien   to depend on their types.  We do exactly that here.  */
272103373Sobrien
273103373Sobrien#undef  COMMON_ASM_OP
274103373Sobrien#define COMMON_ASM_OP	".comm"
275103373Sobrien
276103373Sobrien#undef  ASM_OUTPUT_ALIGNED_COMMON
277103373Sobrien#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
278103373Sobrien  do {									\
279103373Sobrien    if (TARGET_ELF)							\
280103373Sobrien      {							\
281	fprintf ((FILE), "\t%s\t", COMMON_ASM_OP);			\
282	assemble_name ((FILE), (NAME));					\
283	fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);	\
284      }									\
285    else								\
286      {									\
287	int rounded = (SIZE);						\
288	if (rounded == 0) rounded = 1;					\
289	rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;		\
290	rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)	\
291		   * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));		\
292	fputs (".comm ", (FILE));					\
293	assemble_name ((FILE), (NAME));					\
294	fprintf ((FILE), ",%u\n", (rounded));				\
295      }									\
296  } while (0)
297
298/* This says how to output assembler code to declare an
299   uninitialized internal linkage data object.  Under SVR4/ELF,
300   the linker seems to want the alignment of data objects
301   to depend on their types.  We do exactly that here.  */
302
303#undef  LOCAL_ASM_OP
304#define LOCAL_ASM_OP	".local"
305
306/* This says how to output assembler code to declare an
307   uninitialized internal linkage data object.  Under SVR4,
308   the linker seems to want the alignment of data objects
309   to depend on their types.  We do exactly that here.  */
310
311#undef  ASM_OUTPUT_ALIGNED_LOCAL
312#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)		\
313  do {									\
314    if (TARGET_ELF)							\
315      {									\
316	fprintf ((FILE), "\t%s\t", LOCAL_ASM_OP);			\
317	assemble_name ((FILE), (NAME));					\
318	fprintf ((FILE), "\n");						\
319	ASM_OUTPUT_ALIGNED_COMMON ((FILE), (NAME), (SIZE), (ALIGN));	\
320      }									\
321    else								\
322      {									\
323	int rounded = (SIZE);						\
324	if (rounded == 0) rounded = 1;					\
325	rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;		\
326	rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)	\
327		   * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));		\
328	fputs (".lcomm ", (FILE));					\
329	assemble_name ((FILE), (NAME));					\
330	fprintf ((FILE), ",%u\n", (rounded));				\
331      }									\
332  } while (0)
333
334#undef  ASM_OUTPUT_BEFORE_CASE_LABEL
335#define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE)		\
336  ASM_OUTPUT_ALIGN ((FILE), 2);
337
338#undef  ASM_OUTPUT_CASE_LABEL
339#define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE)		\
340  do {									\
341    ASM_OUTPUT_BEFORE_CASE_LABEL ((FILE), (PREFIX), (NUM), (JUMPTABLE))	\
342    ASM_OUTPUT_INTERNAL_LABEL ((FILE), (PREFIX), (NUM));		\
343  } while (0)
344
345/* The standard SVR4/ELF assembler seems to require that certain builtin
346   library routines (e.g. .udiv) be explicitly declared as .globl
347   in each assembly file where they are referenced.  */
348
349#undef  ASM_OUTPUT_EXTERNAL_LIBCALL
350#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)				\
351  ASM_GLOBALIZE_LABEL ((FILE), XSTR ((FUN), 0))
352
353/* Support const sections and the ctors and dtors sections for g++.
354   Note that there appears to be two different ways to support const
355   sections at the moment.  You can either #define the symbol
356   READONLY_DATA_SECTION (giving it some code which switches to the
357   readonly data section) or else you can #define the symbols
358   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
359   SELECT_RTX_SECTION.  We do both here just to be on the safe side.
360   FreeBSD conditionalizes the use of ".section rodata" depending on
361   ELF mode - otherwise .text.  */
362
363#undef  USE_CONST_SECTION
364#define USE_CONST_SECTION	TARGET_ELF
365
366#undef  CONST_SECTION_ASM_OP
367#define CONST_SECTION_ASM_OP	".section\t.rodata"
368
369/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
370
371   Note that we want to give these sections the SHF_WRITE attribute
372   because these sections will actually contain data (i.e. tables of
373   addresses of functions in the current root executable or shared library
374   file) and, in the case of a shared library, the relocatable addresses
375   will have to be properly resolved/relocated (and then written into) by
376   the dynamic linker when it actually attaches the given shared library
377   to the executing process.  (Note that on SVR4, you may wish to use the
378   `-z text' option to the ELF linker, when building a shared library, as
379   an additional check that you are doing everything right.  But if you do
380   use the `-z text' option when building a shared library, you will get
381   errors unless the .ctors and .dtors sections are marked as writable
382   via the SHF_WRITE attribute.)  */
383
384#undef  CTORS_SECTION_ASM_OP
385#define CTORS_SECTION_ASM_OP	".section\t.ctors,\"aw\""
386#undef  DTORS_SECTION_ASM_OP
387#define DTORS_SECTION_ASM_OP	".section\t.dtors,\"aw\""
388
389/* On svr4, we *do* have support for the .init and .fini sections, and we
390   can put stuff in there to be executed before and after `main'.  We let
391   crtstuff.c and other files know this by defining the following symbols.
392   The definitions say how to change sections to the .init and .fini
393   sections.  This is the same for all known svr4 assemblers.  */
394
395#undef  INIT_SECTION_ASM_OP
396#define INIT_SECTION_ASM_OP	".section\t.init"
397#undef  FINI_SECTION_ASM_OP
398#define FINI_SECTION_ASM_OP	".section\t.fini"
399
400/* A default list of other sections which we might be "in" at any given
401   time.  For targets that use additional sections (e.g. .tdesc) you
402   should override this definition in the target-specific file which
403   includes this file.  */
404
405#undef  EXTRA_SECTIONS
406#define EXTRA_SECTIONS	in_const, in_ctors, in_dtors
407
408/* A default list of extra section function definitions.  For targets
409   that use additional sections (e.g. .tdesc) you should override this
410   definition in the target-specific file which includes this file.  */
411
412#undef  EXTRA_SECTION_FUNCTIONS
413#define EXTRA_SECTION_FUNCTIONS						\
414  CONST_SECTION_FUNCTION						\
415  CTORS_SECTION_FUNCTION						\
416  DTORS_SECTION_FUNCTION
417
418#undef  READONLY_DATA_SECTION
419#define READONLY_DATA_SECTION()	const_section ()
420
421extern void text_section ();
422
423#undef  CONST_SECTION_FUNCTION
424#define CONST_SECTION_FUNCTION						\
425  void									\
426  const_section ()							\
427  {									\
428    if (!USE_CONST_SECTION)						\
429      text_section();							\
430    else if (in_section != in_const)					\
431      {									\
432	fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);		\
433	in_section = in_const;						\
434      }									\
435  }
436
437#undef  CTORS_SECTION_FUNCTION
438#define CTORS_SECTION_FUNCTION						\
439  void									\
440  ctors_section ()							\
441  {									\
442    if (in_section != in_ctors)						\
443      {									\
444	fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);		\
445	in_section = in_ctors;						\
446      }									\
447  }
448
449#undef  DTORS_SECTION_FUNCTION
450#define DTORS_SECTION_FUNCTION						\
451  void									\
452  dtors_section ()							\
453  {									\
454    if (in_section != in_dtors)						\
455      {									\
456 	fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);		\
457	in_section = in_dtors;						\
458      }									\
459  }
460
461/* A C statement (sans semicolon) to output an element in the table of
462   global constructors.  */
463#undef  ASM_OUTPUT_CONSTRUCTOR
464#define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME)				\
465  do {									\
466    if (TARGET_ELF)							\
467      {									\
468	ctors_section ();						\
469	fprintf ((FILE), "\t%s\t ", INT_ASM_OP);			\
470	assemble_name ((FILE), (NAME));					\
471	fprintf ((FILE), "\n");						\
472      }									\
473    else								\
474      {									\
475	fprintf (asm_out_file, "%s \"%s__CTOR_LIST__\",22,0,0,",	\
476		 ASM_STABS_OP, (TARGET_UNDERSCORES) ? "_" : "");	\
477	assemble_name (asm_out_file, name);				\
478	fputc ('\n', asm_out_file);					\
479      }									\
480  } while (0)
481
482/* A C statement (sans semicolon) to output an element in the table of
483   global destructors.  */
484#undef  ASM_OUTPUT_DESTRUCTOR
485#define ASM_OUTPUT_DESTRUCTOR(FILE, NAME)				\
486  do {									\
487    if (TARGET_ELF)							\
488      {									\
489	dtors_section ();						\
490	fprintf ((FILE), "\t%s\t ", INT_ASM_OP);			\
491	assemble_name ((FILE), (NAME));					\
492	fprintf ((FILE), "\n");						\
493      }									\
494    else								\
495      {									\
496	fprintf (asm_out_file, "%s \"%s__DTOR_LIST__\",22,0,0,",	\
497		 ASM_STABS_OP, (TARGET_UNDERSCORES) ? "_" : "");	\
498	assemble_name (asm_out_file, name);				\
499	fputc ('\n', asm_out_file);					\
500      }									\
501  } while (0)
502
503/* A C statement or statements to switch to the appropriate
504   section for output of RTX in mode MODE.  RTX is some kind
505   of constant in RTL.  The argument MODE is redundant except
506   in the case of a `const_int' rtx.  Currently, these always
507   go into the const section.  */
508
509#undef  SELECT_RTX_SECTION
510#define SELECT_RTX_SECTION(MODE, RTX)	const_section()
511
512/* Define the strings used for the special svr4/ELF .type and .size
513   directives.  These strings generally do not vary from one svr4/ELF
514   system to another.  */
515
516#undef  TYPE_ASM_OP
517#define TYPE_ASM_OP	".type"
518#undef  SIZE_ASM_OP
519#define SIZE_ASM_OP	".size"
520
521/* This is how we tell the assembler that a symbol is weak.  */
522
523#undef  ASM_WEAKEN_LABEL
524#define ASM_WEAKEN_LABEL(FILE, NAME)					\
525  do {									\
526    fputs ("\t.globl\t", (FILE)); assemble_name ((FILE), (NAME));	\
527    fputc ('\n', (FILE));						\
528    fputs ("\t.weak\t", (FILE)); assemble_name ((FILE), (NAME));	\
529    fputc ('\n', (FILE));						\
530  } while (0)
531
532/* The following macro defines the [default] format used with ELF to output
533   the second operand of the .type assembler directive.  */
534
535#undef  TYPE_OPERAND_FMT
536#define TYPE_OPERAND_FMT	"@%s"
537
538/* Write the extra assembler code needed to declare a function's result.
539   Most svr4/ELF assemblers don't require any special declaration of the
540   result value.  */
541
542#undef  ASM_DECLARE_RESULT
543#define ASM_DECLARE_RESULT(FILE, RESULT)
544
545/* These macros generate the special .type and .size directives which
546   are used to set the corresponding fields of the linker symbol table
547   entries in an ELF object file under SVR4/ELF.  These macros also output
548   the starting labels for the relevant functions/objects.  */
549
550/* Write the extra assembler code needed to declare an object properly.  */
551
552#undef  ASM_DECLARE_OBJECT_NAME
553#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)			\
554  do {									\
555    fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);				\
556    assemble_name (FILE, NAME);						\
557    putc (',', FILE);							\
558    fprintf (FILE, TYPE_OPERAND_FMT, "object");				\
559    putc ('\n', FILE);							\
560    size_directive_output = 0;						\
561    if (!flag_inhibit_size_directive && DECL_SIZE (DECL))		\
562      {									\
563	size_directive_output = 1;					\
564	fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);				\
565	assemble_name (FILE, NAME);					\
566	putc (',', FILE);						\
567	fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,				\
568		 int_size_in_bytes (TREE_TYPE (DECL)));			\
569	fputc ('\n', FILE);						\
570      }									\
571    ASM_OUTPUT_LABEL(FILE, NAME);					\
572  } while (0)
573
574/* Output the size directive for a decl in rest_of_decl_compilation
575   in the case where we did not do so before the initializer.
576   Once we find the error_mark_node, we know that the value of
577   size_directive_output was set
578   by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
579
580#undef  ASM_FINISH_DECLARE_OBJECT
581#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)	\
582  do {									\
583    char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);			\
584    if (!flag_inhibit_size_directive && DECL_SIZE (DECL)		\
585	&& ! AT_END && TOP_LEVEL					\
586	&& DECL_INITIAL (DECL) == error_mark_node			\
587	&& !size_directive_output)					\
588      {									\
589	size_directive_output = 1;					\
590	fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);				\
591	assemble_name (FILE, name);					\
592	putc (',', FILE);						\
593	fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,				\
594		int_size_in_bytes (TREE_TYPE (DECL))); 			\
595	fputc ('\n', FILE);						\
596      }									\
597  } while (0)
598
599
600/************************[  Debugger stuff  ]*********************************/
601
602/* All ELF targets can support DWARF-2.  */
603#undef  DWARF2_DEBUGGING_INFO
604#define DWARF2_DEBUGGING_INFO
605
606/* This is BSD, so we want the DBX format.  */
607#undef  DBX_DEBUGGING_INFO
608#define DBX_DEBUGGING_INFO
609
610/* Use stabs instead of DWARF debug format.  */
611#undef  PREFERRED_DEBUGGING_TYPE
612#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
613
614/* But allow STABS to be supported as well.
615   	Note that we want to override some definition settings done for some
616   	architecture's native OS's tools that don't apply to us.  */
617#undef ASM_IDENTIFY_GCC
618#undef ASM_IDENTIFY_LANGUAGE
619
620#include "dbxelf.h"
621