1 /* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
2 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002
3 Free Software Foundation, Inc.
4 Contributed by Eric Youngdale.
5 Modified for stabs-in-ELF by H.J. Lu.
7 This file is part of GNU CC.
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
24 #define LINUX_DEFAULT_ELF
26 /* Output at beginning of assembler file. */
27 /* The .file command should always begin the output. */
29 #define ASM_FILE_START(FILE) \
31 output_file_directive (FILE, main_input_filename); \
32 if (ix86_asm_dialect == ASM_INTEL) \
33 fputs ("\t.intel_syntax\n", FILE); \
36 #define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)");
38 /* The svr4 ABI for the i386 says that records and unions are returned
40 #undef DEFAULT_PCC_STRUCT_RETURN
41 #define DEFAULT_PCC_STRUCT_RETURN 1
43 #undef ASM_COMMENT_START
44 #define ASM_COMMENT_START "#"
46 #undef DBX_REGISTER_NUMBER
47 #define DBX_REGISTER_NUMBER(n) \
48 (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
50 /* Output assembler code to FILE to call the profiler.
51 To the best of my knowledge, no Linux libc has required the label
52 argument to mcount. */
54 #define NO_PROFILE_COUNTERS
56 #undef FUNCTION_PROFILER
57 #define FUNCTION_PROFILER(FILE, LABELNO) \
60 fprintf (FILE, "\tcall\t*mcount@GOT(%%ebx)\n"); \
62 fprintf (FILE, "\tcall\tmcount\n"); \
65 /* The GLIBC version of mcount for the x86 assumes that there is a
66 frame, so we cannot allow profiling without a frame pointer. */
68 #undef SUBTARGET_FRAME_POINTER_REQUIRED
69 #define SUBTARGET_FRAME_POINTER_REQUIRED current_function_profile
72 #define SIZE_TYPE "unsigned int"
75 #define PTRDIFF_TYPE "int"
78 #define WCHAR_TYPE "long int"
80 #undef WCHAR_TYPE_SIZE
81 #define WCHAR_TYPE_SIZE BITS_PER_WORD
83 #define TARGET_OS_CPP_BUILTINS() \
86 builtin_define_std ("linux"); \
87 builtin_define_std ("unix"); \
88 builtin_define ("__ELF__"); \
89 builtin_define ("__gnu_linux__"); \
90 builtin_assert ("system=posix"); \
93 builtin_define ("__PIC__"); \
94 builtin_define ("__pic__"); \
101 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
103 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
107 #define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
109 /* Provide a LINK_SPEC appropriate for Linux. Here we provide support
110 for the special GCC options -static and -shared, which allow us to
111 link things in one of these three modes by applying the appropriate
112 combinations of options at link-time. We like to support here for
113 as many of the other GNU linker options as possible. But I don't
114 have the time to search for those flags. I am sure how to add
115 support for -soname shared_object_name. H.J.
117 I took out %{v:%{!V:-V}}. It is too much :-(. They can use
120 When the -shared link option is used a final link is not being
123 /* If ELF is the default format, we should not use /lib/elf. */
127 #ifndef LINUX_DEFAULT_ELF
128 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
132 %{rdynamic:-export-dynamic} \
133 %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \
134 %{!rpath:-rpath /lib/elf/}} %{static:-static}}}"
136 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
140 %{rdynamic:-export-dynamic} \
141 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
145 #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
149 %{rdynamic:-export-dynamic} \
150 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
154 /* A C statement (sans semicolon) to output to the stdio stream
155 FILE the assembler definition of uninitialized global DECL named
156 NAME whose size is SIZE bytes and alignment is ALIGN bytes.
157 Try to use asm_output_aligned_bss to implement this macro. */
159 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
160 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
162 /* A C statement to output to the stdio stream FILE an assembler
163 command to advance the location counter to a multiple of 1<<LOG
164 bytes if it is within MAX_SKIP bytes.
166 This is used to align code labels according to Intel recommendations. */
168 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
169 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
172 if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
173 else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
178 #if defined(__PIC__) && defined (USE_GNULIBC_1)
179 /* This is a kludge. The i386 GNU/Linux dynamic linker needs ___brk_addr,
180 __environ and atexit. We have to make sure they are in the .dynsym
181 section. We do this by forcing the assembler to create undefined
182 references to these symbols in the object file. */
183 #undef CRT_CALL_STATIC_FUNCTION
184 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
185 asm (SECTION_OP "\n\t" \
186 "call " USER_LABEL_PREFIX #FUNC "\n" \
187 TEXT_SECTION_ASM_OP "\n\t" \
188 ".extern ___brk_addr\n\t" \
189 ".type ___brk_addr,@object\n\t" \
190 ".extern __environ\n\t" \
191 ".type __environ,@object\n\t" \
192 ".extern atexit\n\t" \
193 ".type atexit,@function");
196 /* Handle special EH pointer encodings. Absolute, pc-relative, and
197 indirect are handled automatically. */
198 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
200 if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel) \
202 fputs (ASM_LONG, FILE); \
203 assemble_name (FILE, XSTR (ADDR, 0)); \
204 fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
209 /* Used by crtstuff.c to initialize the base of data-relative relocations.
210 These are GOT relative on x86, so return the pic register. */
212 #define CRT_GET_RFIB_DATA(BASE) \
214 register void *ebx_ __asm__("ebx"); \
218 #define CRT_GET_RFIB_DATA(BASE) \
219 __asm__ ("call\t.LPR%=\n" \
222 /* Due to a GAS bug, this cannot use EAX. That encodes \
223 smaller than the traditional EBX, which results in the \
224 offset being off by one. */ \
225 "addl\t$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0" \
229 /* Do code reading to identify a signal frame, and set the frame
230 state data appropriately. See unwind-dw2.c for the structs. */
234 #include <sys/ucontext.h>
237 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
239 unsigned char *pc_ = (CONTEXT)->ra; \
240 struct sigcontext *sc_; \
243 /* popl %eax ; movl $__NR_sigreturn,%eax ; int $0x80 */ \
244 if (*(unsigned short *)(pc_+0) == 0xb858 \
245 && *(unsigned int *)(pc_+2) == 119 \
246 && *(unsigned short *)(pc_+6) == 0x80cd) \
247 sc_ = (CONTEXT)->cfa + 4; \
248 /* movl $__NR_rt_sigreturn,%eax ; int $0x80 */ \
249 else if (*(unsigned char *)(pc_+0) == 0xb8 \
250 && *(unsigned int *)(pc_+1) == 173 \
251 && *(unsigned short *)(pc_+5) == 0x80cd) \
253 struct rt_sigframe { \
255 struct siginfo *pinfo; \
257 struct siginfo info; \
258 struct ucontext uc; \
259 } *rt_ = (CONTEXT)->cfa; \
260 sc_ = (struct sigcontext *) &rt_->uc.uc_mcontext; \
265 new_cfa_ = sc_->esp; \
266 (FS)->cfa_how = CFA_REG_OFFSET; \
268 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
270 /* The SVR4 register numbering macros aren't usable in libgcc. */ \
271 (FS)->regs.reg[0].how = REG_SAVED_OFFSET; \
272 (FS)->regs.reg[0].loc.offset = (long)&sc_->eax - new_cfa_; \
273 (FS)->regs.reg[3].how = REG_SAVED_OFFSET; \
274 (FS)->regs.reg[3].loc.offset = (long)&sc_->ebx - new_cfa_; \
275 (FS)->regs.reg[1].how = REG_SAVED_OFFSET; \
276 (FS)->regs.reg[1].loc.offset = (long)&sc_->ecx - new_cfa_; \
277 (FS)->regs.reg[2].how = REG_SAVED_OFFSET; \
278 (FS)->regs.reg[2].loc.offset = (long)&sc_->edx - new_cfa_; \
279 (FS)->regs.reg[6].how = REG_SAVED_OFFSET; \
280 (FS)->regs.reg[6].loc.offset = (long)&sc_->esi - new_cfa_; \
281 (FS)->regs.reg[7].how = REG_SAVED_OFFSET; \
282 (FS)->regs.reg[7].loc.offset = (long)&sc_->edi - new_cfa_; \
283 (FS)->regs.reg[5].how = REG_SAVED_OFFSET; \
284 (FS)->regs.reg[5].loc.offset = (long)&sc_->ebp - new_cfa_; \
285 (FS)->regs.reg[8].how = REG_SAVED_OFFSET; \
286 (FS)->regs.reg[8].loc.offset = (long)&sc_->eip - new_cfa_; \
287 (FS)->retaddr_column = 8; \