Debian Codegraph @

gcc/config/csky/csky-linux-elf.h

raw
1 /* Declarations for C-SKY targets running Linux.
2 Copyright (C) 2018-2025 Free Software Foundation, Inc.
3 Contributed by C-SKY Microsystems and Mentor Graphics.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 3, or (at your
10 option) any later version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21 /******************************************************************
22 * Run-time Target Specification *
23 ******************************************************************/
24
25 #undef STARTFILE_SPEC
26 #define STARTFILE_SPEC \
27 "%{!shared: %{pie:Scrt1.o%s;:crt1.o%s}} \
28 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
29
30 #undef ENDFILE_SPEC
31 #define ENDFILE_SPEC \
32 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
33
34 #undef CC1_SPEC
35 #define CC1_SPEC \
36 "%{EB:-EB} \
37 %{EL:-EL} \
38 %{profile:-p} \
39 "
40
41 #undef ASM_SPEC
42 #define ASM_SPEC \
43 "%{mbig-endian:-mbig-endian} \
44 %{EB:-EB} \
45 %{EL:-EL} \
46 %{fpic|fPIC:-pic} \
47 %{mcpu=*:-mcpu=%*} \
48 %{march=*:-march=%*} \
49 %{mhard-float:-mhard-float} \
50 %{mfloat-abi=softfp:-mhard-float} \
51 %{mfloat-abi=hard:-mhard-float} \
52 %{melrw:-melrw} \
53 %{mno-elrw:-mno-elrw} \
54 %{mistack:-mistack} \
55 %{mno-istack:-mno-istack} \
56 %{mmp:-mmp} \
57 %{mcp:-mcp} \
58 %{mcache:-mcache} \
59 %{msecurity|mmac:-msecurity} \
60 %{mtrust:-mtrust} \
61 %{mdsp:-mdsp} \
62 %{medsp:-medsp} \
63 %{mvdsp:-mvdsp} \
64 "
65
66 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-cskyv2%{mfloat-abi=hard:-hf}%{mbig-endian:-be}.so.1"
67
68 #ifdef CSKY_ENABLE_MULTILIB
69 #undef SYSROOT_SUFFIX_SPEC
70 #define SYSROOT_SUFFIX_SPEC \
71 "%{mbig-endian:/big}" \
72 "%{mcpu=ck807*:/ck807}" \
73 "%{mcpu=ck860*:/ck860}" \
74 "%{mcpu=ck800*:/ck800}" \
75 "%{mfloat-abi=softfp:/soft-fp}" \
76 "%{mfloat-abi=hard:/hard-fp}"
77 #endif
78
79 #define LINUX_TARGET_LINK_SPEC "%{h*} %{version:-v} \
80 %{b} \
81 %{static:-Bstatic} \
82 %{shared:-shared} \
83 %{symbolic:-Bsymbolic} \
84 %{!static: \
85 %{rdynamic:-export-dynamic} \
86 %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
87 -X \
88 %{mbig-endian:-EB} %{mlittle-endian:-EL} \
89 %{EB:-EB} %{EL:-EL}"
90
91
92 #undef LINK_SPEC
93 #define LINK_SPEC LINUX_TARGET_LINK_SPEC
94
95
96 #undef LIB_SPEC
97 #define LIB_SPEC \
98 "%{pthread:-lpthread} -lc %{mccrt:-lcc-rt}"
99 /* FIXME add this to LIB_SPEC when need */
100 /* %{!shared:%{profile:-lc_p}%{!profile:-lc}}" */
101
102 #define TARGET_OS_CPP_BUILTINS() \
103 do \
104 { \
105 GNU_USER_TARGET_OS_CPP_BUILTINS (); \
106 } \
107 while (0)
108
109 /* In crtstuff.c to control section in where code resides.
110 We have to write it as asm code. */
111 #ifdef __PIC__
112 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
113 asm (SECTION_OP "\n" \
114 "\tgrs\tr3, .Lgetpc_"#FUNC"\n\t" \
115 ".Lgetpc_"#FUNC":\n\t" \
116 "\tlrw\tr2,\t.Lgetpc_"#FUNC"@GOTPC\n\t" \
117 "\taddu\tr3, r2\n\t" \
118 "\tlrw\tr2, "#FUNC"@GOTOFF\n\t" \
119 "\taddu\tr2, r3\n\t" \
120 "\tjsr\tr2\n\t"); \
121 FORCE_CODE_SECTION_ALIGN \
122 asm (TEXT_SECTION_ASM_OP);
123 #endif
124
125 #undef CPP_SPEC
126 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
127
128 #undef FUNCTION_PROFILER
129 #define SAVE_LR \
130 "push\tlr"
131 #define FUNCTION_PROFILER(file, labelno) \
132 fprintf (file, "\t%s\n\tjbsr\t_mcount\n", SAVE_LR);
133 #define NO_PROFILE_COUNTERS 1
134
135 /* Enable features only for Linux toolchains. */
136 #define TARGET_CSKY_LINUX 1
137
138 /* Clear the instruction cache from `BEG' to `END'. */
139 #define CLEAR_INSN_CACHE(BEG, END) \
140 cacheflush (BEG, END-BEG, 3)
141
142 /* For __clear_cache in libgcc2.c. The declaration is copied from
143 <sys/cachectl.h>. */
144 #ifdef IN_LIBGCC2
145 extern int cacheflush (void *__addr, const int __nbytes, const int __op);
146 #endif
147
148 /* The SYNC operations are implemented as library functions, not
149 INSN patterns. As a result, the HAVE defines for the patterns are
150 not defined. We need to define them to generate the corresponding
151 __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* and __GCC_ATOMIC_*_LOCK_FREE
152 defines. */
153
154 #define HAVE_sync_compare_and_swapqi 1
155 #define HAVE_sync_compare_and_swaphi 1
156 #define HAVE_sync_compare_and_swapsi 1