linux.h revision 52284
175584Sru/* Definitions for Intel 386 running Linux-based GNU systems with ELF format. 275584Sru Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 375584Sru Contributed by Eric Youngdale. 475584Sru Modified for stabs-in-ELF by H.J. Lu. 5114402Sru 6114402SruThis file is part of GNU CC. 7114402Sru 8114402SruGNU CC is free software; you can redistribute it and/or modify 9114402Sruit under the terms of the GNU General Public License as published by 10114402Sruthe Free Software Foundation; either version 2, or (at your option) 11114402Sruany later version. 12114402Sru 13114402SruGNU CC is distributed in the hope that it will be useful, 14114402Srubut WITHOUT ANY WARRANTY; without even the implied warranty of 15114402SruMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16114402SruGNU General Public License for more details. 17114402Sru 18114402SruYou should have received a copy of the GNU General Public License 19114402Srualong with GNU CC; see the file COPYING. If not, write to 20114402Sruthe Free Software Foundation, 59 Temple Place - Suite 330, 21114402SruBoston, MA 02111-1307, USA. */ 22114402Sru 23114402Sru#define LINUX_DEFAULT_ELF 24114402Sru 25114402Sru/* A lie, I guess, but the general idea behind linux/ELF is that we are 26114402Sru supposed to be outputting something that will assemble under SVr4. 27114402Sru This gets us pretty close. */ 28114402Sru#include <i386/i386.h> /* Base i386 target machine definitions */ 29114402Sru#include <i386/att.h> /* Use the i386 AT&T assembler syntax */ 30114402Sru#include <linux.h> /* some common stuff */ 31114402Sru 32114402Sru#undef TARGET_VERSION 33114402Sru#define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)"); 34114402Sru 35114402Sru/* The svr4 ABI for the i386 says that records and unions are returned 36114402Sru in memory. */ 3775584Sru#undef DEFAULT_PCC_STRUCT_RETURN 3875584Sru#define DEFAULT_PCC_STRUCT_RETURN 1 3975584Sru 4075584Sru#undef ASM_COMMENT_START 4175584Sru#define ASM_COMMENT_START "#" 4275584Sru 4375584Sru/* This is how to output an element of a case-vector that is relative. 4475584Sru This is only used for PIC code. See comments by the `casesi' insn in 4575584Sru i386.md for an explanation of the expression this outputs. */ 4675584Sru#undef ASM_OUTPUT_ADDR_DIFF_ELT 4775584Sru#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ 4875584Sru fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) 4975584Sru 5075584Sru/* Indicate that jump tables go in the text section. This is 5175584Sru necessary when compiling PIC code. */ 5275584Sru#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic) 5375584Sru 5475584Sru/* Copy this from the svr4 specifications... */ 5575584Sru/* Define the register numbers to be used in Dwarf debugging information. 5675584Sru The SVR4 reference port C compiler uses the following register numbers 5775584Sru in its Dwarf output code: 5875584Sru 0 for %eax (gnu regno = 0) 5975584Sru 1 for %ecx (gnu regno = 2) 6075584Sru 2 for %edx (gnu regno = 1) 6175584Sru 3 for %ebx (gnu regno = 3) 6275584Sru 4 for %esp (gnu regno = 7) 6375584Sru 5 for %ebp (gnu regno = 6) 6475584Sru 6 for %esi (gnu regno = 4) 6575584Sru 7 for %edi (gnu regno = 5) 6675584Sru The following three DWARF register numbers are never generated by 6775584Sru the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4 6875584Sru believes these numbers have these meanings. 6975584Sru 8 for %eip (no gnu equivalent) 7075584Sru 9 for %eflags (no gnu equivalent) 7175584Sru 10 for %trapno (no gnu equivalent) 7275584Sru It is not at all clear how we should number the FP stack registers 7375584Sru for the x86 architecture. If the version of SDB on x86/svr4 were 7475584Sru a bit less brain dead with respect to floating-point then we would 7575584Sru have a precedent to follow with respect to DWARF register numbers 7675584Sru for x86 FP registers, but the SDB on x86/svr4 is so completely 7775584Sru broken with respect to FP registers that it is hardly worth thinking 7875584Sru of it as something to strive for compatibility with. 7975584Sru The version of x86/svr4 SDB I have at the moment does (partially) 8075584Sru seem to believe that DWARF register number 11 is associated with 8175584Sru the x86 register %st(0), but that's about all. Higher DWARF 8275584Sru register numbers don't seem to be associated with anything in 8375584Sru particular, and even for DWARF regno 11, SDB only seems to under- 8475584Sru stand that it should say that a variable lives in %st(0) (when 8575584Sru asked via an `=' command) if we said it was in DWARF regno 11, 8675584Sru but SDB still prints garbage when asked for the value of the 8775584Sru variable in question (via a `/' command). 8875584Sru (Also note that the labels SDB prints for various FP stack regs 8975584Sru when doing an `x' command are all wrong.) 9075584Sru Note that these problems generally don't affect the native SVR4 9175584Sru C compiler because it doesn't allow the use of -O with -g and 9275584Sru because when it is *not* optimizing, it allocates a memory 9375584Sru location for each floating-point variable, and the memory 9475584Sru location is what gets described in the DWARF AT_location 9575584Sru attribute for the variable in question. 9675584Sru Regardless of the severe mental illness of the x86/svr4 SDB, we 9775584Sru do something sensible here and we use the following DWARF 9875584Sru register numbers. Note that these are all stack-top-relative 9975584Sru numbers. 10075584Sru 11 for %st(0) (gnu regno = 8) 10175584Sru 12 for %st(1) (gnu regno = 9) 10275584Sru 13 for %st(2) (gnu regno = 10) 10375584Sru 14 for %st(3) (gnu regno = 11) 10475584Sru 15 for %st(4) (gnu regno = 12) 10575584Sru 16 for %st(5) (gnu regno = 13) 10675584Sru 17 for %st(6) (gnu regno = 14) 10775584Sru 18 for %st(7) (gnu regno = 15) 10875584Sru*/ 10975584Sru#undef DBX_REGISTER_NUMBER 11075584Sru#define DBX_REGISTER_NUMBER(n) \ 11175584Sru((n) == 0 ? 0 \ 11275584Sru : (n) == 1 ? 2 \ 11375584Sru : (n) == 2 ? 1 \ 11475584Sru : (n) == 3 ? 3 \ 11575584Sru : (n) == 4 ? 6 \ 11675584Sru : (n) == 5 ? 7 \ 11775584Sru : (n) == 6 ? 5 \ 11875584Sru : (n) == 7 ? 4 \ 11975584Sru : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \ 12075584Sru : (-1)) 12175584Sru 12275584Sru/* Output assembler code to FILE to increment profiler label # LABELNO 12375584Sru for profiling a function entry. */ 12475584Sru 12575584Sru#undef FUNCTION_PROFILER 12675584Sru#define FUNCTION_PROFILER(FILE, LABELNO) \ 12775584Sru{ \ 12875584Sru if (flag_pic) \ 12975584Sru { \ 13075584Sru fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ 13175584Sru LPREFIX, (LABELNO)); \ 13275584Sru fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ 13375584Sru } \ 13475584Sru else \ 13575584Sru { \ 13675584Sru fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \ 13775584Sru fprintf (FILE, "\tcall mcount\n"); \ 13875584Sru } \ 13975584Sru} 14075584Sru 14175584Sru#undef SIZE_TYPE 14275584Sru#define SIZE_TYPE "unsigned int" 14375584Sru 14475584Sru#undef PTRDIFF_TYPE 14575584Sru#define PTRDIFF_TYPE "int" 14675584Sru 14775584Sru#undef WCHAR_TYPE 14875584Sru#define WCHAR_TYPE "long int" 14975584Sru 15075584Sru#undef WCHAR_TYPE_SIZE 15175584Sru#define WCHAR_TYPE_SIZE BITS_PER_WORD 15275584Sru 15375584Sru#undef CPP_PREDEFINES 15475584Sru#define CPP_PREDEFINES "-D__ELF__ -Dunix -D__i386__ -Dlinux -Asystem(posix)" 15575584Sru 15675584Sru#undef CPP_SPEC 15775584Sru#ifdef USE_GNULIBC_1 15875584Sru#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" 15975584Sru#else 16075584Sru#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" 16175584Sru#endif 16275584Sru 16375584Sru#undef CC1_SPEC 16475584Sru#define CC1_SPEC "%(cc1_cpu) %{profile:-p}" 16575584Sru 16675584Sru/* Provide a LINK_SPEC appropriate for Linux. Here we provide support 16775584Sru for the special GCC options -static and -shared, which allow us to 16875584Sru link things in one of these three modes by applying the appropriate 16975584Sru combinations of options at link-time. We like to support here for 17075584Sru as many of the other GNU linker options as possible. But I don't 17175584Sru have the time to search for those flags. I am sure how to add 17275584Sru support for -soname shared_object_name. H.J. 17375584Sru 17475584Sru I took out %{v:%{!V:-V}}. It is too much :-(. They can use 17575584Sru -Wl,-V. 17675584Sru 17775584Sru When the -shared link option is used a final link is not being 17875584Sru done. */ 17975584Sru 18075584Sru/* If ELF is the default format, we should not use /lib/elf. */ 18175584Sru 18275584Sru#undef LINK_SPEC 18375584Sru#ifdef USE_GNULIBC_1 18475584Sru#ifndef LINUX_DEFAULT_ELF 18575584Sru#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 18675584Sru %{!shared: \ 187114402Sru %{!ibcs: \ 188114402Sru %{!static: \ 189114402Sru %{rdynamic:-export-dynamic} \ 190114402Sru %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \ 191114402Sru %{!rpath:-rpath /lib/elf/}} %{static:-static}}}" 192114402Sru#else 193114402Sru#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 194114402Sru %{!shared: \ 195114402Sru %{!ibcs: \ 196114402Sru %{!static: \ 197114402Sru %{rdynamic:-export-dynamic} \ 198114402Sru %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \ 199114402Sru %{static:-static}}}" 200114402Sru#endif 201114402Sru#else 202114402Sru#define LINK_SPEC "-m elf_i386 %{shared:-shared} \ 203114402Sru %{!shared: \ 204114402Sru %{!ibcs: \ 205114402Sru %{!static: \ 206114402Sru %{rdynamic:-export-dynamic} \ 207114402Sru %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ 208114402Sru %{static:-static}}}" 209114402Sru#endif 210114402Sru 211114402Sru/* Get perform_* macros to build libgcc.a. */ 212114402Sru#include "i386/perform.h" 213114402Sru 214114402Sru/* A C statement (sans semicolon) to output to the stdio stream 215114402Sru FILE the assembler definition of uninitialized global DECL named 216114402Sru NAME whose size is SIZE bytes and alignment is ALIGN bytes. 217114402Sru Try to use asm_output_aligned_bss to implement this macro. */ 218114402Sru 219114402Sru#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 220114402Sru asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 22175584Sru 22275584Sru/* A C statement to output to the stdio stream FILE an assembler 22375584Sru command to advance the location counter to a multiple of 1<<LOG 22475584Sru bytes if it is within MAX_SKIP bytes. 22575584Sru 22675584Sru This is used to align code labels according to Intel recommendations. */ 22775584Sru 22875584Sru#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN 22975584Sru#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ 23075584Sru do { \ 23175584Sru if ((LOG) != 0) { \ 23275584Sru if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ 233114402Sru else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ 23475584Sru } \ 23575584Sru } while (0) 23675584Sru#endif 23775584Sru