1/* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
2   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
3   2006 Free Software Foundation, Inc.
4   Contributed by Eric Youngdale.
5   Modified for stabs-in-ELF by H.J. Lu.
6
7This file is part of GCC.
8
9GCC is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2, or (at your option)
12any later version.
13
14GCC is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GCC; see the file COPYING.  If not, write to
21the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22Boston, MA 02110-1301, USA.  */
23
24/* Output at beginning of assembler file.  */
25/* The .file command should always begin the output.  */
26#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
27
28#define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)");
29
30/* The svr4 ABI for the i386 says that records and unions are returned
31   in memory.  */
32#undef DEFAULT_PCC_STRUCT_RETURN
33#define DEFAULT_PCC_STRUCT_RETURN 1
34
35/* We arrange for the whole %gs segment to map the tls area.  */
36#undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT
37#define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS
38
39#undef ASM_COMMENT_START
40#define ASM_COMMENT_START "#"
41
42#undef DBX_REGISTER_NUMBER
43#define DBX_REGISTER_NUMBER(n) \
44  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
45
46/* Output assembler code to FILE to call the profiler.
47   To the best of my knowledge, no Linux libc has required the label
48   argument to mcount.  */
49
50#define NO_PROFILE_COUNTERS	1
51
52#undef MCOUNT_NAME
53#define MCOUNT_NAME "mcount"
54
55/* The GLIBC version of mcount for the x86 assumes that there is a
56   frame, so we cannot allow profiling without a frame pointer.  */
57
58#undef SUBTARGET_FRAME_POINTER_REQUIRED
59#define SUBTARGET_FRAME_POINTER_REQUIRED current_function_profile
60
61#undef SIZE_TYPE
62#define SIZE_TYPE "unsigned int"
63
64#undef PTRDIFF_TYPE
65#define PTRDIFF_TYPE "int"
66
67#undef WCHAR_TYPE
68#define WCHAR_TYPE "long int"
69
70#undef WCHAR_TYPE_SIZE
71#define WCHAR_TYPE_SIZE BITS_PER_WORD
72
73#define TARGET_OS_CPP_BUILTINS()		\
74  do						\
75    {						\
76	LINUX_TARGET_OS_CPP_BUILTINS();		\
77    }						\
78  while (0)
79
80#undef CPP_SPEC
81#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
82
83#undef CC1_SPEC
84#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
85
86/* Provide a LINK_SPEC appropriate for Linux.  Here we provide support
87   for the special GCC options -static and -shared, which allow us to
88   link things in one of these three modes by applying the appropriate
89   combinations of options at link-time. We like to support here for
90   as many of the other GNU linker options as possible. But I don't
91   have the time to search for those flags. I am sure how to add
92   support for -soname shared_object_name. H.J.
93
94   I took out %{v:%{!V:-V}}. It is too much :-(. They can use
95   -Wl,-V.
96
97   When the -shared link option is used a final link is not being
98   done.  */
99
100/* If ELF is the default format, we should not use /lib/elf.  */
101
102/* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
103#define LINK_EMULATION "elf_i386"
104#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
105
106#undef  SUBTARGET_EXTRA_SPECS
107#define SUBTARGET_EXTRA_SPECS \
108  { "link_emulation", LINK_EMULATION },\
109  { "dynamic_linker", LINUX_DYNAMIC_LINKER }
110
111#undef	LINK_SPEC
112#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
113  %{!shared: \
114    %{!ibcs: \
115      %{!static: \
116	%{rdynamic:-export-dynamic} \
117	%{!dynamic-linker:-dynamic-linker %(dynamic_linker)}} \
118	%{static:-static}}}"
119
120/* Similar to standard Linux, but adding -ffast-math support.  */
121#undef  ENDFILE_SPEC
122#define ENDFILE_SPEC \
123  "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
124   %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
125
126/* A C statement (sans semicolon) to output to the stdio stream
127   FILE the assembler definition of uninitialized global DECL named
128   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
129   Try to use asm_output_aligned_bss to implement this macro.  */
130
131#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
132  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
133
134/* A C statement to output to the stdio stream FILE an assembler
135   command to advance the location counter to a multiple of 1<<LOG
136   bytes if it is within MAX_SKIP bytes.
137
138   This is used to align code labels according to Intel recommendations.  */
139
140#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
141#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)			\
142  do {									\
143    if ((LOG) != 0) {							\
144      if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));	\
145      else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
146    }									\
147  } while (0)
148#endif
149
150/* Handle special EH pointer encodings.  Absolute, pc-relative, and
151   indirect are handled automatically.  */
152#define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
153  do {									\
154    if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel)		\
155      {									\
156        fputs (ASM_LONG, FILE);			\
157        assemble_name (FILE, XSTR (ADDR, 0));				\
158	fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
159        goto DONE;							\
160      }									\
161  } while (0)
162
163/* Used by crtstuff.c to initialize the base of data-relative relocations.
164   These are GOT relative on x86, so return the pic register.  */
165#ifdef __PIC__
166#define CRT_GET_RFIB_DATA(BASE)			\
167  {						\
168    register void *ebx_ __asm__("ebx");		\
169    BASE = ebx_;				\
170  }
171#else
172#define CRT_GET_RFIB_DATA(BASE)						\
173  __asm__ ("call\t.LPR%=\n"						\
174	   ".LPR%=:\n\t"						\
175	   "popl\t%0\n\t"						\
176	   /* Due to a GAS bug, this cannot use EAX.  That encodes	\
177	      smaller than the traditional EBX, which results in the	\
178	      offset being off by one.  */				\
179	   "addl\t$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"			\
180	   : "=d"(BASE))
181#endif
182
183#undef NEED_INDICATE_EXEC_STACK
184#define NEED_INDICATE_EXEC_STACK 1
185
186#define MD_UNWIND_SUPPORT "config/i386/linux-unwind.h"
187
188/* This macro may be overridden in i386/k*bsd-gnu.h.  */
189#define REG_NAME(reg) reg
190
191#ifdef TARGET_LIBC_PROVIDES_SSP
192/* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
193#define TARGET_THREAD_SSP_OFFSET	0x14
194#endif
195