freebsd.h revision 51408
119370Spst/* Definitions for Intel 386 running FreeBSD with either a.out or ELF format
219370Spst   Copyright (C) 1996 Free Software Foundation, Inc.
3130803Smarcel   Contributed by Eric Youngdale.
4130803Smarcel   Modified for stabs-in-ELF by H.J. Lu.
5130803Smarcel   Adapted from GNU/Linux version by John Polstra.
6130803Smarcel   Added support for generating "old a.out gas" on the fly by Peter Wemm.
798944Sobrien
819370SpstThis file is part of GNU CC.
998944Sobrien
1098944SobrienGNU CC is free software; you can redistribute it and/or modify
1198944Sobrienit under the terms of the GNU General Public License as published by
1298944Sobrienthe Free Software Foundation; either version 2, or (at your option)
1319370Spstany later version.
1498944Sobrien
1598944SobrienGNU CC is distributed in the hope that it will be useful,
1698944Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1798944SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1819370SpstGNU General Public License for more details.
1998944Sobrien
2098944SobrienYou should have received a copy of the GNU General Public License
2198944Sobrienalong with GNU CC; see the file COPYING.  If not, write to
2298944Sobrienthe Free Software Foundation, 59 Temple Place - Suite 330,
2319370SpstBoston, MA 02111-1307, USA.  */
2419370Spst
2519370Spst/* $FreeBSD: head/contrib/gcc/config/i386/freebsd.h 51408 1999-09-19 10:28:57Z obrien $ */
2619370Spst
2719370Spst
2819370Spst#undef TARGET_VERSION
2919370Spst#define TARGET_VERSION fprintf (stderr, " (i386 FreeBSD/ELF)");
3019370Spst
3119370Spst/* The svr4 ABI for the i386 says that records and unions are returned
32130803Smarcel   in memory.  */
3319370Spst/* On FreeBSD, we do not. */
3419370Spst#undef DEFAULT_PCC_STRUCT_RETURN
35130803Smarcel#define DEFAULT_PCC_STRUCT_RETURN 0
36130803Smarcel
37130803Smarcel/* This gets defined in tm.h->linux.h->svr4.h, and keeps us from using
3819370Spst   libraries compiled with the native cc, so undef it. */
3919370Spst#undef NO_DOLLAR_IN_LABEL
40130803Smarcel
4119370Spst/* Don't assume anything about the header files.  */
4219370Spst#undef NO_IMPLICIT_EXTERN_C
4319370Spst#define NO_IMPLICIT_EXTERN_C
4419370Spst
4519370Spst/* This defines which switch letters take arguments.  On FreeBSD, most of
4619370Spst   the normal cases (defined in gcc.c) apply, and we also have -h* and
4719370Spst   -z* options (for the linker) (comming from svr4).
4819370Spst   We also have -R (alias --rpath), no -z, --soname (-h), --assert etc.  */
4919370Spst
5019370Spst#undef SWITCH_TAKES_ARG
5119370Spst#define SWITCH_TAKES_ARG(CHAR)						\
5219370Spst  (DEFAULT_SWITCH_TAKES_ARG (CHAR)					\
5319370Spst   || (CHAR) == 'h'							\
5419370Spst   || (CHAR) == 'z' /* ignored by ld */					\
5519370Spst   || (CHAR) == 'R')
5619370Spst
5719370Spst#undef WORD_SWITCH_TAKES_ARG
5898944Sobrien#define WORD_SWITCH_TAKES_ARG(STR)					\
5998944Sobrien  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)					\
6019370Spst   || !strcmp (STR, "rpath") || !strcmp (STR, "rpath-link")		\
6198944Sobrien   || !strcmp (STR, "soname") || !strcmp (STR, "defsym") 		\
6298944Sobrien   || !strcmp (STR, "assert") || !strcmp (STR, "dynamic-linker"))
6319370Spst
6498944Sobrien#define MASK_PROFILER_EPILOGUE	010000000000
6519370Spst#define MASK_AOUT		004000000000	/* a.out not elf */
6698944Sobrien#define MASK_UNDERSCORES	002000000000	/* use leading _ */
6719370Spst
6898944Sobrien#define TARGET_PROFILER_EPILOGUE	(target_flags & MASK_PROFILER_EPILOGUE)
6919370Spst#define TARGET_AOUT			(target_flags & MASK_AOUT)
7098944Sobrien#define TARGET_ELF			((target_flags & MASK_AOUT) == 0)
7198944Sobrien#define TARGET_UNDERSCORES		((target_flags & MASK_UNDERSCORES) != 0)
7219370Spst
7398944Sobrien#undef	SUBTARGET_SWITCHES
7446283Sdfr#define SUBTARGET_SWITCHES					\
7598944Sobrien     { "profiler-epilogue",	 MASK_PROFILER_EPILOGUE},	\
7646283Sdfr     { "no-profiler-epilogue",	-MASK_PROFILER_EPILOGUE},	\
7798944Sobrien     { "aout",			 MASK_AOUT},			\
7898944Sobrien     { "no-aout",		-MASK_AOUT},			\
7998944Sobrien     { "underscores",		 MASK_UNDERSCORES},		\
8098944Sobrien     { "no-underscores",	-MASK_UNDERSCORES},
8198944Sobrien
8298944Sobrien/* Prefix for internally generated assembler labels.  If we aren't using
8319370Spst   underscores, we are using prefix `.'s to identify labels that should
84130803Smarcel   be ignored, as in `i386/gas.h' --karl@cs.umb.edu  */
8519370Spst#undef  LPREFIX
8698944Sobrien#define LPREFIX ((TARGET_UNDERSCORES) ? "L" : ".L")
8798944Sobrien
8819370Spst/* Override the default comment-starter of "/".  */
8919370Spst#undef ASM_COMMENT_START
9019370Spst#define ASM_COMMENT_START "#"
91130803Smarcel
92130803Smarcel#undef COMMENT_BEGIN
93130803Smarcel#define COMMENT_BEGIN "#"
9419370Spst
9598944Sobrien#undef ASM_APP_ON
9619370Spst#define ASM_APP_ON "#APP\n"
97130803Smarcel
98130803Smarcel#undef ASM_APP_OFF
99130803Smarcel#define ASM_APP_OFF "#NO_APP\n"
100130803Smarcel
10119370Spst#define SET_ASM_OP	".set"
102130803Smarcel
103130803Smarcel/* Output at beginning of assembler file.  */
10419370Spst/* The .file command should always begin the output.  */
105130803Smarcel
106130803Smarcel#undef ASM_FILE_START
107130803Smarcel#define ASM_FILE_START(FILE)						\
10819370Spst  do {									\
10919370Spst        output_file_directive (FILE, main_input_filename);		\
11019370Spst	if (TARGET_ELF)							\
11119370Spst          fprintf (FILE, "\t.version\t\"01.01\"\n");			\
11219370Spst  } while (0)
11319370Spst
11419370Spst/* Identify the front-end which produced this file.  To keep symbol
11519370Spst   space down, and not confuse kdb, only do this if the language is
11619370Spst   not C. (svr4.h defines ASM_IDENTIFY_GCC but neglects this) */
11719370Spst#undef ASM_IDENTIFY_LANGUAGE
11819370Spst#define ASM_IDENTIFY_LANGUAGE(STREAM)					\
119130803Smarcel{									\
12019370Spst  if (strcmp (lang_identify (), "c") != 0)				\
121130803Smarcel    output_lang_identify (STREAM);					\
122130803Smarcel}
12319370Spst
12419370Spst/* This is how to store into the string BUF
12519370Spst   the symbol_ref name of an internal numbered label where
12619370Spst   PREFIX is the class of label and NUM is the number within the class.
12719370Spst   This is suitable for output with `assemble_name'.  */
12898944Sobrien#undef	ASM_GENERATE_INTERNAL_LABEL
12998944Sobrien#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER)			\
13019370Spst    sprintf ((BUF), "*%s%s%d", (TARGET_UNDERSCORES) ? "" : ".",		\
13119370Spst	     (PREFIX), (NUMBER))
13219370Spst
13319370Spst/* This is how to output an internal numbered label where
13498944Sobrien   PREFIX is the class of label and NUM is the number within the class.  */
13519370Spst#undef	ASM_OUTPUT_INTERNAL_LABEL
13619370Spst#define	ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)			\
13719370Spst  fprintf (FILE, "%s%s%d:\n", (TARGET_UNDERSCORES) ? "" : ".",		\
13819370Spst	   PREFIX, NUM)
13998944Sobrien
14019370Spst/* This is how to output a reference to a user-level label named NAME.  */
141130803Smarcel#undef  ASM_OUTPUT_LABELREF
14219370Spst#define ASM_OUTPUT_LABELREF(FILE,NAME)					\
14398944Sobrien  fprintf (FILE, "%s%s", (TARGET_UNDERSCORES) ? "_" : "", NAME)
14419370Spst
145130803Smarcel
14698944Sobrien/* This is how to output an element of a case-vector that is relative.
14798944Sobrien   This is only used for PIC code.  See comments by the `casesi' insn in
14819370Spst   i386.md for an explanation of the expression this outputs. */
149130803Smarcel#undef ASM_OUTPUT_ADDR_DIFF_ELT
15019370Spst#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
15119370Spst  fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
15219370Spst
15319370Spst#undef ASM_OUTPUT_ALIGN
154130803Smarcel#define ASM_OUTPUT_ALIGN(FILE,LOG)      				\
155130803Smarcel  if ((LOG)!=0) {							\
15619370Spst    if (in_text_section())						\
15719370Spst      fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG));			\
15898944Sobrien    else								\
159130803Smarcel      fprintf ((FILE), "\t.p2align %d\n", (LOG));			\
16098944Sobrien  }
16198944Sobrien
16298944Sobrien/* conditionalize the use of ".section rodata" on elf mode - otherwise .text */
16398944Sobrien#undef USE_CONST_SECTION
164130803Smarcel#define USE_CONST_SECTION	TARGET_ELF
16519370Spst
16619370Spst/* The a.out tools do not support "linkonce" sections. */
16719370Spst#define SUPPORTS_ONE_ONLY	TARGET_ELF
16898944Sobrien
16919370Spst/* The a.out tools do not support "Lscope" .stabs symbols. */
17019370Spst#define NO_DBX_FUNCTION_END	TARGET_AOUT
17119370Spst
17219370Spst/* A C statement (sans semicolon) to output an element in the table of
17319370Spst   global constructors.  */
17498944Sobrien#undef ASM_OUTPUT_CONSTRUCTOR
17598944Sobrien#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)				\
176130803Smarcel  do {									\
17798944Sobrien    if (TARGET_ELF) {							\
17819370Spst      ctors_section ();							\
17919370Spst      fprintf (FILE, "\t%s\t ", INT_ASM_OP);				\
18019370Spst      assemble_name (FILE, NAME);					\
18119370Spst      fprintf (FILE, "\n");						\
18298944Sobrien    } else {								\
18319370Spst      fprintf (asm_out_file, "%s \"%s__CTOR_LIST__\",22,0,0,", ASM_STABS_OP, \
18419370Spst	       (TARGET_UNDERSCORES) ? "_" : "");			\
185130803Smarcel      assemble_name (asm_out_file, name);				\
186130803Smarcel      fputc ('\n', asm_out_file);					\
187130803Smarcel    }									\
18819370Spst  } while (0)
18919370Spst
19019370Spst/* A C statement (sans semicolon) to output an element in the table of
19198944Sobrien   global destructors.  */
19298944Sobrien#undef ASM_OUTPUT_DESTRUCTOR
19398944Sobrien#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)				\
19498944Sobrien  do {									\
19598944Sobrien    if (TARGET_ELF) {							\
19698944Sobrien      dtors_section ();							\
19798944Sobrien      fprintf (FILE, "\t%s\t ", INT_ASM_OP);				\
19898944Sobrien      assemble_name (FILE, NAME);					\
19998944Sobrien      fprintf (FILE, "\n");						\
20098944Sobrien    } else {								\
20198944Sobrien      fprintf (asm_out_file, "%s \"%s__DTOR_LIST__\",22,0,0,", ASM_STABS_OP, \
20298944Sobrien	       (TARGET_UNDERSCORES) ? "_" : "");			\
20398944Sobrien      assemble_name (asm_out_file, name);				\
20498944Sobrien      fputc ('\n', asm_out_file);					\
20598944Sobrien    }									\
20698944Sobrien  } while (0)
20798944Sobrien
208130803Smarcel/* This says how to output assembler code to declare an
209130803Smarcel   uninitialized internal linkage data object.  Under SVR4,
210130803Smarcel   the linker seems to want the alignment of data objects
211130803Smarcel   to depend on their types.  We do exactly that here.  */
212130803Smarcel
213130803Smarcel#undef ASM_OUTPUT_ALIGNED_LOCAL
214130803Smarcel#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)		\
215130803Smarceldo {									\
216130803Smarcel  if (TARGET_ELF) {							\
217130803Smarcel    fprintf ((FILE), "\t%s\t", LOCAL_ASM_OP);				\
218130803Smarcel    assemble_name ((FILE), (NAME));					\
219130803Smarcel    fprintf ((FILE), "\n");						\
220130803Smarcel    ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);		\
221130803Smarcel  } else {								\
222130803Smarcel    int rounded = (SIZE);						\
223130803Smarcel    if (rounded == 0) rounded = 1;					\
224130803Smarcel    rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;			\
225130803Smarcel    rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)		\
226130803Smarcel			   * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));	\
227130803Smarcel    fputs (".lcomm ", (FILE));						\
228130803Smarcel    assemble_name ((FILE), (NAME));					\
229130803Smarcel    fprintf ((FILE), ",%u\n", (rounded));				\
23098944Sobrien  }									\
23198944Sobrien} while (0)
23298944Sobrien
233130803Smarcel#undef ASM_OUTPUT_ALIGNED_COMMON
234130803Smarcel#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
23598944Sobriendo {									\
236130803Smarcel  if (TARGET_ELF) {							\
237130803Smarcel    fprintf ((FILE), "\t%s\t", COMMON_ASM_OP);				\
238130803Smarcel    assemble_name ((FILE), (NAME));					\
23998944Sobrien    fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);	\
24019370Spst  } else {								\
24119370Spst    int rounded = (SIZE);						\
24219370Spst    if (rounded == 0) rounded = 1;					\
24398944Sobrien    rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;			\
24498944Sobrien    rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)		\
24519370Spst			   * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));	\
24619370Spst    fputs (".comm ", (FILE));						\
24719370Spst    assemble_name ((FILE), (NAME));					\
24819370Spst    fprintf ((FILE), ",%u\n", (rounded));				\
24998944Sobrien  }									\
25019370Spst} while (0)
25198944Sobrien
25219370Spst/* Turn off svr4.h version, it chokes the old gas.  The old layout
25398944Sobrien   works fine under new gas anyway. */
25419370Spst#undef ASM_OUTPUT_ASCII
25519370Spst
25619370Spst/* How to output some space */
25798944Sobrien#undef ASM_OUTPUT_SKIP
25819370Spst#define ASM_OUTPUT_SKIP(FILE,SIZE) 					\
25919370Spstdo {									\
26098944Sobrien  if (TARGET_ELF) {							\
26119370Spst    fprintf (FILE, "\t%s\t%u\n", SKIP_ASM_OP, (SIZE));			\
26298944Sobrien  } else {								\
26319370Spst    fprintf (FILE, "\t.space %u\n", (SIZE));				\
26419370Spst  }									\
26598944Sobrien} while (0)
26698944Sobrien
26719370Spst#undef ASM_OUTPUT_SOURCE_LINE
26898944Sobrien#define ASM_OUTPUT_SOURCE_LINE(file, line)				\
26919370Spstdo {									\
27019370Spst  static int sym_lineno = 1;						\
27119370Spst  if (TARGET_ELF) {							\
27219370Spst    fprintf (file, ".stabn 68,0,%d,.LM%d-", line, sym_lineno);		\
27319370Spst    assemble_name (file, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
27419370Spst    fprintf (file, "\n.LM%d:\n", sym_lineno);				\
27519370Spst    sym_lineno += 1;							\
27619370Spst  } else {								\
27798944Sobrien    fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);	\
27819370Spst  }									\
27919370Spst} while (0)
28098944Sobrien
28119370Spst#undef DEFAULT_VTABLE_THUNKS
28219370Spst#define DEFAULT_VTABLE_THUNKS 1
28319370Spst
28498944Sobrien/* This is BSD, so we want the DBX format.  */
28598944Sobrien#define DBX_DEBUGGING_INFO
28619370Spst
28798944Sobrien/* Use stabs instead of DWARF debug format.  */
28819370Spst#undef PREFERRED_DEBUGGING_TYPE
28919370Spst#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
29019370Spst
29119370Spst/* in elf, the function stabs come first, before the relative offsets */
29219370Spst#undef DBX_FUNCTION_FIRST
29319370Spst#define DBX_CHECK_FUNCTION_FIRST TARGET_ELF
29419370Spst
29519370Spst/* tag end of file in elf mode */
29619370Spst#undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
29719370Spst#define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME)			\
29898944Sobriendo {									\
29998944Sobrien  if (TARGET_ELF) {							\
30098944Sobrien    fprintf (FILE, "\t.text\n\t.stabs \"\",%d,0,0,.Letext\n.Letext:\n", N_SO); \
30119370Spst  }									\
30219370Spst} while (0)
30319370Spst
30419370Spst/* stabs-in-elf has offsets relative to function beginning */
30598944Sobrien#undef DBX_OUTPUT_LBRAC
30698944Sobrien#define DBX_OUTPUT_LBRAC(file,name)					\
30798944Sobriendo {									\
30819370Spst  fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);		\
30919370Spst  assemble_name (asmfile, buf);						\
31019370Spst  if (TARGET_ELF) {							\
31119370Spst    fputc ('-', asmfile);						\
31298944Sobrien    assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
313130803Smarcel  }									\
31419370Spst  fprintf (asmfile, "\n");						\
31598944Sobrien} while (0)
31619370Spst
31798944Sobrien#undef DBX_OUTPUT_RBRAC
31898944Sobrien#define DBX_OUTPUT_RBRAC(file,name)					\
31998944Sobriendo {									\
32098944Sobrien  fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);		\
32198944Sobrien  assemble_name (asmfile, buf);						\
32298944Sobrien  if (TARGET_ELF) {							\
32398944Sobrien    fputc ('-', asmfile);						\
32498944Sobrien    assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
32598944Sobrien  }									\
32698944Sobrien  fprintf (asmfile, "\n");						\
32798944Sobrien} while (0)
32898944Sobrien
32998944Sobrien
33098944Sobrien/* Define macro used to output shift-double opcodes when the shift
33198944Sobrien   count is in %cl.  Some assemblers require %cl as an argument;
33298944Sobrien   some don't.
33398944Sobrien
33498944Sobrien   *OLD* GAS requires the %cl argument, so override i386/unix.h. */
33598944Sobrien
33698944Sobrien#undef AS3_SHIFT_DOUBLE
33798944Sobrien#define AS3_SHIFT_DOUBLE(a,b,c,d) AS3 (a,b,c,d)
33898944Sobrien
33998944Sobrien/* Indicate that jump tables go in the text section.  This is
34098944Sobrien   necessary when compiling PIC code.  */
34198944Sobrien#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
34298944Sobrien
34398944Sobrien/* override the exception table positioning */
34498944Sobrien#define EXCEPTION_SECTION() \
34598944Sobriendo {									\
34698944Sobrien  if (TARGET_ELF) {							\
34719370Spst    named_section (NULL_TREE, ".gcc_except_table", 0);			\
34846283Sdfr  } else {								\
34946283Sdfr    if (flag_pic)							\
350130803Smarcel      data_section ();							\
35146283Sdfr    else								\
35246283Sdfr      readonly_data_section ();						\
35346283Sdfr  }									\
35446283Sdfr} while (0);
35519370Spst
35619370Spst/* supply our own hook for calling __main() from main() */
35719370Spst#define GEN_CALL__MAIN \
35819370Spst  do {									\
35919370Spst    if (!(TARGET_ELF))							\
36019370Spst      emit_library_call (gen_rtx (SYMBOL_REF, Pmode, NAME__MAIN), 0,	\
36119370Spst			 VOIDmode, 0);					\
36219370Spst  } while (0)
36319370Spst
36419370Spst/* Copy this from the svr4 specifications... */
36598944Sobrien/* Define the register numbers to be used in Dwarf debugging information.
36619370Spst   The SVR4 reference port C compiler uses the following register numbers
36719370Spst   in its Dwarf output code:
36898944Sobrien	0 for %eax (gnu regno = 0)
36919370Spst	1 for %ecx (gnu regno = 2)
37019370Spst	2 for %edx (gnu regno = 1)
37119370Spst	3 for %ebx (gnu regno = 3)
37219370Spst	4 for %esp (gnu regno = 7)
37319370Spst	5 for %ebp (gnu regno = 6)
37498944Sobrien	6 for %esi (gnu regno = 4)
37598944Sobrien	7 for %edi (gnu regno = 5)
37619370Spst   The following three DWARF register numbers are never generated by
37719370Spst   the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
37819370Spst   believes these numbers have these meanings.
37919370Spst	8  for %eip    (no gnu equivalent)
38098944Sobrien	9  for %eflags (no gnu equivalent)
38119370Spst	10 for %trapno (no gnu equivalent)
38298944Sobrien   It is not at all clear how we should number the FP stack registers
38319370Spst   for the x86 architecture.  If the version of SDB on x86/svr4 were
38419370Spst   a bit less brain dead with respect to floating-point then we would
38598944Sobrien   have a precedent to follow with respect to DWARF register numbers
38698944Sobrien   for x86 FP registers, but the SDB on x86/svr4 is so completely
38719370Spst   broken with respect to FP registers that it is hardly worth thinking
38819370Spst   of it as something to strive for compatibility with.
38998944Sobrien   The version of x86/svr4 SDB I have at the moment does (partially)
39019370Spst   seem to believe that DWARF register number 11 is associated with
39119370Spst   the x86 register %st(0), but that's about all.  Higher DWARF
39298944Sobrien   register numbers don't seem to be associated with anything in
39398944Sobrien   particular, and even for DWARF regno 11, SDB only seems to under-
39419370Spst   stand that it should say that a variable lives in %st(0) (when
395130803Smarcel   asked via an `=' command) if we said it was in DWARF regno 11,
39619370Spst   but SDB still prints garbage when asked for the value of the
39719370Spst   variable in question (via a `/' command).
39819370Spst   (Also note that the labels SDB prints for various FP stack regs
39919370Spst   when doing an `x' command are all wrong.)
40019370Spst   Note that these problems generally don't affect the native SVR4
40119370Spst   C compiler because it doesn't allow the use of -O with -g and
40219370Spst   because when it is *not* optimizing, it allocates a memory
40319370Spst   location for each floating-point variable, and the memory
40419370Spst   location is what gets described in the DWARF AT_location
40519370Spst   attribute for the variable in question.
40619370Spst   Regardless of the severe mental illness of the x86/svr4 SDB, we
40719370Spst   do something sensible here and we use the following DWARF
40819370Spst   register numbers.  Note that these are all stack-top-relative
40919370Spst   numbers.
41019370Spst	11 for %st(0) (gnu regno = 8)
41119370Spst	12 for %st(1) (gnu regno = 9)
41219370Spst	13 for %st(2) (gnu regno = 10)
41319370Spst	14 for %st(3) (gnu regno = 11)
41419370Spst	15 for %st(4) (gnu regno = 12)
41519370Spst	16 for %st(5) (gnu regno = 13)
41619370Spst	17 for %st(6) (gnu regno = 14)
41798944Sobrien	18 for %st(7) (gnu regno = 15)
41898944Sobrien*/
41919370Spst#undef DWARF_DBX_REGISTER_NUMBER
42019370Spst#define DWARF_DBX_REGISTER_NUMBER(n) \
42198944Sobrien((n) == 0 ? 0 \
42219370Spst : (n) == 1 ? 2 \
42398944Sobrien : (n) == 2 ? 1 \
42419370Spst : (n) == 3 ? 3 \
42598944Sobrien : (n) == 4 ? 6 \
42619370Spst : (n) == 5 ? 7 \
42798944Sobrien : (n) == 6 ? 5 \
42898944Sobrien : (n) == 7 ? 4 \
42998944Sobrien : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
43019370Spst : (-1))
43198944Sobrien
43219370Spst/* Now what stabs expects in the register.  */
43398944Sobrien#define STABS_DBX_REGISTER_NUMBER(n) \
43498944Sobrien((n) == 0 ? 0 : \
43598944Sobrien (n) == 1 ? 2 : \
43619370Spst (n) == 2 ? 1 : \
43719370Spst (n) == 3 ? 3 : \
43819370Spst (n) == 4 ? 6 : \
43919370Spst (n) == 5 ? 7 : \
44098944Sobrien (n) == 6 ? 4 : \
44198944Sobrien (n) == 7 ? 5 : \
44298944Sobrien (n) + 4)
44319370Spst
444130803Smarcel#undef  DBX_REGISTER_NUMBER
445130803Smarcel#define DBX_REGISTER_NUMBER(n)	((write_symbols == DWARF_DEBUG)	\
44619370Spst				? DWARF_DBX_REGISTER_NUMBER(n)	\
447130803Smarcel				: STABS_DBX_REGISTER_NUMBER(n))
44819370Spst
44998944Sobrien/* Tell final.c that we don't need a label passed to mcount.  */
450130803Smarcel#define NO_PROFILE_DATA
45119370Spst
45219370Spst/* Output assembler code to FILE to increment profiler label # LABELNO
45319370Spst   for profiling a function entry.  */
45446283Sdfr/* Redefine this to not pass an unused label in %edx.  */
45546283Sdfr
45646283Sdfr#undef FUNCTION_PROFILER
45719370Spst#define FUNCTION_PROFILER(FILE, LABELNO)  \
45898944Sobrien{									\
45919370Spst  if (flag_pic)								\
46046283Sdfr    {									\
46119370Spst      fprintf (FILE, "\tcall *%s@GOT(%%ebx)\n",				\
46219370Spst      TARGET_AOUT ? "mcount" : ".mcount");				\
46319370Spst    }									\
46419370Spst  else									\
46519370Spst    {									\
46619370Spst      fprintf (FILE, "\tcall %s\n", TARGET_AOUT ? "mcount" : ".mcount");	\
46719370Spst    }									\
46819370Spst}
46919370Spst
47019370Spst#define FUNCTION_PROFILER_EPILOGUE(FILE)  \
47119370Spst{									\
47219370Spst  if (TARGET_PROFILER_EPILOGUE)						\
47319370Spst    {									\
47419370Spst      if (flag_pic)							\
47546283Sdfr	fprintf (FILE, "\tcall *%s@GOT(%%ebx)\n",			\
47646283Sdfr	  TARGET_AOUT ? "mexitcount" : ".mexitcount");			\
47798944Sobrien      else								\
47819370Spst	fprintf (FILE, "\tcall %s\n",					\
47946283Sdfr	  TARGET_AOUT ? "mexitcount" : ".mexitcount");			\
48046283Sdfr    }									\
48146283Sdfr}
48246283Sdfr
48319370Spst#undef SIZE_TYPE
48446283Sdfr#define SIZE_TYPE "unsigned int"
48546283Sdfr
48646283Sdfr#undef PTRDIFF_TYPE
48746283Sdfr#define PTRDIFF_TYPE "int"
48898944Sobrien
48946283Sdfr#undef WCHAR_TYPE
49019370Spst#define WCHAR_TYPE "int"
49146283Sdfr
49298944Sobrien#define WCHAR_UNSIGNED 0
49319370Spst
494130803Smarcel#undef WCHAR_TYPE_SIZE
495130803Smarcel#define WCHAR_TYPE_SIZE BITS_PER_WORD
496130803Smarcel
497130803Smarcel#undef CPP_PREDEFINES
498130803Smarcel#define CPP_PREDEFINES "-Di386 -Dunix -D__FreeBSD__=4 -D__FreeBSD_cc_version=400002 -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)"
49946283Sdfr
50046283Sdfr#undef CPP_SPEC
50146283Sdfr#if TARGET_CPU_DEFAULT == 2
50246283Sdfr#define CPP_SPEC "\
50346283Sdfr%{!maout: -D__ELF__} \
504130803Smarcel%{munderscores: -D__UNDERSCORES__} \
50546283Sdfr%{maout: %{!mno-underscores: -D__UNDERSCORES__}} \
50646283Sdfr%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__}"
50746283Sdfr#else
50898944Sobrien#define CPP_SPEC "\
50946283Sdfr%{!maout: -D__ELF__} \
51046283Sdfr%{munderscores: -D__UNDERSCORES__} \
51198944Sobrien%{maout: %{!mno-underscores: -D__UNDERSCORES__}} \
51298944Sobrien%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m486:-D__i486__}"
51346283Sdfr#endif
514130803Smarcel
515130803Smarcel#undef CC1_SPEC
516130803Smarcel#define CC1_SPEC "\
51746283Sdfr%{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \
51846283Sdfr%{maout: %{!mno-underscores: %{!munderscores: -munderscores }}}"
51998944Sobrien
52046283Sdfr#undef  ASM_SPEC
52146283Sdfr#define ASM_SPEC	"%{v*: -v} %{maout: %{fpic:-k} %{fPIC:-k}}"
52246283Sdfr
52346283Sdfr/* Like the default, except no -lg, and no -p.  */
52446283Sdfr#undef LIB_SPEC
52519370Spst#define LIB_SPEC "%{!shared:%{!pg:%{!pthread:%{!kthread:-lc}%{kthread:-lpthread -lc}}%{pthread:-lc_r}}%{pg:%{!pthread:%{!kthread:-lc_p}%{kthread:-lpthread_p -lc_p}}%{pthread:-lc_r_p}}}"
52619370Spst
52719370Spst/* Let gcc locate this for us according to the -m rules */
52846283Sdfr#undef  LIBGCC_SPEC
52946283Sdfr#define LIBGCC_SPEC "%{!shared:libgcc.a%s}"
53046283Sdfr
53146283Sdfr/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
53219370Spst   for the special GCC options -static and -shared, which allow us to
53319370Spst   link things in one of these three modes by applying the appropriate
53419370Spst   combinations of options at link-time. We like to support here for
53598944Sobrien   as many of the other GNU linker options as possible. But I don't
53619370Spst   have the time to search for those flags. I am sure how to add
53719370Spst   support for -soname shared_object_name. H.J.
53898944Sobrien
53919370Spst   I took out %{v:%{!V:-V}}. It is too much :-(. They can use
54019370Spst   -Wl,-V.
54119370Spst
54219370Spst   When the -shared link option is used a final link is not being
54319370Spst   done.  */
54419370Spst
54519370Spst#undef	LINK_SPEC
54619370Spst#define LINK_SPEC "\
54719370Spst %{p:%e`-p' not supported; use `-pg' and gprof(1)} \
54819370Spst  %{maout: %{shared:-Bshareable} \
54919370Spst    %{!shared:%{!nostdlib:%{!r:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} \
55019370Spst      %{pg:-Bstatic} %{Z}} \
55119370Spst    %{assert*} %{R*}} \
55219370Spst  %{!maout: \
55319370Spst    -m elf_i386 \
55419370Spst    %{Wl,*:%*} \
55519370Spst    %{assert*} %{R*} %{rpath*} %{defsym*} \
55698944Sobrien    %{shared:-Bshareable %{h*} %{soname*}} \
55719370Spst    %{symbolic:-Bsymbolic} \
55819370Spst    %{!shared: \
55919370Spst      %{!static: \
56019370Spst	%{rdynamic: -export-dynamic} \
56119370Spst	%{!dynamic-linker: -dynamic-linker /usr/libexec/ld-elf.so.1}} \
56219370Spst      %{static:-Bstatic}}}"
56319370Spst
56419370Spst/* A C statement to output to the stdio stream FILE an assembler
56519370Spst   command to advance the location counter to a multiple of 1<<LOG
56619370Spst   bytes if it is within MAX_SKIP bytes.
56719370Spst
56819370Spst   This is used to align code labels according to Intel recommendations.  */
56998944Sobrien
57098944Sobrien#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
57119370Spst#error "we don't have this for the aout gas"
57219370Spst#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
57319370Spst  if ((LOG)!=0) \
57498944Sobrien    if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
57519370Spst    else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP))
57619370Spst#endif
57719370Spst
578130803Smarcel#undef STARTFILE_SPEC
57998944Sobrien#define STARTFILE_SPEC "\
58019370Spst  %{maout: %{shared:c++rt0.o%s} \
58119370Spst    %{!shared:%{pg:gcrt0.o%s}%{!pg:%{static:scrt0.o%s}%{!static:crt0.o%s}}}} \
58219370Spst  %{!maout:  %{!shared: \
58319370Spst    %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} \
58419370Spst    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
58519370Spst
58619370Spst#undef  ENDFILE_SPEC
58719370Spst#define ENDFILE_SPEC \
58819370Spst  "%{!maout: %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s}"
58919370Spst
590130803Smarcel/* This goes away when the math emulator is fixed.  */
59119370Spst#undef TARGET_DEFAULT
59298944Sobrien#define TARGET_DEFAULT	(MASK_NO_FANCY_MATH_387 | 0301)
59398944Sobrien
59498944Sobrien#define HAVE_ATEXIT
59519370Spst
59619370Spst/* FreeBSD ELF using our home-grown crtbegin.o/crtend.o does not support the
597130803Smarcel   DWARF2 unwinding mechanisms.  Once `make world' bootstraping problems with
59819370Spst   the EGCS crtstuff.c is overcome, we will switch to the non-sjlj-exceptions
599130803Smarcel   type exception machanism.  */
60019370Spst#define DWARF2_UNWIND_INFO 0
60146283Sdfr