linux.h revision 18334
175584Sru/* Definitions for Intel 386 running Linux with ELF format 275584Sru Copyright (C) 1994, 1995 Free Software Foundation, Inc. 375584Sru Contributed by Eric Youngdale. 475584Sru Modified for stabs-in-ELF by H.J. Lu. 575584Sru 675584SruThis file is part of GNU CC. 775584Sru 875584SruGNU CC is free software; you can redistribute it and/or modify 975584Sruit under the terms of the GNU General Public License as published by 1075584Sruthe Free Software Foundation; either version 2, or (at your option) 1175584Sruany later version. 1275584Sru 1375584SruGNU CC is distributed in the hope that it will be useful, 1475584Srubut WITHOUT ANY WARRANTY; without even the implied warranty of 1575584SruMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1675584SruGNU General Public License for more details. 1775584Sru 1875584SruYou should have received a copy of the GNU General Public License 1975584Srualong with GNU CC; see the file COPYING. If not, write to 2075584Sruthe Free Software Foundation, 59 Temple Place - Suite 330, 2175584SruBoston, MA 02111-1307, USA. */ 2275584Sru 2375584Sru#define LINUX_DEFAULT_ELF 2475584Sru 2575584Sru/* A lie, I guess, but the general idea behind linux/ELF is that we are 2675584Sru supposed to be outputting something that will assemble under SVr4. 2775584Sru This gets us pretty close. */ 2875584Sru#include <i386/i386.h> /* Base i386 target machine definitions */ 2975584Sru#include <i386/att.h> /* Use the i386 AT&T assembler syntax */ 3075584Sru#include <linux.h> /* some common stuff */ 3175584Sru 3275584Sru#undef TARGET_VERSION 3375584Sru#define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)"); 3475584Sru 3575584Sru/* The svr4 ABI for the i386 says that records and unions are returned 3675584Sru in memory. */ 3775584Sru#undef DEFAULT_PCC_STRUCT_RETURN 3875584Sru#define DEFAULT_PCC_STRUCT_RETURN 1 3975584Sru 4075584Sru/* This is how to output an element of a case-vector that is relative. 4175584Sru This is only used for PIC code. See comments by the `casesi' insn in 4275584Sru i386.md for an explanation of the expression this outputs. */ 4375584Sru#undef ASM_OUTPUT_ADDR_DIFF_ELT 4475584Sru#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ 4575584Sru fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) 4675584Sru 4775584Sru/* Indicate that jump tables go in the text section. This is 4875584Sru necessary when compiling PIC code. */ 4975584Sru#define JUMP_TABLES_IN_TEXT_SECTION 5075584Sru 5175584Sru/* Copy this from the svr4 specifications... */ 5275584Sru/* Define the register numbers to be used in Dwarf debugging information. 5375584Sru The SVR4 reference port C compiler uses the following register numbers 5475584Sru in its Dwarf output code: 5575584Sru 0 for %eax (gnu regno = 0) 5675584Sru 1 for %ecx (gnu regno = 2) 5775584Sru 2 for %edx (gnu regno = 1) 5875584Sru 3 for %ebx (gnu regno = 3) 5975584Sru 4 for %esp (gnu regno = 7) 6075584Sru 5 for %ebp (gnu regno = 6) 6175584Sru 6 for %esi (gnu regno = 4) 6275584Sru 7 for %edi (gnu regno = 5) 6375584Sru The following three DWARF register numbers are never generated by 6475584Sru the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4 6575584Sru believes these numbers have these meanings. 6675584Sru 8 for %eip (no gnu equivalent) 6775584Sru 9 for %eflags (no gnu equivalent) 6875584Sru 10 for %trapno (no gnu equivalent) 6975584Sru It is not at all clear how we should number the FP stack registers 7075584Sru for the x86 architecture. If the version of SDB on x86/svr4 were 7175584Sru a bit less brain dead with respect to floating-point then we would 7275584Sru have a precedent to follow with respect to DWARF register numbers 7375584Sru for x86 FP registers, but the SDB on x86/svr4 is so completely 7475584Sru broken with respect to FP registers that it is hardly worth thinking 7575584Sru of it as something to strive for compatibility with. 7675584Sru The version of x86/svr4 SDB I have at the moment does (partially) 7775584Sru seem to believe that DWARF register number 11 is associated with 7875584Sru the x86 register %st(0), but that's about all. Higher DWARF 7975584Sru register numbers don't seem to be associated with anything in 8075584Sru particular, and even for DWARF regno 11, SDB only seems to under- 8175584Sru stand that it should say that a variable lives in %st(0) (when 8275584Sru asked via an `=' command) if we said it was in DWARF regno 11, 8375584Sru but SDB still prints garbage when asked for the value of the 8475584Sru variable in question (via a `/' command). 8575584Sru (Also note that the labels SDB prints for various FP stack regs 8675584Sru when doing an `x' command are all wrong.) 8775584Sru Note that these problems generally don't affect the native SVR4 8875584Sru C compiler because it doesn't allow the use of -O with -g and 8975584Sru because when it is *not* optimizing, it allocates a memory 9075584Sru location for each floating-point variable, and the memory 9175584Sru location is what gets described in the DWARF AT_location 9275584Sru attribute for the variable in question. 9375584Sru Regardless of the severe mental illness of the x86/svr4 SDB, we 9475584Sru do something sensible here and we use the following DWARF 9575584Sru register numbers. Note that these are all stack-top-relative 9675584Sru numbers. 9775584Sru 11 for %st(0) (gnu regno = 8) 9875584Sru 12 for %st(1) (gnu regno = 9) 9975584Sru 13 for %st(2) (gnu regno = 10) 10075584Sru 14 for %st(3) (gnu regno = 11) 10175584Sru 15 for %st(4) (gnu regno = 12) 10275584Sru 16 for %st(5) (gnu regno = 13) 10375584Sru 17 for %st(6) (gnu regno = 14) 10475584Sru 18 for %st(7) (gnu regno = 15) 10575584Sru*/ 10675584Sru#undef DBX_REGISTER_NUMBER 10775584Sru#define DBX_REGISTER_NUMBER(n) \ 10875584Sru((n) == 0 ? 0 \ 10975584Sru : (n) == 1 ? 2 \ 11075584Sru : (n) == 2 ? 1 \ 11175584Sru : (n) == 3 ? 3 \ 11275584Sru : (n) == 4 ? 6 \ 11375584Sru : (n) == 5 ? 7 \ 11475584Sru : (n) == 6 ? 5 \ 11575584Sru : (n) == 7 ? 4 \ 11675584Sru : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \ 11775584Sru : (-1)) 11875584Sru 11975584Sru/* Output assembler code to FILE to increment profiler label # LABELNO 12075584Sru for profiling a function entry. */ 12175584Sru 12275584Sru#undef FUNCTION_PROFILER 12375584Sru#define FUNCTION_PROFILER(FILE, LABELNO) \ 12475584Sru{ \ 12575584Sru if (flag_pic) \ 12675584Sru { \ 12775584Sru fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ 12875584Sru LPREFIX, (LABELNO)); \ 12975584Sru fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ 13075584Sru } \ 13175584Sru else \ 13275584Sru { \ 13375584Sru fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \ 13475584Sru fprintf (FILE, "\tcall mcount\n"); \ 13575584Sru } \ 13675584Sru} 13775584Sru 13875584Sru#undef SIZE_TYPE 13975584Sru#define SIZE_TYPE "unsigned int" 14075584Sru 14175584Sru#undef PTRDIFF_TYPE 14275584Sru#define PTRDIFF_TYPE "int" 14375584Sru 14475584Sru#undef WCHAR_TYPE 14575584Sru#define WCHAR_TYPE "long int" 14675584Sru 14775584Sru#undef WCHAR_TYPE_SIZE 14875584Sru#define WCHAR_TYPE_SIZE BITS_PER_WORD 14975584Sru 15075584Sru#undef CPP_PREDEFINES 15175584Sru#define CPP_PREDEFINES "-D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)" 15275584Sru 15375584Sru#undef CPP_SPEC 15475584Sru#if TARGET_CPU_DEFAULT == 2 15575584Sru#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE}" 15675584Sru#else 15775584Sru#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m486:-D__i486__} %{posix:-D_POSIX_SOURCE}" 15875584Sru#endif 15975584Sru 16075584Sru#undef LIB_SPEC 16175584Sru#if 1 16275584Sru/* We no longer link with libc_p.a or libg.a by default. If you 16375584Sru * want to profile or debug the Linux C library, please add 16475584Sru * -lc_p or -ggdb to LDFLAGS at the link time, respectively. 16575584Sru */ 16675584Sru#define LIB_SPEC \ 16775584Sru "%{!shared: %{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} \ 16875584Sru %{!ggdb:-lc} %{ggdb:-lg}}" 16975584Sru#else 17075584Sru#define LIB_SPEC \ 17175584Sru "%{!shared: \ 17275584Sru %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \ 17375584Sru %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}" 17475584Sru#endif 17575584Sru 17675584Sru/* Provide a LINK_SPEC appropriate for Linux. Here we provide support 17775584Sru for the special GCC options -static and -shared, which allow us to 17875584Sru link things in one of these three modes by applying the appropriate 17975584Sru combinations of options at link-time. We like to support here for 18075584Sru as many of the other GNU linker options as possible. But I don't 18175584Sru have the time to search for those flags. I am sure how to add 18275584Sru support for -soname shared_object_name. H.J. 18375584Sru 18475584Sru I took out %{v:%{!V:-V}}. It is too much :-(. They can use 18575584Sru -Wl,-V. 18675584Sru 18775584Sru When the -shared link option is used a final link is not being 18875584Sru done. */ 18975584Sru 19075584Sru/* If ELF is the default format, we should not use /lib/elf. */ 19175584Sru 19275584Sru#undef LINK_SPEC 19375584Sru#ifndef LINUX_DEFAULT_ELF 19475584Sru#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 19575584Sru %{!shared: \ 19675584Sru %{!ibcs: \ 19775584Sru %{!static: \ 19875584Sru %{rdynamic:-export-dynamic} \ 19975584Sru %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \ 20075584Sru %{!rpath:-rpath /lib/elf/}} %{static:-static}}}" 20175584Sru#else 20275584Sru#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 20375584Sru %{!shared: \ 20475584Sru %{!ibcs: \ 20575584Sru %{!static: \ 20675584Sru %{rdynamic:-export-dynamic} \ 20775584Sru %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \ 20875584Sru %{static:-static}}}" 20975584Sru#endif 21075584Sru 21175584Sru/* Get perform_* macros to build libgcc.a. */ 21275584Sru#include "i386/perform.h" 21375584Sru