1 /* Definitions for Intel 386 running Linux with ELF format
2 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
3 Contributed by Eric Youngdale.
4 Modified for stabs-in-ELF by H.J. Lu.
6 This file is part of GNU CC.
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)
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.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
22 #define LINUX_DEFAULT_ELF
24 /* A lie, I guess, but the general idea behind linux/ELF is that we are
25 supposed to be outputting something that will assemble under SVr4.
26 This gets us pretty close. */
27 #include <i386/i386.h> /* Base i386 target machine definitions */
28 #include <i386/att.h> /* Use the i386 AT&T assembler syntax */
29 #include <linux.h> /* some common stuff */
32 #define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)");
34 /* The svr4 ABI for the i386 says that records and unions are returned
36 #undef DEFAULT_PCC_STRUCT_RETURN
37 #define DEFAULT_PCC_STRUCT_RETURN 1
39 /* This is how to output an element of a case-vector that is relative.
40 This is only used for PIC code. See comments by the `casesi' insn in
41 i386.md for an explanation of the expression this outputs. */
42 #undef ASM_OUTPUT_ADDR_DIFF_ELT
43 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
44 fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
46 /* Indicate that jump tables go in the text section. This is
47 necessary when compiling PIC code. */
48 #define JUMP_TABLES_IN_TEXT_SECTION
50 /* Copy this from the svr4 specifications... */
51 /* Define the register numbers to be used in Dwarf debugging information.
52 The SVR4 reference port C compiler uses the following register numbers
53 in its Dwarf output code:
54 0 for %eax (gnu regno = 0)
55 1 for %ecx (gnu regno = 2)
56 2 for %edx (gnu regno = 1)
57 3 for %ebx (gnu regno = 3)
58 4 for %esp (gnu regno = 7)
59 5 for %ebp (gnu regno = 6)
60 6 for %esi (gnu regno = 4)
61 7 for %edi (gnu regno = 5)
62 The following three DWARF register numbers are never generated by
63 the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
64 believes these numbers have these meanings.
65 8 for %eip (no gnu equivalent)
66 9 for %eflags (no gnu equivalent)
67 10 for %trapno (no gnu equivalent)
68 It is not at all clear how we should number the FP stack registers
69 for the x86 architecture. If the version of SDB on x86/svr4 were
70 a bit less brain dead with respect to floating-point then we would
71 have a precedent to follow with respect to DWARF register numbers
72 for x86 FP registers, but the SDB on x86/svr4 is so completely
73 broken with respect to FP registers that it is hardly worth thinking
74 of it as something to strive for compatibility with.
75 The version of x86/svr4 SDB I have at the moment does (partially)
76 seem to believe that DWARF register number 11 is associated with
77 the x86 register %st(0), but that's about all. Higher DWARF
78 register numbers don't seem to be associated with anything in
79 particular, and even for DWARF regno 11, SDB only seems to under-
80 stand that it should say that a variable lives in %st(0) (when
81 asked via an `=' command) if we said it was in DWARF regno 11,
82 but SDB still prints garbage when asked for the value of the
83 variable in question (via a `/' command).
84 (Also note that the labels SDB prints for various FP stack regs
85 when doing an `x' command are all wrong.)
86 Note that these problems generally don't affect the native SVR4
87 C compiler because it doesn't allow the use of -O with -g and
88 because when it is *not* optimizing, it allocates a memory
89 location for each floating-point variable, and the memory
90 location is what gets described in the DWARF AT_location
91 attribute for the variable in question.
92 Regardless of the severe mental illness of the x86/svr4 SDB, we
93 do something sensible here and we use the following DWARF
94 register numbers. Note that these are all stack-top-relative
96 11 for %st(0) (gnu regno = 8)
97 12 for %st(1) (gnu regno = 9)
98 13 for %st(2) (gnu regno = 10)
99 14 for %st(3) (gnu regno = 11)
100 15 for %st(4) (gnu regno = 12)
101 16 for %st(5) (gnu regno = 13)
102 17 for %st(6) (gnu regno = 14)
103 18 for %st(7) (gnu regno = 15)
105 #undef DBX_REGISTER_NUMBER
106 #define DBX_REGISTER_NUMBER(n) \
115 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
118 /* Output assembler code to FILE to increment profiler label # LABELNO
119 for profiling a function entry. */
121 #undef FUNCTION_PROFILER
122 #define FUNCTION_PROFILER(FILE, LABELNO) \
126 fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \
127 LPREFIX, (LABELNO)); \
128 fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \
132 fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \
133 fprintf (FILE, "\tcall mcount\n"); \
138 #define SIZE_TYPE "unsigned int"
141 #define PTRDIFF_TYPE "int"
144 #define WCHAR_TYPE "long int"
146 #undef WCHAR_TYPE_SIZE
147 #define WCHAR_TYPE_SIZE BITS_PER_WORD
149 #undef CPP_PREDEFINES
150 #define CPP_PREDEFINES "-D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)"
153 #if TARGET_CPU_DEFAULT == 2
154 #define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE}"
156 #define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m486:-D__i486__} %{posix:-D_POSIX_SOURCE}"
161 /* We no longer link with libc_p.a or libg.a by default. If you
162 * want to profile or debug the Linux C library, please add
163 * -lc_p or -ggdb to LDFLAGS at the link time, respectively.
166 "%{!shared: %{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} \
167 %{!ggdb:-lc} %{ggdb:-lg}}"
171 %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
172 %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
175 /* Provide a LINK_SPEC appropriate for Linux. Here we provide support
176 for the special GCC options -static and -shared, which allow us to
177 link things in one of these three modes by applying the appropriate
178 combinations of options at link-time. We like to support here for
179 as many of the other GNU linker options as possible. But I don't
180 have the time to search for those flags. I am sure how to add
181 support for -soname shared_object_name. H.J.
183 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
186 When the -shared link option is used a final link is not being
189 /* If ELF is the default format, we should not use /lib/elf. */
192 #ifndef LINUX_DEFAULT_ELF
193 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
197 %{rdynamic:-export-dynamic} \
198 %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \
199 %{!rpath:-rpath /lib/elf/}} %{static:-static}}}"
201 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
205 %{rdynamic:-export-dynamic} \
206 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
210 /* Get perform_* macros to build libgcc.a. */
211 #include "i386/perform.h"