linux.h revision 50397
1/* Definitions for Intel 386 running Linux-based GNU systems with ELF format. 2 Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 3 Contributed by Eric Youngdale. 4 Modified for stabs-in-ELF by H.J. Lu. 5 6This file is part of GNU CC. 7 8GNU CC is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 2, or (at your option) 11any later version. 12 13GNU CC is distributed in the hope that it will be useful, 14but WITHOUT ANY WARRANTY; without even the implied warranty of 15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16GNU General Public License for more details. 17 18You should have received a copy of the GNU General Public License 19along with GNU CC; see the file COPYING. If not, write to 20the Free Software Foundation, 59 Temple Place - Suite 330, 21Boston, MA 02111-1307, USA. */ 22 23#define LINUX_DEFAULT_ELF 24 25/* A lie, I guess, but the general idea behind linux/ELF is that we are 26 supposed to be outputting something that will assemble under SVr4. 27 This gets us pretty close. */ 28#include <i386/i386.h> /* Base i386 target machine definitions */ 29#include <i386/att.h> /* Use the i386 AT&T assembler syntax */ 30#include <linux.h> /* some common stuff */ 31 32#undef TARGET_VERSION 33#define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)"); 34 35/* The svr4 ABI for the i386 says that records and unions are returned 36 in memory. */ 37#undef DEFAULT_PCC_STRUCT_RETURN 38#define DEFAULT_PCC_STRUCT_RETURN 1 39 40#undef ASM_COMMENT_START 41#define ASM_COMMENT_START "#" 42 43/* This is how to output an element of a case-vector that is relative. 44 This is only used for PIC code. See comments by the `casesi' insn in 45 i386.md for an explanation of the expression this outputs. */ 46#undef ASM_OUTPUT_ADDR_DIFF_ELT 47#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ 48 fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) 49 50/* Indicate that jump tables go in the text section. This is 51 necessary when compiling PIC code. */ 52#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic) 53 54/* Copy this from the svr4 specifications... */ 55/* Define the register numbers to be used in Dwarf debugging information. 56 The SVR4 reference port C compiler uses the following register numbers 57 in its Dwarf output code: 58 0 for %eax (gnu regno = 0) 59 1 for %ecx (gnu regno = 2) 60 2 for %edx (gnu regno = 1) 61 3 for %ebx (gnu regno = 3) 62 4 for %esp (gnu regno = 7) 63 5 for %ebp (gnu regno = 6) 64 6 for %esi (gnu regno = 4) 65 7 for %edi (gnu regno = 5) 66 The following three DWARF register numbers are never generated by 67 the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4 68 believes these numbers have these meanings. 69 8 for %eip (no gnu equivalent) 70 9 for %eflags (no gnu equivalent) 71 10 for %trapno (no gnu equivalent) 72 It is not at all clear how we should number the FP stack registers 73 for the x86 architecture. If the version of SDB on x86/svr4 were 74 a bit less brain dead with respect to floating-point then we would 75 have a precedent to follow with respect to DWARF register numbers 76 for x86 FP registers, but the SDB on x86/svr4 is so completely 77 broken with respect to FP registers that it is hardly worth thinking 78 of it as something to strive for compatibility with. 79 The version of x86/svr4 SDB I have at the moment does (partially) 80 seem to believe that DWARF register number 11 is associated with 81 the x86 register %st(0), but that's about all. Higher DWARF 82 register numbers don't seem to be associated with anything in 83 particular, and even for DWARF regno 11, SDB only seems to under- 84 stand that it should say that a variable lives in %st(0) (when 85 asked via an `=' command) if we said it was in DWARF regno 11, 86 but SDB still prints garbage when asked for the value of the 87 variable in question (via a `/' command). 88 (Also note that the labels SDB prints for various FP stack regs 89 when doing an `x' command are all wrong.) 90 Note that these problems generally don't affect the native SVR4 91 C compiler because it doesn't allow the use of -O with -g and 92 because when it is *not* optimizing, it allocates a memory 93 location for each floating-point variable, and the memory 94 location is what gets described in the DWARF AT_location 95 attribute for the variable in question. 96 Regardless of the severe mental illness of the x86/svr4 SDB, we 97 do something sensible here and we use the following DWARF 98 register numbers. Note that these are all stack-top-relative 99 numbers. 100 11 for %st(0) (gnu regno = 8) 101 12 for %st(1) (gnu regno = 9) 102 13 for %st(2) (gnu regno = 10) 103 14 for %st(3) (gnu regno = 11) 104 15 for %st(4) (gnu regno = 12) 105 16 for %st(5) (gnu regno = 13) 106 17 for %st(6) (gnu regno = 14) 107 18 for %st(7) (gnu regno = 15) 108*/ 109#undef DBX_REGISTER_NUMBER 110#define DBX_REGISTER_NUMBER(n) \ 111((n) == 0 ? 0 \ 112 : (n) == 1 ? 2 \ 113 : (n) == 2 ? 1 \ 114 : (n) == 3 ? 3 \ 115 : (n) == 4 ? 6 \ 116 : (n) == 5 ? 7 \ 117 : (n) == 6 ? 5 \ 118 : (n) == 7 ? 4 \ 119 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \ 120 : (-1)) 121 122/* Output assembler code to FILE to increment profiler label # LABELNO 123 for profiling a function entry. */ 124 125#undef FUNCTION_PROFILER 126#define FUNCTION_PROFILER(FILE, LABELNO) \ 127{ \ 128 if (flag_pic) \ 129 { \ 130 fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ 131 LPREFIX, (LABELNO)); \ 132 fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ 133 } \ 134 else \ 135 { \ 136 fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \ 137 fprintf (FILE, "\tcall mcount\n"); \ 138 } \ 139} 140 141#undef SIZE_TYPE 142#define SIZE_TYPE "unsigned int" 143 144#undef PTRDIFF_TYPE 145#define PTRDIFF_TYPE "int" 146 147#undef WCHAR_TYPE 148#define WCHAR_TYPE "long int" 149 150#undef WCHAR_TYPE_SIZE 151#define WCHAR_TYPE_SIZE BITS_PER_WORD 152 153/* The egcs-1.1 branch is the last time we will have -Di386. -D__i386__ is the thing to use. */ 154#undef CPP_PREDEFINES 155#define CPP_PREDEFINES "-D__ELF__ -Dunix -Di386 -D__i386__ -Dlinux -Asystem(posix)" 156 157#undef CPP_SPEC 158#ifdef USE_GNULIBC_1 159#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" 160#else 161#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" 162#endif 163 164#undef CC1_SPEC 165#define CC1_SPEC "%(cc1_cpu) %{profile:-p}" 166 167/* Provide a LINK_SPEC appropriate for Linux. Here we provide support 168 for the special GCC options -static and -shared, which allow us to 169 link things in one of these three modes by applying the appropriate 170 combinations of options at link-time. We like to support here for 171 as many of the other GNU linker options as possible. But I don't 172 have the time to search for those flags. I am sure how to add 173 support for -soname shared_object_name. H.J. 174 175 I took out %{v:%{!V:-V}}. It is too much :-(. They can use 176 -Wl,-V. 177 178 When the -shared link option is used a final link is not being 179 done. */ 180 181/* If ELF is the default format, we should not use /lib/elf. */ 182 183#undef LINK_SPEC 184#ifdef USE_GNULIBC_1 185#ifndef LINUX_DEFAULT_ELF 186#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 187 %{!shared: \ 188 %{!ibcs: \ 189 %{!static: \ 190 %{rdynamic:-export-dynamic} \ 191 %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \ 192 %{!rpath:-rpath /lib/elf/}} %{static:-static}}}" 193#else 194#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 195 %{!shared: \ 196 %{!ibcs: \ 197 %{!static: \ 198 %{rdynamic:-export-dynamic} \ 199 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \ 200 %{static:-static}}}" 201#endif 202#else 203#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 204 %{!shared: \ 205 %{!ibcs: \ 206 %{!static: \ 207 %{rdynamic:-export-dynamic} \ 208 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ 209 %{static:-static}}}" 210#endif 211 212/* Get perform_* macros to build libgcc.a. */ 213#include "i386/perform.h" 214 215/* A C statement (sans semicolon) to output to the stdio stream 216 FILE the assembler definition of uninitialized global DECL named 217 NAME whose size is SIZE bytes and alignment is ALIGN bytes. 218 Try to use asm_output_aligned_bss to implement this macro. */ 219 220#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 221 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 222 223/* A C statement to output to the stdio stream FILE an assembler 224 command to advance the location counter to a multiple of 1<<LOG 225 bytes if it is within MAX_SKIP bytes. 226 227 This is used to align code labels according to Intel recommendations. */ 228 229#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN 230#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ 231 if ((LOG)!=0) \ 232 if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ 233 else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)) 234#endif 235