]>
Commit | Line | Data |
---|---|---|
2eab15c9 | 1 | /* Common VxWorks target definitions for GNU compiler. |
a5544970 | 2 | Copyright (C) 1999-2019 Free Software Foundation, Inc. |
4977bab6 | 3 | Contributed by Wind River Systems. |
2eab15c9 | 4 | Rewritten by CodeSourcery, LLC. |
4977bab6 | 5 | |
814499a4 | 6 | This file is part of GCC. |
4977bab6 | 7 | |
2eab15c9 PE |
8 | GCC is free software; you can redistribute it and/or modify it under |
9 | the terms of the GNU General Public License as published by the Free | |
2f83c7d6 | 10 | Software Foundation; either version 3, or (at your option) any later |
2eab15c9 | 11 | version. |
4977bab6 | 12 | |
2eab15c9 PE |
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
4977bab6 ZW |
17 | |
18 | You should have received a copy of the GNU General Public License | |
2f83c7d6 NC |
19 | along with GCC; see the file COPYING3. If not see |
20 | <http://www.gnu.org/licenses/>. */ | |
4977bab6 | 21 | |
073a8998 | 22 | /* Assert that we are targeting VxWorks. */ |
a7f051fe RS |
23 | #undef TARGET_VXWORKS |
24 | #define TARGET_VXWORKS 1 | |
25 | ||
2eab15c9 PE |
26 | /* In kernel mode, VxWorks provides all the libraries itself, as well as |
27 | the functionality of startup files, etc. In RTP mode, it behaves more | |
28 | like a traditional Unix, with more external files. Most of our specs | |
29 | must be aware of the difference. */ | |
4977bab6 | 30 | |
30d8946b MM |
31 | /* We look for the VxWorks header files using the environment |
32 | variables that are set in VxWorks to indicate the location of the | |
33 | system header files. We use -idirafter so that the GCC's own | |
34 | header-file directories (containing <stddef.h>, etc.) come before | |
35 | the VxWorks system header directories. */ | |
4977bab6 | 36 | |
2eab15c9 PE |
37 | /* Since we provide a default -isystem, expand -isystem on the command |
38 | line early. */ | |
b269e899 JL |
39 | #if TARGET_VXWORKS7 |
40 | ||
41 | #undef VXWORKS_ADDITIONAL_CPP_SPEC | |
42 | #define VXWORKS_ADDITIONAL_CPP_SPEC \ | |
43 | "%{!nostdinc: \ | |
44 | %{isystem*} \ | |
45 | %{mrtp: -idirafter %:getenv(VSB_DIR /h) \ | |
46 | -idirafter %:getenv(VSB_DIR /share/h) \ | |
47 | -idirafter %:getenv(VSB_DIR /usr/h/public) \ | |
48 | -idirafter %:getenv(VSB_DIR /usr/h) \ | |
49 | ;: -idirafter %:getenv(VSB_DIR /h) \ | |
50 | -idirafter %:getenv(VSB_DIR /share/h) \ | |
51 | -idirafter %:getenv(VSB_DIR /krnl/h/system) \ | |
52 | -idirafter %:getenv(VSB_DIR /krnl/h/public)}}" | |
53 | ||
54 | #else /* TARGET_VXWORKS7 */ | |
55 | ||
2eab15c9 | 56 | #undef VXWORKS_ADDITIONAL_CPP_SPEC |
cb717c40 RS |
57 | #define VXWORKS_ADDITIONAL_CPP_SPEC \ |
58 | "%{!nostdinc: \ | |
6b19ff66 RV |
59 | %{isystem*} \ |
60 | %{mrtp: -idirafter %:getenv(WIND_USR /h) \ | |
61 | -idirafter %:getenv(WIND_USR /h/wrn/coreip) \ | |
62 | ;: -idirafter %:getenv(WIND_BASE /target/h) \ | |
63 | -idirafter %:getenv(WIND_BASE /target/h/wrn/coreip) \ | |
64 | }}" | |
4977bab6 | 65 | |
b269e899 JL |
66 | #endif |
67 | ||
8d0ef282 OH |
68 | /* For VxWorks static rtps, the system provides libc_internal.a, a superset of |
69 | libgcc.a that we need to use e.g. to satisfy references to __init and | |
70 | __fini. We still want our libgcc to prevail for symbols it would provide | |
71 | (e.g. register save entry points), so re-place it here between libraries | |
bca81bd2 OH |
72 | that might reference it and libc_internal. |
73 | ||
74 | In addition, some versions of VxWorks rely on explicit extra libraries for | |
75 | system calls and the set of base network libraries of common use varies | |
76 | across architectures. The default settings defined here might be redefined | |
77 | by target specific port configuration files. */ | |
b269e899 | 78 | |
88f4e766 OH |
79 | #define VXWORKS_SYSCALL_LIBS_RTP |
80 | ||
bca81bd2 OH |
81 | #define VXWORKS_NET_LIBS_RTP "-lnet -ldsi" |
82 | ||
88f4e766 | 83 | #define VXWORKS_LIBS_RTP \ |
bca81bd2 | 84 | VXWORKS_SYSCALL_LIBS_RTP " " VXWORKS_NET_LIBS_RTP " -lc -lgcc -lc_internal" |
b269e899 JL |
85 | |
86 | /* On Vx6 and previous, the libraries to pick up depends on the architecture, | |
87 | so cannot be defined for all archs at once. On Vx7, a VSB is always needed | |
88 | and its structure is fixed and does not depend on the arch. We can thus | |
f509691b OH |
89 | tell gcc where to look for when linking with RTP libraries. Use |
90 | STARTFILE_PREFIX_SPEC for this, instead of explicit -L options in LIB_SPEC, | |
91 | so they survive -nodefaultlibs. */ | |
b269e899 | 92 | |
931fae81 JL |
93 | /* On Vx7 RTP, we need to drag the __tls__ symbol to trigger initialization of |
94 | tlsLib, responsible for TLS support by the OS. */ | |
95 | ||
b269e899 | 96 | #if TARGET_VXWORKS7 |
f509691b OH |
97 | #undef STARTFILE_PREFIX_SPEC |
98 | #define STARTFILE_PREFIX_SPEC "%:getenv(VSB_DIR /usr/lib/common)" | |
931fae81 | 99 | #define TLS_SYM "-u __tls__" |
b269e899 | 100 | #else |
931fae81 | 101 | #define TLS_SYM "" |
b269e899 JL |
102 | #endif |
103 | ||
2eab15c9 PE |
104 | #undef VXWORKS_LIB_SPEC |
105 | #define VXWORKS_LIB_SPEC \ | |
106 | "%{mrtp:%{shared:-u " USER_LABEL_PREFIX "__init -u " USER_LABEL_PREFIX "__fini} \ | |
107 | %{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \ | |
931fae81 | 108 | " TLS_SYM " \ |
f509691b | 109 | --start-group " VXWORKS_LIBS_RTP " --end-group}}" |
4977bab6 | 110 | |
2eab15c9 PE |
111 | /* The no-op spec for "-shared" below is present because otherwise GCC |
112 | will treat it as an unrecognized option. */ | |
113 | #undef VXWORKS_LINK_SPEC | |
114 | #define VXWORKS_LINK_SPEC \ | |
115 | "%{!mrtp:-r} \ | |
116 | %{!shared: \ | |
117 | %{mrtp:-q %{h*} \ | |
c6c34cb4 | 118 | %{R*} %{!T*: %(link_start) } \ |
2eab15c9 | 119 | %(link_target) %(link_os)}} \ |
1c387101 | 120 | %{v:-v} \ |
2eab15c9 PE |
121 | %{shared:-shared} \ |
122 | %{Bstatic:-Bstatic} \ | |
123 | %{Bdynamic:-Bdynamic} \ | |
124 | %{!Xbind-lazy:-z now} \ | |
125 | %{Xbind-now:%{Xbind-lazy: \ | |
126 | %e-Xbind-now and -Xbind-lazy are incompatible}} \ | |
127 | %{mrtp:%{!shared:%{!non-static:-static} \ | |
128 | %{non-static:--force-dynamic --export-dynamic}}}" | |
4977bab6 | 129 | |
2eab15c9 | 130 | #undef VXWORKS_LIBGCC_SPEC |
8d0ef282 | 131 | #define VXWORKS_LIBGCC_SPEC "-lgcc" |
4977bab6 | 132 | |
2eab15c9 | 133 | #undef VXWORKS_STARTFILE_SPEC |
b83b15da | 134 | #define VXWORKS_STARTFILE_SPEC "%{mrtp:%{!shared:-l:crt0.o}}" |
2eab15c9 | 135 | #define VXWORKS_ENDFILE_SPEC "" |
4977bab6 | 136 | |
c5387660 | 137 | /* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE. */ |
931fae81 JL |
138 | |
139 | #define VXWORKS_HAVE_TLS (TARGET_VXWORKS7 && TARGET_VXWORKS_RTP) | |
140 | ||
2eab15c9 | 141 | #undef VXWORKS_OVERRIDE_OPTIONS |
ef672755 RS |
142 | #define VXWORKS_OVERRIDE_OPTIONS vxworks_override_options () |
143 | extern void vxworks_override_options (void); | |
4977bab6 | 144 | |
7f37b31d JL |
145 | /* Whether the VxWorks variant and mode supports constructors/destructors |
146 | placed in .ctors/.dtors section or if we should generate proxy functions | |
147 | for them, with special names which munch knows how to collect. On most | |
148 | versions of VxWorks, only the RTP loader supports .ctors/.dtors sections, | |
149 | not the kernel module loader. */ | |
150 | #define TARGET_VXWORKS_HAVE_CTORS_DTORS TARGET_VXWORKS_RTP | |
151 | ||
152 | /* Support for prioritized ctors/dtors is in sync with the support for sections | |
153 | on the VxWorks front, and is assumed to be provided by whatever linker level | |
154 | glue is required if we were configured with --enable-initfini-array. */ | |
ace193dc | 155 | #define SUPPORTS_INIT_PRIORITY \ |
7f37b31d | 156 | (TARGET_VXWORKS_HAVE_CTORS_DTORS || HAVE_INITFINI_ARRAY_SUPPORT) |
ad8577fd | 157 | |
eae016fc | 158 | #if !HAVE_INITFINI_ARRAY_SUPPORT |
b2f4bed8 MM |
159 | /* VxWorks requires special handling of constructors and destructors. |
160 | All VxWorks configurations must use these functions. */ | |
9403b7f7 | 161 | #undef TARGET_ASM_CONSTRUCTOR |
b2f4bed8 | 162 | #define TARGET_ASM_CONSTRUCTOR vxworks_asm_out_constructor |
9403b7f7 | 163 | #undef TARGET_ASM_DESTRUCTOR |
b2f4bed8 MM |
164 | #define TARGET_ASM_DESTRUCTOR vxworks_asm_out_destructor |
165 | extern void vxworks_asm_out_constructor (rtx symbol, int priority); | |
166 | extern void vxworks_asm_out_destructor (rtx symbol, int priority); | |
eae016fc | 167 | #endif |
4977bab6 | 168 | |
26b5109f RS |
169 | /* Override the vxworks-dummy.h definitions. TARGET_VXWORKS_RTP |
170 | is defined by vxworks.opt. */ | |
171 | #undef VXWORKS_GOTT_BASE | |
2eab15c9 | 172 | #define VXWORKS_GOTT_BASE "__GOTT_BASE__" |
26b5109f | 173 | #undef VXWORKS_GOTT_INDEX |
2eab15c9 | 174 | #define VXWORKS_GOTT_INDEX "__GOTT_INDEX__" |
4977bab6 | 175 | |
c447f774 | 176 | #undef PTRDIFF_TYPE |
aa56e87e | 177 | #define PTRDIFF_TYPE (TARGET_VXWORKS64 ? "long int" : "int") |
c447f774 RS |
178 | |
179 | #undef SIZE_TYPE | |
aa56e87e | 180 | #define SIZE_TYPE (TARGET_VXWORKS64 ? "long unsigned int" : "unsigned int") |
c447f774 | 181 | |
d33d9e47 AI |
182 | #undef TARGET_LIBC_HAS_FUNCTION |
183 | #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function | |
184 | ||
c447f774 RS |
185 | /* Both kernels and RTPs have the facilities required by this macro. */ |
186 | #define TARGET_POSIX_IO | |
187 | ||
cb717c40 | 188 | /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS. */ |
3b727799 OH |
189 | |
190 | /* The VxWorks personality we rely on, controlling which sections of system | |
191 | headers files we trigger. This might be redefined on targets where the | |
192 | base VxWorks environment doesn't come with a GNU toolchain. */ | |
193 | ||
194 | #define VXWORKS_PERSONALITY "gnu" | |
195 | ||
cb717c40 RS |
196 | #define VXWORKS_OS_CPP_BUILTINS() \ |
197 | do \ | |
198 | { \ | |
199 | builtin_define ("__vxworks"); \ | |
200 | builtin_define ("__VXWORKS__"); \ | |
201 | builtin_assert ("system=unix"); \ | |
202 | if (TARGET_VXWORKS_RTP) \ | |
203 | builtin_define ("__RTP__"); \ | |
204 | else \ | |
205 | builtin_define ("_WRS_KERNEL"); \ | |
3b727799 OH |
206 | builtin_define ("TOOL_FAMILY=" VXWORKS_PERSONALITY); \ |
207 | builtin_define ("TOOL=" VXWORKS_PERSONALITY); \ | |
b269e899 JL |
208 | if (TARGET_VXWORKS7) \ |
209 | { \ | |
210 | builtin_define ("_VSB_CONFIG_FILE=<config/vsbConfig.h>"); \ | |
211 | \ | |
212 | /* _ALLOW_KEYWORD_MACROS is needed on VxWorks 7 to \ | |
213 | prevent compilation failures triggered by our \ | |
214 | definition of "inline" in ansidecl when "inline" \ | |
215 | is not a keyword. */ \ | |
216 | if (!flag_isoc99 && !c_dialect_cxx()) \ | |
217 | builtin_define ("_ALLOW_KEYWORD_MACROS"); \ | |
218 | } \ | |
cb717c40 RS |
219 | } \ |
220 | while (0) | |
221 | ||
2eab15c9 | 222 | #define VXWORKS_KIND VXWORKS_KIND_NORMAL |
1c387101 NF |
223 | |
224 | /* The diab linker does not handle .gnu_attribute sections. */ | |
225 | #undef HAVE_AS_GNU_ATTRIBUTE | |
824a2b3d | 226 | |
5244089f OH |
227 | /* We provide our own version of __clear_cache in libgcc, using a separate C |
228 | file to facilitate #inclusion of VxWorks header files. */ | |
3b727799 | 229 | #undef CLEAR_INSN_CACHE |
5244089f OH |
230 | #define CLEAR_INSN_CACHE 1 |
231 | ||
824a2b3d OH |
232 | /* Default dwarf control values, for non-gdb debuggers that come with |
233 | VxWorks. */ | |
234 | ||
235 | #undef VXWORKS_DWARF_VERSION_DEFAULT | |
236 | #define VXWORKS_DWARF_VERSION_DEFAULT (TARGET_VXWORKS7 ? 4 : 2) | |
237 | ||
238 | #undef DWARF_GNAT_ENCODINGS_DEFAULT | |
239 | #define DWARF_GNAT_ENCODINGS_DEFAULT \ | |
240 | (TARGET_VXWORKS7 ? DWARF_GNAT_ENCODINGS_MINIMAL : DWARF_GNAT_ENCODINGS_ALL) |