linux.h revision 169689
1168515Sgshapiro/* Definitions for Intel 386 running Linux-based GNU systems with ELF format. 2168515Sgshapiro Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005, 3168515Sgshapiro 2006 Free Software Foundation, Inc. 4168515Sgshapiro Contributed by Eric Youngdale. 5266692Sgshapiro Modified for stabs-in-ELF by H.J. Lu. 6168515Sgshapiro 7168515SgshapiroThis file is part of GCC. 8168515Sgshapiro 9168515SgshapiroGCC is free software; you can redistribute it and/or modify 10168515Sgshapiroit under the terms of the GNU General Public License as published by 11168515Sgshapirothe Free Software Foundation; either version 2, or (at your option) 12168515Sgshapiroany later version. 13168515Sgshapiro 14168515SgshapiroGCC is distributed in the hope that it will be useful, 15168515Sgshapirobut WITHOUT ANY WARRANTY; without even the implied warranty of 16168515SgshapiroMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17168515SgshapiroGNU General Public License for more details. 18168515Sgshapiro 19168515SgshapiroYou should have received a copy of the GNU General Public License 20168515Sgshapiroalong with GCC; see the file COPYING. If not, write to 21168515Sgshapirothe Free Software Foundation, 51 Franklin Street, Fifth Floor, 22168515SgshapiroBoston, MA 02110-1301, USA. */ 23168515Sgshapiro 24168515Sgshapiro/* Output at beginning of assembler file. */ 25168515Sgshapiro/* The .file command should always begin the output. */ 26168515Sgshapiro#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true 27168515Sgshapiro 28168515Sgshapiro#define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)"); 29168515Sgshapiro 30168515Sgshapiro/* The svr4 ABI for the i386 says that records and unions are returned 31168515Sgshapiro in memory. */ 32168515Sgshapiro#undef DEFAULT_PCC_STRUCT_RETURN 33168515Sgshapiro#define DEFAULT_PCC_STRUCT_RETURN 1 34168515Sgshapiro 35168515Sgshapiro/* We arrange for the whole %gs segment to map the tls area. */ 36168515Sgshapiro#undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT 37168515Sgshapiro#define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS 38168515Sgshapiro 39168515Sgshapiro#undef ASM_COMMENT_START 40168515Sgshapiro#define ASM_COMMENT_START "#" 41168515Sgshapiro 42168515Sgshapiro#undef DBX_REGISTER_NUMBER 43168515Sgshapiro#define DBX_REGISTER_NUMBER(n) \ 44168515Sgshapiro (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n]) 45168515Sgshapiro 46168515Sgshapiro/* Output assembler code to FILE to call the profiler. 47168515Sgshapiro To the best of my knowledge, no Linux libc has required the label 48168515Sgshapiro argument to mcount. */ 49168515Sgshapiro 50168515Sgshapiro#define NO_PROFILE_COUNTERS 1 51168515Sgshapiro 52168515Sgshapiro#undef MCOUNT_NAME 53168515Sgshapiro#define MCOUNT_NAME "mcount" 54168515Sgshapiro 55168515Sgshapiro/* The GLIBC version of mcount for the x86 assumes that there is a 56168515Sgshapiro frame, so we cannot allow profiling without a frame pointer. */ 57168515Sgshapiro 58168515Sgshapiro#undef SUBTARGET_FRAME_POINTER_REQUIRED 59168515Sgshapiro#define SUBTARGET_FRAME_POINTER_REQUIRED current_function_profile 60168515Sgshapiro 61168515Sgshapiro#undef SIZE_TYPE 62168515Sgshapiro#define SIZE_TYPE "unsigned int" 63168515Sgshapiro 64168515Sgshapiro#undef PTRDIFF_TYPE 65168515Sgshapiro#define PTRDIFF_TYPE "int" 66168515Sgshapiro 67168515Sgshapiro#undef WCHAR_TYPE 68168515Sgshapiro#define WCHAR_TYPE "long int" 69168515Sgshapiro 70168515Sgshapiro#undef WCHAR_TYPE_SIZE 71168515Sgshapiro#define WCHAR_TYPE_SIZE BITS_PER_WORD 72168515Sgshapiro 73168515Sgshapiro#define TARGET_OS_CPP_BUILTINS() \ 74168515Sgshapiro do \ 75168515Sgshapiro { \ 76168515Sgshapiro LINUX_TARGET_OS_CPP_BUILTINS(); \ 77168515Sgshapiro } \ 78168515Sgshapiro while (0) 79168515Sgshapiro 80168515Sgshapiro#undef CPP_SPEC 81168515Sgshapiro#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" 82168515Sgshapiro 83168515Sgshapiro#undef CC1_SPEC 84168515Sgshapiro#define CC1_SPEC "%(cc1_cpu) %{profile:-p}" 85168515Sgshapiro 86168515Sgshapiro/* Provide a LINK_SPEC appropriate for Linux. Here we provide support 87168515Sgshapiro for the special GCC options -static and -shared, which allow us to 88168515Sgshapiro link things in one of these three modes by applying the appropriate 89168515Sgshapiro combinations of options at link-time. We like to support here for 90168515Sgshapiro as many of the other GNU linker options as possible. But I don't 91168515Sgshapiro have the time to search for those flags. I am sure how to add 92168515Sgshapiro support for -soname shared_object_name. H.J. 93168515Sgshapiro 94168515Sgshapiro I took out %{v:%{!V:-V}}. It is too much :-(. They can use 95168515Sgshapiro -Wl,-V. 96168515Sgshapiro 97168515Sgshapiro When the -shared link option is used a final link is not being 98168515Sgshapiro done. */ 99168515Sgshapiro 100168515Sgshapiro/* If ELF is the default format, we should not use /lib/elf. */ 101168515Sgshapiro 102168515Sgshapiro/* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */ 103168515Sgshapiro#define LINK_EMULATION "elf_i386" 104168515Sgshapiro#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" 105168515Sgshapiro 106168515Sgshapiro#undef SUBTARGET_EXTRA_SPECS 107168515Sgshapiro#define SUBTARGET_EXTRA_SPECS \ 108168515Sgshapiro { "link_emulation", LINK_EMULATION },\ 109168515Sgshapiro { "dynamic_linker", LINUX_DYNAMIC_LINKER } 110168515Sgshapiro 111168515Sgshapiro#undef LINK_SPEC 112168515Sgshapiro#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ 113168515Sgshapiro %{!shared: \ 114168515Sgshapiro %{!ibcs: \ 115168515Sgshapiro %{!static: \ 116168515Sgshapiro %{rdynamic:-export-dynamic} \ 117168515Sgshapiro %{!dynamic-linker:-dynamic-linker %(dynamic_linker)}} \ 118168515Sgshapiro %{static:-static}}}" 119168515Sgshapiro 120168515Sgshapiro/* Similar to standard Linux, but adding -ffast-math support. */ 121168515Sgshapiro#undef ENDFILE_SPEC 122168515Sgshapiro#define ENDFILE_SPEC \ 123168515Sgshapiro "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ 124168515Sgshapiro %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" 125168515Sgshapiro 126168515Sgshapiro/* A C statement (sans semicolon) to output to the stdio stream 127168515Sgshapiro FILE the assembler definition of uninitialized global DECL named 128168515Sgshapiro NAME whose size is SIZE bytes and alignment is ALIGN bytes. 129168515Sgshapiro Try to use asm_output_aligned_bss to implement this macro. */ 130168515Sgshapiro 131168515Sgshapiro#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 132168515Sgshapiro asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 133168515Sgshapiro 134168515Sgshapiro/* A C statement to output to the stdio stream FILE an assembler 135168515Sgshapiro command to advance the location counter to a multiple of 1<<LOG 136168515Sgshapiro bytes if it is within MAX_SKIP bytes. 137168515Sgshapiro 138168515Sgshapiro This is used to align code labels according to Intel recommendations. */ 139168515Sgshapiro 140168515Sgshapiro#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN 141168515Sgshapiro#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ 142168515Sgshapiro do { \ 143168515Sgshapiro if ((LOG) != 0) { \ 144168515Sgshapiro if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ 145168515Sgshapiro else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ 146168515Sgshapiro } \ 147168515Sgshapiro } while (0) 148168515Sgshapiro#endif 149168515Sgshapiro 150168515Sgshapiro/* Handle special EH pointer encodings. Absolute, pc-relative, and 151168515Sgshapiro indirect are handled automatically. */ 152168515Sgshapiro#define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \ 153168515Sgshapiro do { \ 154168515Sgshapiro if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel) \ 155168515Sgshapiro { \ 156168515Sgshapiro fputs (ASM_LONG, FILE); \ 157168515Sgshapiro assemble_name (FILE, XSTR (ADDR, 0)); \ 158168515Sgshapiro fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \ 159168515Sgshapiro goto DONE; \ 160168515Sgshapiro } \ 161168515Sgshapiro } while (0) 162168515Sgshapiro 163168515Sgshapiro/* Used by crtstuff.c to initialize the base of data-relative relocations. 164168515Sgshapiro These are GOT relative on x86, so return the pic register. */ 165168515Sgshapiro#ifdef __PIC__ 166168515Sgshapiro#define CRT_GET_RFIB_DATA(BASE) \ 167168515Sgshapiro { \ 168168515Sgshapiro register void *ebx_ __asm__("ebx"); \ 169168515Sgshapiro BASE = ebx_; \ 170168515Sgshapiro } 171168515Sgshapiro#else 172168515Sgshapiro#define CRT_GET_RFIB_DATA(BASE) \ 173168515Sgshapiro __asm__ ("call\t.LPR%=\n" \ 174168515Sgshapiro ".LPR%=:\n\t" \ 175168515Sgshapiro "popl\t%0\n\t" \ 176168515Sgshapiro /* Due to a GAS bug, this cannot use EAX. That encodes \ 177168515Sgshapiro smaller than the traditional EBX, which results in the \ 178168515Sgshapiro offset being off by one. */ \ 179168515Sgshapiro "addl\t$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0" \ 180168515Sgshapiro : "=d"(BASE)) 181168515Sgshapiro#endif 182168515Sgshapiro 183168515Sgshapiro#undef NEED_INDICATE_EXEC_STACK 184168515Sgshapiro#define NEED_INDICATE_EXEC_STACK 1 185168515Sgshapiro 186168515Sgshapiro#define MD_UNWIND_SUPPORT "config/i386/linux-unwind.h" 187168515Sgshapiro 188168515Sgshapiro/* This macro may be overridden in i386/k*bsd-gnu.h. */ 189168515Sgshapiro#define REG_NAME(reg) reg 190168515Sgshapiro 191168515Sgshapiro#ifdef TARGET_LIBC_PROVIDES_SSP 192168515Sgshapiro/* i386 glibc provides __stack_chk_guard in %gs:0x14. */ 193168515Sgshapiro#define TARGET_THREAD_SSP_OFFSET 0x14 194168515Sgshapiro#endif 195168515Sgshapiro