1/* Definitions for AMD x86-64 using GNU userspace.
2 Copyright (C) 2001-2023 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka <jh@suse.cz>, based on linux.h.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see 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 %{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 %{!static-pie: \
63 %{rdynamic:-export-dynamic} \
64 %{" SPEC_32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
65 %{" SPEC_64 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \
66 %{" SPEC_X32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKERX32 "}}} \
67 %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}"
68
69#undef LINK_SPEC
70#define LINK_SPEC GNU_USER_TARGET_LINK_SPEC
71
72#if TARGET_64BIT_DEFAULT
73#if TARGET_BI_ARCH == 2
74#define MULTILIB_DEFAULTS { "mx32" }
75#else
76#define MULTILIB_DEFAULTS { "m64" }
77#endif
78#else
79#define MULTILIB_DEFAULTS { "m32" }
80#endif
81
82#ifdef TARGET_LIBC_PROVIDES_SSP
83/* i386 glibc provides __stack_chk_guard in %gs:0x14,
84 x32 glibc provides it in %fs:0x18.
85 x86_64 glibc provides it in %fs:0x28. */
86#define TARGET_THREAD_SSP_OFFSET \
87 (TARGET_64BIT ? (TARGET_X32 ? 0x18 : 0x28) : 0x14)
88
89/* i386 glibc provides __private_ss in %gs:0x30.
90 x32 glibc provides it in %fs:0x40.
91 x86_64 glibc provides it in %fs:0x70. */
92#define TARGET_THREAD_SPLIT_STACK_OFFSET \
93 (TARGET_64BIT ? (TARGET_X32 ? 0x40 : 0x70) : 0x30)
94#endif
95
96#undef WCHAR_TYPE
97#define WCHAR_TYPE (TARGET_LP64 ? "int" : "long int")
98

source code of gcc/config/i386/gnu-user64.h