]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/sh/linux.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / sh / linux.h
CommitLineData
93ca1662 1/* Definitions for SH running Linux-based GNU systems using ELF
7adcbafe 2 Copyright (C) 1999-2022 Free Software Foundation, Inc.
93ca1662
NY
3 Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
4
7ec022b2 5This file is part of GCC.
93ca1662 6
7ec022b2 7GCC is free software; you can redistribute it and/or modify
93ca1662 8it under the terms of the GNU General Public License as published by
2f83c7d6 9the Free Software Foundation; either version 3, or (at your option)
93ca1662
NY
10any later version.
11
7ec022b2 12GCC is distributed in the hope that it will be useful,
93ca1662
NY
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
17You should have received a copy of the GNU General Public License
2f83c7d6
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
93ca1662
NY
20
21/* Run-time Target Specification. */
93ca1662 22
4977bab6
ZW
23/* Enable DWARF 2 exceptions. */
24#undef DWARF2_UNWIND_INFO
25#define DWARF2_UNWIND_INFO 1
26
f636e2a5
AH
27#undef SUBTARGET_CPP_SPEC
28#define SUBTARGET_CPP_SPEC "\
93ca1662 29 %{posix:-D_POSIX_SOURCE} \
f636e2a5
AH
30 %{pthread:-D_REENTRANT -D_PTHREADS} \
31"
32
f1a58d92 33#define TARGET_OS_CPP_BUILTINS() \
65f527e0
KK
34 do \
35 { \
107fd1c1 36 GNU_USER_TARGET_OS_CPP_BUILTINS(); \
65f527e0
KK
37 } \
38 while (0)
f1a58d92
R
39
40#undef TARGET_DEFAULT
41#define TARGET_DEFAULT \
ee0d2b68 42 (TARGET_CPU_DEFAULT | TARGET_ENDIAN_DEFAULT | TARGET_OPT_DEFAULT)
f1a58d92 43
43c73004
KK
44#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
45
51090a41
GR
46#if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
47#define MUSL_DYNAMIC_LINKER_E "%{mb:eb}"
48#else
49#define MUSL_DYNAMIC_LINKER_E "%{!ml:eb}"
50#endif
51
52#if TARGET_CPU_DEFAULT & (MASK_HARD_SH2A_DOUBLE | MASK_SH4)
53/* "-nofpu" if any nofpu option is specified. */
54#define MUSL_DYNAMIC_LINKER_FP \
55 "%{m1|m2|m2a-nofpu|m3|m4-nofpu|m4-100-nofpu|m4-200-nofpu|m4-300-nofpu|" \
56 "m4-340|m4-400|m4-500|m4al:-nofpu}"
57#else
58/* "-nofpu" if none of the hard fpu options are specified. */
59#define MUSL_DYNAMIC_LINKER_FP "%{m2a|m4|m4-100|m4-200|m4-300|m4a:;:-nofpu}"
60#endif
61
62#undef MUSL_DYNAMIC_LINKER
63#define MUSL_DYNAMIC_LINKER \
64 "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
65 "%{mfdpic:-fdpic}.so.1"
66
7bd85ce0
JM
67#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
68
f1a58d92 69#undef SUBTARGET_LINK_EMUL_SUFFIX
1e44e857
DJ
70#define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}"
71
f1a58d92
R
72#undef SUBTARGET_LINK_SPEC
73#define SUBTARGET_LINK_SPEC \
74 "%{shared:-shared} \
93ca1662
NY
75 %{!static: \
76 %{rdynamic:-export-dynamic} \
107fd1c1 77 -dynamic-linker " GNU_USER_DYNAMIC_LINKER "} \
93ca1662
NY
78 %{static:-static}"
79
4977bab6 80/* Output assembler code to STREAM to call the profiler. */
4977bab6
ZW
81#undef FUNCTION_PROFILER
82#define FUNCTION_PROFILER(STREAM,LABELNO) \
83 do { \
ae88d80c
KK
84 if (flag_pic) \
85 { \
86 fprintf (STREAM, "\tmov.l\t3f,r1\n"); \
87 fprintf (STREAM, "\tmova\t3f,r0\n"); \
88 fprintf (STREAM, "\tadd\tr1,r0\n"); \
89 fprintf (STREAM, "\tmov.l\t1f,r1\n"); \
90 fprintf (STREAM, "\tmov.l\t@(r0,r1),r1\n"); \
91 } \
92 else \
93 fprintf (STREAM, "\tmov.l\t1f,r1\n"); \
94 fprintf (STREAM, "\tsts.l\tpr,@-r15\n"); \
95 fprintf (STREAM, "\tmova\t2f,r0\n"); \
96 fprintf (STREAM, "\tjmp\t@r1\n"); \
97 fprintf (STREAM, "\tlds\tr0,pr\n"); \
98 fprintf (STREAM, "\t.align\t2\n"); \
99 if (flag_pic) \
100 { \
101 fprintf (STREAM, "1:\t.long\tmcount@GOT\n"); \
102 fprintf (STREAM, "3:\t.long\t_GLOBAL_OFFSET_TABLE_\n"); \
103 } \
104 else \
105 fprintf (STREAM, "1:\t.long\tmcount\n"); \
106 fprintf (STREAM, "2:\tlds.l\t@r15+,pr\n"); \
4977bab6
ZW
107 } while (0)
108
235b4b36
KK
109/* For SH3 and SH4, we use a slot of the unwind frame which correspond
110 to a fake register number 16 as a placeholder for the return address
111 in MD_FALLBACK_FRAME_STATE_FOR and its content will be read with
112 _Unwind_GetGR which uses dwarf_reg_size_table to get the size of
113 the register. So the entry of dwarf_reg_size_table corresponding to
114 this slot must be set. To do this, we redefine DBX_REGISTER_NUMBER
115 so as to return itself for 16. */
116#undef DBX_REGISTER_NUMBER
117#define DBX_REGISTER_NUMBER(REGNO) \
e1fab8ba 118 (((REGNO) == 16) ? 16 : SH_DBX_REGISTER_NUMBER (REGNO))
73a4d10b 119
dab37c68
RH
120/* Install the __sync libcalls. */
121#undef TARGET_INIT_LIBFUNCS
122#define TARGET_INIT_LIBFUNCS sh_init_sync_libfuncs
bed9e870
OE
123
124#undef SUBTARGET_OVERRIDE_OPTIONS
7bd76b9c
OE
125#define SUBTARGET_OVERRIDE_OPTIONS \
126 do \
127 { \
128 /* Set default atomic model if it hasn't been specified. */ \
00f34291 129 if (OPTION_SET_P (sh_atomic_model_str) == 0) \
7bd76b9c
OE
130 { \
131 if (TARGET_SH3) \
132 sh_atomic_model_str = "soft-gusa"; \
133 else if (TARGET_SH1) \
134 sh_atomic_model_str = "soft-imask"; \
135 } \
ee0d2b68 136 /* Set -musermode if it hasn't been specified. */ \
00f34291 137 if (OPTION_SET_P (TARGET_USERMODE) == 0) \
ee0d2b68 138 TARGET_USERMODE = true; \
7bd76b9c 139 } \
bed9e870 140 while (0)