1 /* Definitions for Intel 386 running FreeBSD with ELF format
2 Copyright (C) 1996 Free Software Foundation, Inc.
3 Contributed by Eric Youngdale.
4 Modified for stabs-in-ELF by H.J. Lu.
5 Adapted from GNU/Linux version by John Polstra.
6 Continued development by David O'Brien <obrien@freebsd.org>
8 This file is part of GNU CC.
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
26 #define TARGET_VERSION fprintf (stderr, " (i386 FreeBSD/ELF)");
28 /* Override the default comment-starter of "/". */
29 #undef ASM_COMMENT_START
30 #define ASM_COMMENT_START "#"
33 #define ASM_APP_ON "#APP\n"
36 #define ASM_APP_OFF "#NO_APP\n"
39 #define SET_ASM_OP ".set"
41 /* This is how to output an element of a case-vector that is relative.
42 This is only used for PIC code. See comments by the `casesi' insn in
43 i386.md for an explanation of the expression this outputs. */
44 #undef ASM_OUTPUT_ADDR_DIFF_ELT
45 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
46 fprintf ((FILE), "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
48 /* Indicate that jump tables go in the text section. This is
49 necessary when compiling PIC code. */
50 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
52 /* Copy this from the svr4 specifications... */
53 /* Define the register numbers to be used in Dwarf debugging information.
54 The SVR4 reference port C compiler uses the following register numbers
55 in its Dwarf output code:
56 0 for %eax (gnu regno = 0)
57 1 for %ecx (gnu regno = 2)
58 2 for %edx (gnu regno = 1)
59 3 for %ebx (gnu regno = 3)
60 4 for %esp (gnu regno = 7)
61 5 for %ebp (gnu regno = 6)
62 6 for %esi (gnu regno = 4)
63 7 for %edi (gnu regno = 5)
64 The following three DWARF register numbers are never generated by
65 the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
66 believes these numbers have these meanings.
67 8 for %eip (no gnu equivalent)
68 9 for %eflags (no gnu equivalent)
69 10 for %trapno (no gnu equivalent)
70 It is not at all clear how we should number the FP stack registers
71 for the x86 architecture. If the version of SDB on x86/svr4 were
72 a bit less brain dead with respect to floating-point then we would
73 have a precedent to follow with respect to DWARF register numbers
74 for x86 FP registers, but the SDB on x86/svr4 is so completely
75 broken with respect to FP registers that it is hardly worth thinking
76 of it as something to strive for compatibility with.
77 The version of x86/svr4 SDB I have at the moment does (partially)
78 seem to believe that DWARF register number 11 is associated with
79 the x86 register %st(0), but that's about all. Higher DWARF
80 register numbers don't seem to be associated with anything in
81 particular, and even for DWARF regno 11, SDB only seems to under-
82 stand that it should say that a variable lives in %st(0) (when
83 asked via an `=' command) if we said it was in DWARF regno 11,
84 but SDB still prints garbage when asked for the value of the
85 variable in question (via a `/' command).
86 (Also note that the labels SDB prints for various FP stack regs
87 when doing an `x' command are all wrong.)
88 Note that these problems generally don't affect the native SVR4
89 C compiler because it doesn't allow the use of -O with -g and
90 because when it is *not* optimizing, it allocates a memory
91 location for each floating-point variable, and the memory
92 location is what gets described in the DWARF AT_location
93 attribute for the variable in question.
94 Regardless of the severe mental illness of the x86/svr4 SDB, we
95 do something sensible here and we use the following DWARF
96 register numbers. Note that these are all stack-top-relative
98 11 for %st(0) (gnu regno = 8)
99 12 for %st(1) (gnu regno = 9)
100 13 for %st(2) (gnu regno = 10)
101 14 for %st(3) (gnu regno = 11)
102 15 for %st(4) (gnu regno = 12)
103 16 for %st(5) (gnu regno = 13)
104 17 for %st(6) (gnu regno = 14)
105 18 for %st(7) (gnu regno = 15)
107 #undef DBX_REGISTER_NUMBER
108 #define DBX_REGISTER_NUMBER(n) \
117 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
120 /* Tell final.c that we don't need a label passed to mcount. */
122 #undef FUNCTION_PROFILER
123 #define FUNCTION_PROFILER(FILE, LABELNO) \
126 fprintf ((FILE), "\tcall *.mcount@GOT(%%ebx)\n"); \
128 fprintf ((FILE), "\tcall .mcount\n"); \
131 /* Make gcc agree with <machine/ansi.h>. */
134 #define SIZE_TYPE "unsigned int"
137 #define PTRDIFF_TYPE "int"
139 #undef WCHAR_TYPE_SIZE
140 #define WCHAR_TYPE_SIZE BITS_PER_WORD
142 #undef CPP_PREDEFINES
143 #define CPP_PREDEFINES "-Di386 -Dunix -D__ELF__ -D__FreeBSD__ -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)"
145 /* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add
146 the magical crtbegin.o file (see crtstuff.c) which provides part
147 of the support for getting C++ file-scope static object constructed
148 before entering `main'. */
150 #undef STARTFILE_SPEC
151 #define STARTFILE_SPEC \
153 %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
154 %{!p:%{profile:gcrt1.o%s} \
155 %{!profile:crt1.o%s}}}} \
156 crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
158 /* Provide a ENDFILE_SPEC appropriate for FreeBSD. Here we tack on
159 the magical crtend.o file (see crtstuff.c) which provides part of
160 the support for getting C++ file-scope static object constructed
161 before entering `main', followed by a normal "finalizer" file,
165 #define ENDFILE_SPEC \
166 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
168 /* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support
169 for the special GCC options -static and -shared, which allow us to
170 link things in one of these three modes by applying the appropriate
171 combinations of options at link-time. We like to support here for
172 as many of the other GNU linker options as possible. But I don't
173 have the time to search for those flags. I am sure how to add
174 support for -soname shared_object_name. H.J.
176 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
179 When the -shared link option is used a final link is not being
183 #define LINK_SPEC "-m elf_i386 \
186 %{assert*} %{R*} %{rpath*} %{defsym*} \
187 %{shared:-Bshareable %{h*} %{soname*}} \
190 %{rdynamic:-export-dynamic} \
191 %{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}} \
192 %{static:-Bstatic}} \
193 %{symbolic:-Bsymbolic}"
195 /* A C statement to output to the stdio stream FILE an assembler
196 command to advance the location counter to a multiple of 1<<LOG
197 bytes if it is within MAX_SKIP bytes.
199 This is used to align code labels according to Intel recommendations. */
201 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
202 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \
204 if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
205 else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \