rtemself.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.
350397Sobrien   Contributed by Eric Youngdale.
450397Sobrien   Modified for stabs-in-ELF by H.J. Lu.
550397Sobrien
650397SobrienThis file is part of GNU CC.
750397Sobrien
850397SobrienGNU CC is free software; you can redistribute it and/or modify
950397Sobrienit under the terms of the GNU General Public License as published by
1050397Sobrienthe Free Software Foundation; either version 2, or (at your option)
1150397Sobrienany later version.
1250397Sobrien
1350397SobrienGNU CC is distributed in the hope that it will be useful,
1450397Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1550397SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1650397SobrienGNU General Public License for more details.
1750397Sobrien
1850397SobrienYou should have received a copy of the GNU General Public License
1950397Sobrienalong with GNU CC; see the file COPYING.  If not, write to
2050397Sobrienthe Free Software Foundation, 59 Temple Place - Suite 330,
2150397SobrienBoston, MA 02111-1307, USA.  */
2250397Sobrien
2350397Sobrien#define LINUX_DEFAULT_ELF
2450397Sobrien
2550397Sobrien/* A lie, I guess, but the general idea behind linux/ELF is that we are
2650397Sobrien   supposed to be outputting something that will assemble under SVr4.
2750397Sobrien   This gets us pretty close.  */
2850397Sobrien#include <i386/i386.h>	/* Base i386 target machine definitions */
2950397Sobrien#include <i386/att.h>	/* Use the i386 AT&T assembler syntax */
3050397Sobrien#include <linux.h>	/* some common stuff */
3150397Sobrien
3250397Sobrien#undef TARGET_VERSION
3350397Sobrien#define TARGET_VERSION fprintf (stderr, " (i386 RTEMS with ELF)");
3450397Sobrien
3550397Sobrien/* The svr4 ABI for the i386 says that records and unions are returned
3650397Sobrien   in memory.  */
3750397Sobrien#undef DEFAULT_PCC_STRUCT_RETURN
3850397Sobrien#define DEFAULT_PCC_STRUCT_RETURN 1
3950397Sobrien
4050397Sobrien/* This is how to output an element of a case-vector that is relative.
4150397Sobrien   This is only used for PIC code.  See comments by the `casesi' insn in
4250397Sobrien   i386.md for an explanation of the expression this outputs. */
4350397Sobrien#undef ASM_OUTPUT_ADDR_DIFF_ELT
4450397Sobrien#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
4550397Sobrien  fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
4650397Sobrien
4750397Sobrien/* Indicate that jump tables go in the text section.  This is
4850397Sobrien   necessary when compiling PIC code.  */
4950397Sobrien#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
5050397Sobrien
5150397Sobrien/* Copy this from the svr4 specifications... */
5250397Sobrien/* Define the register numbers to be used in Dwarf debugging information.
5350397Sobrien   The SVR4 reference port C compiler uses the following register numbers
5450397Sobrien   in its Dwarf output code:
5550397Sobrien	0 for %eax (gnu regno = 0)
5650397Sobrien	1 for %ecx (gnu regno = 2)
5750397Sobrien	2 for %edx (gnu regno = 1)
5850397Sobrien	3 for %ebx (gnu regno = 3)
5950397Sobrien	4 for %esp (gnu regno = 7)
6050397Sobrien	5 for %ebp (gnu regno = 6)
6150397Sobrien	6 for %esi (gnu regno = 4)
6250397Sobrien	7 for %edi (gnu regno = 5)
6350397Sobrien   The following three DWARF register numbers are never generated by
6450397Sobrien   the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
6550397Sobrien   believes these numbers have these meanings.
6650397Sobrien	8  for %eip    (no gnu equivalent)
6750397Sobrien	9  for %eflags (no gnu equivalent)
6850397Sobrien	10 for %trapno (no gnu equivalent)
6950397Sobrien   It is not at all clear how we should number the FP stack registers
7050397Sobrien   for the x86 architecture.  If the version of SDB on x86/svr4 were
7150397Sobrien   a bit less brain dead with respect to floating-point then we would
7250397Sobrien   have a precedent to follow with respect to DWARF register numbers
7350397Sobrien   for x86 FP registers, but the SDB on x86/svr4 is so completely
7450397Sobrien   broken with respect to FP registers that it is hardly worth thinking
7550397Sobrien   of it as something to strive for compatibility with.
7650397Sobrien   The version of x86/svr4 SDB I have at the moment does (partially)
7750397Sobrien   seem to believe that DWARF register number 11 is associated with
7850397Sobrien   the x86 register %st(0), but that's about all.  Higher DWARF
7950397Sobrien   register numbers don't seem to be associated with anything in
8050397Sobrien   particular, and even for DWARF regno 11, SDB only seems to under-
8150397Sobrien   stand that it should say that a variable lives in %st(0) (when
8250397Sobrien   asked via an `=' command) if we said it was in DWARF regno 11,
8350397Sobrien   but SDB still prints garbage when asked for the value of the
8450397Sobrien   variable in question (via a `/' command).
8550397Sobrien   (Also note that the labels SDB prints for various FP stack regs
8650397Sobrien   when doing an `x' command are all wrong.)
8750397Sobrien   Note that these problems generally don't affect the native SVR4
8850397Sobrien   C compiler because it doesn't allow the use of -O with -g and
8950397Sobrien   because when it is *not* optimizing, it allocates a memory
9050397Sobrien   location for each floating-point variable, and the memory
9150397Sobrien   location is what gets described in the DWARF AT_location
9250397Sobrien   attribute for the variable in question.
9350397Sobrien   Regardless of the severe mental illness of the x86/svr4 SDB, we
9450397Sobrien   do something sensible here and we use the following DWARF
9550397Sobrien   register numbers.  Note that these are all stack-top-relative
9650397Sobrien   numbers.
9750397Sobrien	11 for %st(0) (gnu regno = 8)
9850397Sobrien	12 for %st(1) (gnu regno = 9)
9950397Sobrien	13 for %st(2) (gnu regno = 10)
10050397Sobrien	14 for %st(3) (gnu regno = 11)
10150397Sobrien	15 for %st(4) (gnu regno = 12)
10250397Sobrien	16 for %st(5) (gnu regno = 13)
10350397Sobrien	17 for %st(6) (gnu regno = 14)
10450397Sobrien	18 for %st(7) (gnu regno = 15)
10550397Sobrien*/
10650397Sobrien#undef DBX_REGISTER_NUMBER
10750397Sobrien#define DBX_REGISTER_NUMBER(n) \
10850397Sobrien((n) == 0 ? 0 \
10950397Sobrien : (n) == 1 ? 2 \
11050397Sobrien : (n) == 2 ? 1 \
11150397Sobrien : (n) == 3 ? 3 \
11250397Sobrien : (n) == 4 ? 6 \
11350397Sobrien : (n) == 5 ? 7 \
11450397Sobrien : (n) == 6 ? 5 \
11550397Sobrien : (n) == 7 ? 4 \
11650397Sobrien : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
11750397Sobrien : (-1))
11850397Sobrien
11950397Sobrien/* Output assembler code to FILE to increment profiler label # LABELNO
12050397Sobrien   for profiling a function entry.  */
12150397Sobrien
12250397Sobrien#undef FUNCTION_PROFILER
12350397Sobrien#define FUNCTION_PROFILER(FILE, LABELNO)  \
12450397Sobrien{									\
12550397Sobrien  if (flag_pic)								\
12650397Sobrien    {									\
12750397Sobrien      fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n",		\
12850397Sobrien	       LPREFIX, (LABELNO));					\
12950397Sobrien      fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");			\
13050397Sobrien    }									\
13150397Sobrien  else									\
13250397Sobrien    {									\
13350397Sobrien      fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO));	\
13450397Sobrien      fprintf (FILE, "\tcall mcount\n");				\
13550397Sobrien    }									\
13650397Sobrien}
13750397Sobrien
13850397Sobrien#undef SIZE_TYPE
13950397Sobrien#define SIZE_TYPE "unsigned int"
14050397Sobrien
14150397Sobrien#undef PTRDIFF_TYPE
14250397Sobrien#define PTRDIFF_TYPE "int"
14350397Sobrien
14450397Sobrien#undef WCHAR_TYPE
14550397Sobrien#define WCHAR_TYPE "long int"
14650397Sobrien
14750397Sobrien#undef WCHAR_TYPE_SIZE
14850397Sobrien#define WCHAR_TYPE_SIZE BITS_PER_WORD
14950397Sobrien
15050397Sobrien#undef CPP_PREDEFINES
15150397Sobrien#define CPP_PREDEFINES  "-Di386 -Drtems -D__rtems__ \
15250397Sobrien   -Asystem(rtems) -Acpu(i386) -Amachine(i386)"
15350397Sobrien
15450397Sobrien/* Get perform_* macros to build libgcc.a.  */
15550397Sobrien#include "i386/perform.h"
15650397Sobrien
15750397Sobrien/* A C statement (sans semicolon) to output to the stdio stream
15850397Sobrien   FILE the assembler definition of uninitialized global DECL named
15950397Sobrien   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
16050397Sobrien   Try to use asm_output_aligned_bss to implement this macro.  */
16150397Sobrien
16250397Sobrien#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
16350397Sobrien  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
16450397Sobrien
16550397Sobrien#undef STARTFILE_SPEC
16650397Sobrien#define STARTFILE_SPEC  "crt0.o%s"
16750397Sobrien
16850397Sobrien#undef ENDFILE_SPEC
16950397Sobrien
170