1/* Definitions for Linux for S/390.
2   Copyright (C) 1999-2022 Free Software Foundation, Inc.
3   Contributed by Hartmut Penner (hpenner@de.ibm.com) and
4                  Ulrich Weigand (uweigand@de.ibm.com).
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along with GCC; see the file COPYING3.  If not see
20<http://www.gnu.org/licenses/>.  */
21
22#ifndef _LINUX_H
23#define _LINUX_H
24
25/* Target specific type definitions.  */
26
27/* For 31 bit our size type differs from most other targets (where it
28   is "unsigned int").  The difference tends to cause trouble e.g.:
29   Glibc BZ #16712, GCC BZ #79358 but cannot be changed due to ABI
30   issues.  */
31#undef  SIZE_TYPE
32#define SIZE_TYPE "long unsigned int"
33#undef  PTRDIFF_TYPE
34#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
35
36#undef  WCHAR_TYPE
37#define WCHAR_TYPE "int"
38#undef  WCHAR_TYPE_SIZE
39#define WCHAR_TYPE_SIZE 32
40
41
42/* Target specific preprocessor settings.  */
43
44#define TARGET_OS_CPP_BUILTINS()		\
45  do						\
46    {						\
47      GNU_USER_TARGET_OS_CPP_BUILTINS();	\
48    }						\
49  while (0)
50
51
52/* Target specific assembler settings.  */
53/* Rewrite -march=arch* options to the original CPU name in order to
54   make it work with older binutils.  */
55#undef  ASM_SPEC
56#define ASM_SPEC					\
57  "%{m31&m64}%{mesa&mzarch}%{march=z*}"			\
58  "%{march=arch5:-march=z900}"				\
59  "%{march=arch6:-march=z990}"				\
60  "%{march=arch7:-march=z9-ec}"				\
61  "%{march=arch8:-march=z10}"				\
62  "%{march=arch9:-march=z196}"				\
63  "%{march=arch10:-march=zEC12}"			\
64  "%{march=arch11:-march=z13}"
65
66
67/* Target specific linker settings.  */
68
69#ifdef DEFAULT_TARGET_64BIT
70#define MULTILIB_DEFAULTS { "m64" }
71#else
72#define MULTILIB_DEFAULTS { "m31" }
73#endif
74
75#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
76#define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1"
77
78#undef MUSL_DYNAMIC_LINKER32
79#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390.so.1"
80#undef MUSL_DYNAMIC_LINKER64
81#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1"
82
83#undef  LINK_SPEC
84#define LINK_SPEC \
85  "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
86   %{shared:-shared} \
87   %{!shared: \
88      %{static:-static} \
89      %{!static:%{!static-pie: \
90	%{rdynamic:-export-dynamic} \
91	%{m31:-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \
92	%{m64:-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}}} \
93   %{static-pie:-static -pie --no-dynamic-linker -z text}"
94
95#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
96
97#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
98
99#ifdef TARGET_LIBC_PROVIDES_SSP
100/* s390 glibc provides __stack_chk_guard in 0x14(tp),
101   s390x glibc provides it at 0x28(tp).  */
102#define TARGET_THREAD_SSP_OFFSET        (TARGET_64BIT ? 0x28 : 0x14)
103#endif
104
105/* Define if long doubles should be mangled as 'g'.  */
106#define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING
107
108#undef TARGET_LIBC_HAS_FUNCTION
109#define TARGET_LIBC_HAS_FUNCTION gnu_libc_has_function
110
111/* Uninitialized common symbols in non-PIE executables, even with
112   strong definitions in dependent shared libraries, will resolve
113   to COPY relocated symbol in the executable.  See PR65780.  */
114#undef TARGET_BINDS_LOCAL_P
115#define TARGET_BINDS_LOCAL_P default_binds_local_p_2
116
117#endif
118