linux.h revision 50397
150397Sobrien/* Definitions for Intel 386 running Linux-based GNU systems with ELF format. 250397Sobrien Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 318334Speter Contributed by Eric Youngdale. 418334Speter Modified for stabs-in-ELF by H.J. Lu. 518334Speter 618334SpeterThis file is part of GNU CC. 718334Speter 818334SpeterGNU CC is free software; you can redistribute it and/or modify 918334Speterit under the terms of the GNU General Public License as published by 1018334Speterthe Free Software Foundation; either version 2, or (at your option) 1118334Speterany later version. 1218334Speter 1318334SpeterGNU CC is distributed in the hope that it will be useful, 1418334Speterbut WITHOUT ANY WARRANTY; without even the implied warranty of 1518334SpeterMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1618334SpeterGNU General Public License for more details. 1718334Speter 1818334SpeterYou should have received a copy of the GNU General Public License 1918334Speteralong with GNU CC; see the file COPYING. If not, write to 2018334Speterthe Free Software Foundation, 59 Temple Place - Suite 330, 2118334SpeterBoston, MA 02111-1307, USA. */ 2218334Speter 2318334Speter#define LINUX_DEFAULT_ELF 2418334Speter 2518334Speter/* A lie, I guess, but the general idea behind linux/ELF is that we are 2618334Speter supposed to be outputting something that will assemble under SVr4. 2718334Speter This gets us pretty close. */ 2818334Speter#include <i386/i386.h> /* Base i386 target machine definitions */ 2918334Speter#include <i386/att.h> /* Use the i386 AT&T assembler syntax */ 3018334Speter#include <linux.h> /* some common stuff */ 3118334Speter 3218334Speter#undef TARGET_VERSION 3318334Speter#define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)"); 3418334Speter 3518334Speter/* The svr4 ABI for the i386 says that records and unions are returned 3618334Speter in memory. */ 3718334Speter#undef DEFAULT_PCC_STRUCT_RETURN 3818334Speter#define DEFAULT_PCC_STRUCT_RETURN 1 3918334Speter 4050397Sobrien#undef ASM_COMMENT_START 4150397Sobrien#define ASM_COMMENT_START "#" 4250397Sobrien 4318334Speter/* This is how to output an element of a case-vector that is relative. 4418334Speter This is only used for PIC code. See comments by the `casesi' insn in 4518334Speter i386.md for an explanation of the expression this outputs. */ 4618334Speter#undef ASM_OUTPUT_ADDR_DIFF_ELT 4750397Sobrien#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ 4818334Speter fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) 4918334Speter 5018334Speter/* Indicate that jump tables go in the text section. This is 5118334Speter necessary when compiling PIC code. */ 5250397Sobrien#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic) 5318334Speter 5418334Speter/* Copy this from the svr4 specifications... */ 5518334Speter/* Define the register numbers to be used in Dwarf debugging information. 5618334Speter The SVR4 reference port C compiler uses the following register numbers 5718334Speter in its Dwarf output code: 5818334Speter 0 for %eax (gnu regno = 0) 5918334Speter 1 for %ecx (gnu regno = 2) 6018334Speter 2 for %edx (gnu regno = 1) 6118334Speter 3 for %ebx (gnu regno = 3) 6218334Speter 4 for %esp (gnu regno = 7) 6318334Speter 5 for %ebp (gnu regno = 6) 6418334Speter 6 for %esi (gnu regno = 4) 6518334Speter 7 for %edi (gnu regno = 5) 6618334Speter The following three DWARF register numbers are never generated by 6718334Speter the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4 6818334Speter believes these numbers have these meanings. 6918334Speter 8 for %eip (no gnu equivalent) 7018334Speter 9 for %eflags (no gnu equivalent) 7118334Speter 10 for %trapno (no gnu equivalent) 7218334Speter It is not at all clear how we should number the FP stack registers 7318334Speter for the x86 architecture. If the version of SDB on x86/svr4 were 7418334Speter a bit less brain dead with respect to floating-point then we would 7518334Speter have a precedent to follow with respect to DWARF register numbers 7618334Speter for x86 FP registers, but the SDB on x86/svr4 is so completely 7718334Speter broken with respect to FP registers that it is hardly worth thinking 7818334Speter of it as something to strive for compatibility with. 7918334Speter The version of x86/svr4 SDB I have at the moment does (partially) 8018334Speter seem to believe that DWARF register number 11 is associated with 8118334Speter the x86 register %st(0), but that's about all. Higher DWARF 8218334Speter register numbers don't seem to be associated with anything in 8318334Speter particular, and even for DWARF regno 11, SDB only seems to under- 8418334Speter stand that it should say that a variable lives in %st(0) (when 8518334Speter asked via an `=' command) if we said it was in DWARF regno 11, 8618334Speter but SDB still prints garbage when asked for the value of the 8718334Speter variable in question (via a `/' command). 8818334Speter (Also note that the labels SDB prints for various FP stack regs 8918334Speter when doing an `x' command are all wrong.) 9018334Speter Note that these problems generally don't affect the native SVR4 9118334Speter C compiler because it doesn't allow the use of -O with -g and 9218334Speter because when it is *not* optimizing, it allocates a memory 9318334Speter location for each floating-point variable, and the memory 9418334Speter location is what gets described in the DWARF AT_location 9518334Speter attribute for the variable in question. 9618334Speter Regardless of the severe mental illness of the x86/svr4 SDB, we 9718334Speter do something sensible here and we use the following DWARF 9818334Speter register numbers. Note that these are all stack-top-relative 9918334Speter numbers. 10018334Speter 11 for %st(0) (gnu regno = 8) 10118334Speter 12 for %st(1) (gnu regno = 9) 10218334Speter 13 for %st(2) (gnu regno = 10) 10318334Speter 14 for %st(3) (gnu regno = 11) 10418334Speter 15 for %st(4) (gnu regno = 12) 10518334Speter 16 for %st(5) (gnu regno = 13) 10618334Speter 17 for %st(6) (gnu regno = 14) 10718334Speter 18 for %st(7) (gnu regno = 15) 10818334Speter*/ 10918334Speter#undef DBX_REGISTER_NUMBER 11018334Speter#define DBX_REGISTER_NUMBER(n) \ 11118334Speter((n) == 0 ? 0 \ 11218334Speter : (n) == 1 ? 2 \ 11318334Speter : (n) == 2 ? 1 \ 11418334Speter : (n) == 3 ? 3 \ 11518334Speter : (n) == 4 ? 6 \ 11618334Speter : (n) == 5 ? 7 \ 11718334Speter : (n) == 6 ? 5 \ 11818334Speter : (n) == 7 ? 4 \ 11918334Speter : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \ 12018334Speter : (-1)) 12118334Speter 12218334Speter/* Output assembler code to FILE to increment profiler label # LABELNO 12318334Speter for profiling a function entry. */ 12418334Speter 12518334Speter#undef FUNCTION_PROFILER 12618334Speter#define FUNCTION_PROFILER(FILE, LABELNO) \ 12718334Speter{ \ 12818334Speter if (flag_pic) \ 12918334Speter { \ 13018334Speter fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ 13118334Speter LPREFIX, (LABELNO)); \ 13218334Speter fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ 13318334Speter } \ 13418334Speter else \ 13518334Speter { \ 13618334Speter fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \ 13718334Speter fprintf (FILE, "\tcall mcount\n"); \ 13818334Speter } \ 13918334Speter} 14018334Speter 14118334Speter#undef SIZE_TYPE 14218334Speter#define SIZE_TYPE "unsigned int" 14318334Speter 14418334Speter#undef PTRDIFF_TYPE 14518334Speter#define PTRDIFF_TYPE "int" 14618334Speter 14718334Speter#undef WCHAR_TYPE 14818334Speter#define WCHAR_TYPE "long int" 14918334Speter 15018334Speter#undef WCHAR_TYPE_SIZE 15118334Speter#define WCHAR_TYPE_SIZE BITS_PER_WORD 15218334Speter 15350397Sobrien/* The egcs-1.1 branch is the last time we will have -Di386. -D__i386__ is the thing to use. */ 15418334Speter#undef CPP_PREDEFINES 15550397Sobrien#define CPP_PREDEFINES "-D__ELF__ -Dunix -Di386 -D__i386__ -Dlinux -Asystem(posix)" 15618334Speter 15718334Speter#undef CPP_SPEC 15848743Sobrien#ifdef USE_GNULIBC_1 15950397Sobrien#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" 16018334Speter#else 16150397Sobrien#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" 16218334Speter#endif 16318334Speter 16450397Sobrien#undef CC1_SPEC 16550397Sobrien#define CC1_SPEC "%(cc1_cpu) %{profile:-p}" 16648743Sobrien 16718334Speter/* Provide a LINK_SPEC appropriate for Linux. Here we provide support 16818334Speter for the special GCC options -static and -shared, which allow us to 16918334Speter link things in one of these three modes by applying the appropriate 17018334Speter combinations of options at link-time. We like to support here for 17118334Speter as many of the other GNU linker options as possible. But I don't 17218334Speter have the time to search for those flags. I am sure how to add 17318334Speter support for -soname shared_object_name. H.J. 17418334Speter 17518334Speter I took out %{v:%{!V:-V}}. It is too much :-(. They can use 17618334Speter -Wl,-V. 17718334Speter 17818334Speter When the -shared link option is used a final link is not being 17918334Speter done. */ 18018334Speter 18118334Speter/* If ELF is the default format, we should not use /lib/elf. */ 18218334Speter 18318334Speter#undef LINK_SPEC 18448743Sobrien#ifdef USE_GNULIBC_1 18518334Speter#ifndef LINUX_DEFAULT_ELF 18618334Speter#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 18718334Speter %{!shared: \ 18818334Speter %{!ibcs: \ 18918334Speter %{!static: \ 19018334Speter %{rdynamic:-export-dynamic} \ 19118334Speter %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \ 19218334Speter %{!rpath:-rpath /lib/elf/}} %{static:-static}}}" 19318334Speter#else 19418334Speter#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 19518334Speter %{!shared: \ 19618334Speter %{!ibcs: \ 19718334Speter %{!static: \ 19818334Speter %{rdynamic:-export-dynamic} \ 19918334Speter %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \ 20018334Speter %{static:-static}}}" 20118334Speter#endif 20250397Sobrien#else 20348743Sobrien#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 20448743Sobrien %{!shared: \ 20548743Sobrien %{!ibcs: \ 20648743Sobrien %{!static: \ 20748743Sobrien %{rdynamic:-export-dynamic} \ 20848743Sobrien %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ 20948743Sobrien %{static:-static}}}" 21050397Sobrien#endif 21118334Speter 21218334Speter/* Get perform_* macros to build libgcc.a. */ 21318334Speter#include "i386/perform.h" 21450397Sobrien 21550397Sobrien/* A C statement (sans semicolon) to output to the stdio stream 21650397Sobrien FILE the assembler definition of uninitialized global DECL named 21750397Sobrien NAME whose size is SIZE bytes and alignment is ALIGN bytes. 21850397Sobrien Try to use asm_output_aligned_bss to implement this macro. */ 21950397Sobrien 22050397Sobrien#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 22150397Sobrien asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 22250397Sobrien 22350397Sobrien/* A C statement to output to the stdio stream FILE an assembler 22450397Sobrien command to advance the location counter to a multiple of 1<<LOG 22550397Sobrien bytes if it is within MAX_SKIP bytes. 22650397Sobrien 22750397Sobrien This is used to align code labels according to Intel recommendations. */ 22850397Sobrien 22950397Sobrien#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN 23050397Sobrien#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ 23150397Sobrien if ((LOG)!=0) \ 23250397Sobrien if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ 23350397Sobrien else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)) 23450397Sobrien#endif 235