Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / gcc / config / i386 / freebsd-aout.h
1 /* Definitions of target machine for GNU compiler for Intel 80386
2    running FreeBSD.
3    Copyright (C) 1988, 1992, 1994, 1996, 1997 Free Software Foundation, Inc.
4    Contributed by Poul-Henning Kamp <phk@login.dkuug.dk>
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, 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 goes away when the math-emulator is fixed */
35 #undef TARGET_DEFAULT
36 #define TARGET_DEFAULT \
37   (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
38
39 #undef CPP_PREDEFINES
40 #define CPP_PREDEFINES "-Dunix -Di386 -D__FreeBSD__ -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)"
41
42 /* Like the default, except no -lg.  */
43 #define LIB_SPEC "%{!shared:%{!pg:-lc}%{pg:-lc_p}}"
44
45 #undef SIZE_TYPE
46 #define SIZE_TYPE "unsigned int"
47
48 #undef PTRDIFF_TYPE
49 #define PTRDIFF_TYPE "int"
50
51 #undef WCHAR_TYPE
52 #define WCHAR_TYPE "int"
53
54 #define WCHAR_UNSIGNED 0
55
56 #undef WCHAR_TYPE_SIZE
57 #define WCHAR_TYPE_SIZE BITS_PER_WORD
58
59 #define HAVE_ATEXIT
60
61 /* Override the default comment-starter of "/".  */
62
63 #undef ASM_COMMENT_START
64 #define ASM_COMMENT_START "#"
65
66 #undef ASM_APP_ON
67 #define ASM_APP_ON "#APP\n"
68
69 #undef ASM_APP_OFF
70 #define ASM_APP_OFF "#NO_APP\n"
71
72 /* FreeBSD using a.out does not support DWARF2 unwinding mechanisms.  */
73 #define DWARF2_UNWIND_INFO 0
74 \f
75 /* The following macros are stolen from i386v4.h */
76 /* These have to be defined to get PIC code correct */
77
78 /* This is how to output an element of a case-vector that is relative.
79    This is only used for PIC code.  See comments by the `casesi' insn in
80    i386.md for an explanation of the expression this outputs. */
81
82 #undef ASM_OUTPUT_ADDR_DIFF_ELT
83 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
84   fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
85
86 /* Indicate that jump tables go in the text section.  This is
87    necessary when compiling PIC code.  */
88
89 #define JUMP_TABLES_IN_TEXT_SECTION 1
90
91 /* Don't default to pcc-struct-return, because in FreeBSD we prefer the
92    superior nature of the older gcc way.  */
93 #define DEFAULT_PCC_STRUCT_RETURN 0
94
95 /* Ensure we the configuration knows our system correctly so we can link with
96    libraries compiled with the native cc. */
97 #undef NO_DOLLAR_IN_LABEL
98 \f
99 /* i386 freebsd still uses old binutils that don't insert nops by default
100    when the .align directive demands to insert extra space in the text
101    segment.  */
102 #undef ASM_OUTPUT_ALIGN
103 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
104   if ((LOG)!=0) fprintf ((FILE), "\t.align %d,0x90\n", (LOG))
105 \f
106 /* Profiling routines, partially copied from i386/osfrose.h.  */
107
108 /* Redefine this to use %eax instead of %edx.  */
109 #undef FUNCTION_PROFILER
110 #define FUNCTION_PROFILER(FILE, LABELNO)  \
111 {                                                                       \
112   if (flag_pic)                                                         \
113     {                                                                   \
114       fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n",              \
115                LPREFIX, (LABELNO));                                     \
116       fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");                    \
117     }                                                                   \
118   else                                                                  \
119     {                                                                   \
120       fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO));      \
121       fprintf (FILE, "\tcall mcount\n");                                \
122     }                                                                   \
123 }
124
125 /*
126  * Some imports from svr4.h in support of shared libraries.
127  * Currently, we need the DECLARE_OBJECT_SIZE stuff.
128  */
129
130 /* Define the strings used for the special svr4 .type and .size directives.
131    These strings generally do not vary from one system running svr4 to
132    another, but if a given system (e.g. m88k running svr) needs to use
133    different pseudo-op names for these, they may be overridden in the
134    file which includes this one.  */
135
136 #define TYPE_ASM_OP     ".type"
137 #define SIZE_ASM_OP     ".size"
138
139 /* The following macro defines the format used to output the second
140    operand of the .type assembler directive.  Different svr4 assemblers
141    expect various different forms for this operand.  The one given here
142    is just a default.  You may need to override it in your machine-
143    specific tm.h file (depending upon the particulars of your assembler).  */
144
145 #define TYPE_OPERAND_FMT        "@%s"
146
147 /* Write the extra assembler code needed to declare a function's result.
148    Most svr4 assemblers don't require any special declaration of the
149    result value, but there are exceptions.  */
150
151 #ifndef ASM_DECLARE_RESULT
152 #define ASM_DECLARE_RESULT(FILE, RESULT)
153 #endif
154
155 /* These macros generate the special .type and .size directives which
156    are used to set the corresponding fields of the linker symbol table
157    entries in an ELF object file under SVR4.  These macros also output
158    the starting labels for the relevant functions/objects.  */
159
160 /* Write the extra assembler code needed to declare a function properly.
161    Some svr4 assemblers need to also have something extra said about the
162    function's return value.  We allow for that here.  */
163
164 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
165   do {                                                                  \
166     fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);                             \
167     assemble_name (FILE, NAME);                                         \
168     putc (',', FILE);                                                   \
169     fprintf (FILE, TYPE_OPERAND_FMT, "function");                       \
170     putc ('\n', FILE);                                                  \
171     ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                      \
172     ASM_OUTPUT_LABEL(FILE, NAME);                                       \
173   } while (0)
174
175 /* Write the extra assembler code needed to declare an object properly.  */
176
177 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
178   do {                                                                  \
179     fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);                             \
180     assemble_name (FILE, NAME);                                         \
181     putc (',', FILE);                                                   \
182     fprintf (FILE, TYPE_OPERAND_FMT, "object");                         \
183     putc ('\n', FILE);                                                  \
184     size_directive_output = 0;                                          \
185     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))               \
186       {                                                                 \
187         size_directive_output = 1;                                      \
188         fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                         \
189         assemble_name (FILE, NAME);                                     \
190         fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
191       }                                                                 \
192     ASM_OUTPUT_LABEL(FILE, NAME);                                       \
193   } while (0)
194
195 /* Output the size directive for a decl in rest_of_decl_compilation
196    in the case where we did not do so before the initializer.
197    Once we find the error_mark_node, we know that the value of
198    size_directive_output was set
199    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
200
201 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)        \
202 do {                                                                    \
203      char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);                  \
204      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)               \
205          && ! AT_END && TOP_LEVEL                                       \
206          && DECL_INITIAL (DECL) == error_mark_node                      \
207          && !size_directive_output)                                     \
208        {                                                                \
209          fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                        \
210          assemble_name (FILE, name);                                    \
211          fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL)));\
212         }                                                               \
213    } while (0)
214
215
216 /* This is how to declare the size of a function.  */
217
218 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
219   do {                                                                  \
220     if (!flag_inhibit_size_directive)                                   \
221       {                                                                 \
222         char label[256];                                                \
223         static int labelno;                                             \
224         labelno++;                                                      \
225         ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);            \
226         ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);               \
227         fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                         \
228         assemble_name (FILE, (FNAME));                                  \
229         fprintf (FILE, ",");                                            \
230         assemble_name (FILE, label);                                    \
231         fprintf (FILE, "-");                                            \
232         assemble_name (FILE, (FNAME));                                  \
233         putc ('\n', FILE);                                              \
234       }                                                                 \
235   } while (0)
236
237 #define ASM_SPEC   " %| %{fpic:-k} %{fPIC:-k}"
238 #define LINK_SPEC \
239   "%{p:%e`-p' not supported; use `-pg' and gprof(1)} \
240    %{shared:-Bshareable} \
241    %{!shared:%{!nostdlib:%{!r:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} \
242    %{pg:-Bstatic} %{Z}} \
243    %{assert*} %{R*}"
244
245 #define STARTFILE_SPEC  \
246   "%{shared:c++rt0.o%s} \
247    %{!shared:%{pg:gcrt0.o%s}%{!pg:%{static:scrt0.o%s}%{!static:crt0.o%s}}}"