150397Sobrien/* Definitions for Intel 386 running Linux-based GNU systems with ELF format. 2169689Skan Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005, 3169689Skan 2006 Free Software Foundation, Inc. 418334Speter Contributed by Eric Youngdale. 518334Speter Modified for stabs-in-ELF by H.J. Lu. 618334Speter 7132718SkanThis file is part of GCC. 818334Speter 9132718SkanGCC is free software; you can redistribute it and/or modify 1018334Speterit under the terms of the GNU General Public License as published by 1118334Speterthe Free Software Foundation; either version 2, or (at your option) 1218334Speterany later version. 1318334Speter 14132718SkanGCC is distributed in the hope that it will be useful, 1518334Speterbut WITHOUT ANY WARRANTY; without even the implied warranty of 1618334SpeterMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1718334SpeterGNU General Public License for more details. 1818334Speter 1918334SpeterYou should have received a copy of the GNU General Public License 20132718Skanalong with GCC; see the file COPYING. If not, write to 21169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 22169689SkanBoston, MA 02110-1301, USA. */ 2318334Speter 2490075Sobrien/* Output at beginning of assembler file. */ 2590075Sobrien/* The .file command should always begin the output. */ 26132718Skan#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true 2718334Speter 2818334Speter#define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)"); 2918334Speter 3018334Speter/* The svr4 ABI for the i386 says that records and unions are returned 3118334Speter in memory. */ 3218334Speter#undef DEFAULT_PCC_STRUCT_RETURN 3318334Speter#define DEFAULT_PCC_STRUCT_RETURN 1 3418334Speter 35132718Skan/* We arrange for the whole %gs segment to map the tls area. */ 36132718Skan#undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT 37132718Skan#define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS 38132718Skan 3950397Sobrien#undef ASM_COMMENT_START 4050397Sobrien#define ASM_COMMENT_START "#" 4150397Sobrien 4218334Speter#undef DBX_REGISTER_NUMBER 4318334Speter#define DBX_REGISTER_NUMBER(n) \ 4490075Sobrien (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n]) 4518334Speter 4690075Sobrien/* Output assembler code to FILE to call the profiler. 4790075Sobrien To the best of my knowledge, no Linux libc has required the label 4890075Sobrien argument to mcount. */ 4918334Speter 50132718Skan#define NO_PROFILE_COUNTERS 1 5190075Sobrien 52117395Skan#undef MCOUNT_NAME 53117395Skan#define MCOUNT_NAME "mcount" 5418334Speter 55117395Skan/* The GLIBC version of mcount for the x86 assumes that there is a 5690075Sobrien frame, so we cannot allow profiling without a frame pointer. */ 5790075Sobrien 58117395Skan#undef SUBTARGET_FRAME_POINTER_REQUIRED 59117395Skan#define SUBTARGET_FRAME_POINTER_REQUIRED current_function_profile 6090075Sobrien 6118334Speter#undef SIZE_TYPE 6218334Speter#define SIZE_TYPE "unsigned int" 6318334Speter 6418334Speter#undef PTRDIFF_TYPE 6518334Speter#define PTRDIFF_TYPE "int" 6618334Speter 6718334Speter#undef WCHAR_TYPE 6818334Speter#define WCHAR_TYPE "long int" 6918334Speter 7018334Speter#undef WCHAR_TYPE_SIZE 7118334Speter#define WCHAR_TYPE_SIZE BITS_PER_WORD 7218334Speter 73117395Skan#define TARGET_OS_CPP_BUILTINS() \ 74117395Skan do \ 75117395Skan { \ 76132718Skan LINUX_TARGET_OS_CPP_BUILTINS(); \ 77117395Skan } \ 78117395Skan while (0) 7918334Speter 8018334Speter#undef CPP_SPEC 81117395Skan#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" 8218334Speter 8350397Sobrien#undef CC1_SPEC 8450397Sobrien#define CC1_SPEC "%(cc1_cpu) %{profile:-p}" 8548743Sobrien 8618334Speter/* Provide a LINK_SPEC appropriate for Linux. Here we provide support 8718334Speter for the special GCC options -static and -shared, which allow us to 8818334Speter link things in one of these three modes by applying the appropriate 8918334Speter combinations of options at link-time. We like to support here for 9018334Speter as many of the other GNU linker options as possible. But I don't 9118334Speter have the time to search for those flags. I am sure how to add 9218334Speter support for -soname shared_object_name. H.J. 9318334Speter 9418334Speter I took out %{v:%{!V:-V}}. It is too much :-(. They can use 9518334Speter -Wl,-V. 9618334Speter 9718334Speter When the -shared link option is used a final link is not being 9818334Speter done. */ 9918334Speter 10090075Sobrien/* If ELF is the default format, we should not use /lib/elf. */ 10118334Speter 102169689Skan/* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */ 103169689Skan#define LINK_EMULATION "elf_i386" 104169689Skan#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" 105169689Skan 106169689Skan#undef SUBTARGET_EXTRA_SPECS 107169689Skan#define SUBTARGET_EXTRA_SPECS \ 108169689Skan { "link_emulation", LINK_EMULATION },\ 109169689Skan { "dynamic_linker", LINUX_DYNAMIC_LINKER } 110169689Skan 11118334Speter#undef LINK_SPEC 112169689Skan#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ 11318334Speter %{!shared: \ 11418334Speter %{!ibcs: \ 11518334Speter %{!static: \ 11618334Speter %{rdynamic:-export-dynamic} \ 117169689Skan %{!dynamic-linker:-dynamic-linker %(dynamic_linker)}} \ 11818334Speter %{static:-static}}}" 11918334Speter 120169689Skan/* Similar to standard Linux, but adding -ffast-math support. */ 121169689Skan#undef ENDFILE_SPEC 122169689Skan#define ENDFILE_SPEC \ 123169689Skan "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ 124169689Skan %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" 125169689Skan 12650397Sobrien/* A C statement (sans semicolon) to output to the stdio stream 12750397Sobrien FILE the assembler definition of uninitialized global DECL named 12850397Sobrien NAME whose size is SIZE bytes and alignment is ALIGN bytes. 12950397Sobrien Try to use asm_output_aligned_bss to implement this macro. */ 13050397Sobrien 13150397Sobrien#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 13250397Sobrien asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 13350397Sobrien 13450397Sobrien/* A C statement to output to the stdio stream FILE an assembler 13550397Sobrien command to advance the location counter to a multiple of 1<<LOG 13650397Sobrien bytes if it is within MAX_SKIP bytes. 13750397Sobrien 13850397Sobrien This is used to align code labels according to Intel recommendations. */ 13950397Sobrien 14050397Sobrien#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN 14152284Sobrien#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ 14252284Sobrien do { \ 14352284Sobrien if ((LOG) != 0) { \ 14452284Sobrien if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ 14552284Sobrien else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ 14652284Sobrien } \ 14752284Sobrien } while (0) 14850397Sobrien#endif 14990075Sobrien 15090075Sobrien/* Handle special EH pointer encodings. Absolute, pc-relative, and 15190075Sobrien indirect are handled automatically. */ 15290075Sobrien#define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \ 15390075Sobrien do { \ 15490075Sobrien if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel) \ 15590075Sobrien { \ 15690075Sobrien fputs (ASM_LONG, FILE); \ 15790075Sobrien assemble_name (FILE, XSTR (ADDR, 0)); \ 15890075Sobrien fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \ 15990075Sobrien goto DONE; \ 16090075Sobrien } \ 16190075Sobrien } while (0) 16290075Sobrien 16390075Sobrien/* Used by crtstuff.c to initialize the base of data-relative relocations. 16490075Sobrien These are GOT relative on x86, so return the pic register. */ 16590075Sobrien#ifdef __PIC__ 16690075Sobrien#define CRT_GET_RFIB_DATA(BASE) \ 16790075Sobrien { \ 16890075Sobrien register void *ebx_ __asm__("ebx"); \ 16990075Sobrien BASE = ebx_; \ 17090075Sobrien } 17190075Sobrien#else 17290075Sobrien#define CRT_GET_RFIB_DATA(BASE) \ 17390075Sobrien __asm__ ("call\t.LPR%=\n" \ 17490075Sobrien ".LPR%=:\n\t" \ 17590075Sobrien "popl\t%0\n\t" \ 17690075Sobrien /* Due to a GAS bug, this cannot use EAX. That encodes \ 17790075Sobrien smaller than the traditional EBX, which results in the \ 17890075Sobrien offset being off by one. */ \ 17990075Sobrien "addl\t$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0" \ 18090075Sobrien : "=d"(BASE)) 18190075Sobrien#endif 18290075Sobrien 183132718Skan#undef NEED_INDICATE_EXEC_STACK 184132718Skan#define NEED_INDICATE_EXEC_STACK 1 185132718Skan 186169689Skan#define MD_UNWIND_SUPPORT "config/i386/linux-unwind.h" 18790075Sobrien 188169689Skan/* This macro may be overridden in i386/k*bsd-gnu.h. */ 189169689Skan#define REG_NAME(reg) reg 19090075Sobrien 191169689Skan#ifdef TARGET_LIBC_PROVIDES_SSP 192169689Skan/* i386 glibc provides __stack_chk_guard in %gs:0x14. */ 193169689Skan#define TARGET_THREAD_SSP_OFFSET 0x14 194169689Skan#endif 195