1 /* Definitions for AMD x86-64 using GNU userspace.
2    Copyright (C) 2001-2014 Free Software Foundation, Inc.
3    Contributed by Jan Hubicka <jh@suse.cz>, based on linux.h.
4 
5 This file is part of GCC.
6 
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
11 
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16 
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
20 
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24 <http://www.gnu.org/licenses/>.  */
25 
26 /* Provide a LINK_SPEC.  Here we provide support for the special GCC
27    options -static and -shared, which allow us to link things in one
28    of these three modes by applying the appropriate combinations of
29    options at link-time.
30 
31    When the -shared link option is used a final link is not being
32    done.  */
33 
34 #if TARGET_64BIT_DEFAULT
35 #define SPEC_32 "m16|m32"
36 #if TARGET_BI_ARCH == 2
37 #define SPEC_64 "m64"
38 #define SPEC_X32 "m16|m32|m64:;"
39 #else
40 #define SPEC_64 "m16|m32|mx32:;"
41 #define SPEC_X32 "mx32"
42 #endif
43 #else
44 #define SPEC_32 "m64|mx32:;"
45 #define SPEC_64 "m64"
46 #define SPEC_X32 "mx32"
47 #endif
48 
49 #undef ASM_SPEC
50 #define ASM_SPEC "%{" SPEC_32 ":--32} \
51  %{" SPEC_64 ":--64} \
52  %{" SPEC_X32 ":--x32} \
53  %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
54 
55 #define GNU_USER_TARGET_LINK_SPEC				   \
56                   "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
57                    %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
58                    %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
59   %{shared:-shared} \
60   %{!shared: \
61     %{!static: \
62       %{rdynamic:-export-dynamic} \
63       %{" SPEC_32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
64       %{" SPEC_64 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
65       %{" SPEC_X32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKERX32 "}} \
66     %{static:-static}}"
67 
68 #undef	LINK_SPEC
69 #define LINK_SPEC GNU_USER_TARGET_LINK_SPEC
70 
71 #if TARGET_64BIT_DEFAULT
72 #if TARGET_BI_ARCH == 2
73 #define MULTILIB_DEFAULTS { "mx32" }
74 #else
75 #define MULTILIB_DEFAULTS { "m64" }
76 #endif
77 #else
78 #define MULTILIB_DEFAULTS { "m32" }
79 #endif
80 
81 #ifdef TARGET_LIBC_PROVIDES_SSP
82 /* i386 glibc provides __stack_chk_guard in %gs:0x14,
83    x32 glibc provides it in %fs:0x18.
84    x86_64 glibc provides it in %fs:0x28.  */
85 #define TARGET_THREAD_SSP_OFFSET \
86   (TARGET_64BIT ? (TARGET_X32 ? 0x18 : 0x28) : 0x14)
87 
88 /* We only build the -fsplit-stack support in libgcc if the
89    assembler has full support for the CFI directives.  */
90 #if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
91 #define TARGET_CAN_SPLIT_STACK
92 #endif
93 /* We steal the last transactional memory word.  */
94 #define TARGET_THREAD_SPLIT_STACK_OFFSET \
95   (TARGET_64BIT ? (TARGET_X32 ? 0x40 : 0x70) : 0x30)
96 #endif
97 
98 #undef WCHAR_TYPE
99 #define WCHAR_TYPE (TARGET_LP64 ? "int" : "long int")
100