c93d9757d5077ef7f30f670bcaa0de058f7974e6
[platform/upstream/gcc48.git] / gcc / config / i386 / gnu-user.h
1 /* Definitions for Intel 386 systems using GNU userspace.
2    Copyright (C) 1994-2013 Free Software Foundation, Inc.
3    Contributed by Eric Youngdale.
4    Modified for stabs-in-ELF by H.J. Lu.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 /* Output at beginning of assembler file.  */
23 /* The .file command should always begin the output.  */
24 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
25
26 #undef ASM_COMMENT_START
27 #define ASM_COMMENT_START "#"
28
29 #undef DBX_REGISTER_NUMBER
30 #define DBX_REGISTER_NUMBER(n) \
31   (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
32
33 /* Output assembler code to FILE to call the profiler.
34    To the best of my knowledge, no GNU userspace libc has required the label
35    argument to mcount.  */
36
37 #define NO_PROFILE_COUNTERS     1
38
39 #undef MCOUNT_NAME
40 #define MCOUNT_NAME "mcount"
41
42 /* The GLIBC version of mcount for the x86 assumes that there is a
43    frame, so we cannot allow profiling without a frame pointer.  */
44
45 #undef SUBTARGET_FRAME_POINTER_REQUIRED
46 #define SUBTARGET_FRAME_POINTER_REQUIRED crtl->profile
47
48 #undef SIZE_TYPE
49 #define SIZE_TYPE "unsigned int"
50  
51 #undef PTRDIFF_TYPE
52 #define PTRDIFF_TYPE "int"
53   
54 #undef WCHAR_TYPE
55 #define WCHAR_TYPE "long int"
56    
57 #undef WCHAR_TYPE_SIZE
58 #define WCHAR_TYPE_SIZE BITS_PER_WORD
59     
60 /* Provide a LINK_SPEC appropriate for GNU userspace.  Here we provide support
61    for the special GCC options -static and -shared, which allow us to
62    link things in one of these three modes by applying the appropriate
63    combinations of options at link-time.
64
65    When the -shared link option is used a final link is not being
66    done.  */
67
68 #undef  ASM_SPEC
69 #define ASM_SPEC \
70   "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
71
72 #undef  SUBTARGET_EXTRA_SPECS
73 #define SUBTARGET_EXTRA_SPECS \
74   { "link_emulation", GNU_USER_LINK_EMULATION },\
75   { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
76
77 #define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
78   %{!shared: \
79     %{!static: \
80       %{rdynamic:-export-dynamic} \
81       -dynamic-linker %(dynamic_linker)} \
82       %{static:-static}}"
83
84 #undef  LINK_SPEC
85 #define LINK_SPEC GNU_USER_TARGET_LINK_SPEC
86
87 /* A C statement (sans semicolon) to output to the stdio stream
88    FILE the assembler definition of uninitialized global DECL named
89    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
90    Try to use asm_output_aligned_bss to implement this macro.  */
91
92 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
93   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
94
95 /* A C statement to output to the stdio stream FILE an assembler
96    command to advance the location counter to a multiple of 1<<LOG
97    bytes if it is within MAX_SKIP bytes.
98
99    This is used to align code labels according to Intel recommendations.  */
100
101 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
102 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)                    \
103   do {                                                                  \
104     if ((LOG) != 0) {                                                   \
105       if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));  \
106       else {                                                            \
107         fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));     \
108         /* Make sure that we have at least 8 byte alignment if > 8 byte \
109            alignment is preferred.  */                                  \
110         if ((LOG) > 3                                                   \
111             && (1 << (LOG)) > ((MAX_SKIP) + 1)                          \
112             && (MAX_SKIP) >= 7)                                         \
113           fputs ("\t.p2align 3\n", (FILE));                             \
114       }                                                                 \
115     }                                                                   \
116   } while (0)
117 #endif
118
119 /* Handle special EH pointer encodings.  Absolute, pc-relative, and
120    indirect are handled automatically.  */
121 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
122   do {                                                                  \
123     if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel)         \
124       {                                                                 \
125         fputs (ASM_LONG, FILE);                 \
126         assemble_name (FILE, XSTR (ADDR, 0));                           \
127         fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
128         goto DONE;                                                      \
129       }                                                                 \
130   } while (0)
131
132 /* Used by crtstuff.c to initialize the base of data-relative relocations.
133    These are GOT relative on x86, so return the pic register.  */
134 #ifdef __PIC__
135 #define CRT_GET_RFIB_DATA(BASE)                 \
136   {                                             \
137     register void *ebx_ __asm__("ebx");         \
138     BASE = ebx_;                                \
139   }
140 #else
141 #define CRT_GET_RFIB_DATA(BASE)                                         \
142   __asm__ ("call\t.LPR%=\n"                                             \
143            ".LPR%=:\n\t"                                                \
144            "pop{l}\t%0\n\t"                                             \
145            /* Due to a GAS bug, this cannot use EAX.  That encodes      \
146               smaller than the traditional EBX, which results in the    \
147               offset being off by one.  */                              \
148            "add{l}\t{$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"              \
149                    "|%0,_GLOBAL_OFFSET_TABLE_+(.-.LPR%=)}"              \
150            : "=d"(BASE))
151 #endif
152
153 #ifdef TARGET_LIBC_PROVIDES_SSP
154 /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
155 #define TARGET_THREAD_SSP_OFFSET        0x14
156
157 /* We only build the -fsplit-stack support in libgcc if the
158    assembler has full support for the CFI directives.  */
159 #if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
160 #define TARGET_CAN_SPLIT_STACK
161 #endif
162 /* We steal the last transactional memory word.  */
163 #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
164 #endif