1 /* Common VxWorks target definitions for GNU compiler. 2 Copyright (C) 1999-2019 Free Software Foundation, Inc. 3 Contributed by Wind River Systems. 4 Rewritten by CodeSourcery, LLC. 5 6 This file is part of GCC. 7 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 10 Software Foundation; either version 3, or (at your option) any later 11 version. 12 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. 17 18 You should have received a copy of the GNU General Public License 19 along with GCC; see the file COPYING3. If not see 20 <http://www.gnu.org/licenses/>. */ 21 22 /* Assert that we are targeting VxWorks. */ 23 #undef TARGET_VXWORKS 24 #define TARGET_VXWORKS 1 25 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. */ 30 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. */ 36 37 /* Since we provide a default -isystem, expand -isystem on the command 38 line early. */ 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 56 #undef VXWORKS_ADDITIONAL_CPP_SPEC 57 #define VXWORKS_ADDITIONAL_CPP_SPEC \ 58 "%{!nostdinc: \ 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 }}" 65 66 #endif 67 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 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. */ 78 79 #define VXWORKS_SYSCALL_LIBS_RTP 80 81 #define VXWORKS_NET_LIBS_RTP "-lnet -ldsi" 82 83 #define VXWORKS_LIBS_RTP \ 84 VXWORKS_SYSCALL_LIBS_RTP " " VXWORKS_NET_LIBS_RTP " -lc -lgcc -lc_internal" 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 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. */ 92 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 96 #if TARGET_VXWORKS7 97 #undef STARTFILE_PREFIX_SPEC 98 #define STARTFILE_PREFIX_SPEC "%:getenv(VSB_DIR /usr/lib/common)" 99 #define TLS_SYM "-u __tls__" 100 #else 101 #define TLS_SYM "" 102 #endif 103 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} \ 108 " TLS_SYM " \ 109 --start-group " VXWORKS_LIBS_RTP " --end-group}}" 110 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*} \ 118 %{R*} %{!T*: %(link_start) } \ 119 %(link_target) %(link_os)}} \ 120 %{v:-v} \ 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}}}" 129 130 #undef VXWORKS_LIBGCC_SPEC 131 #define VXWORKS_LIBGCC_SPEC "-lgcc" 132 133 #undef VXWORKS_STARTFILE_SPEC 134 #define VXWORKS_STARTFILE_SPEC "%{mrtp:%{!shared:-l:crt0.o}}" 135 #define VXWORKS_ENDFILE_SPEC "" 136 137 /* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE. */ 138 139 #define VXWORKS_HAVE_TLS (TARGET_VXWORKS7 && TARGET_VXWORKS_RTP) 140 141 #undef VXWORKS_OVERRIDE_OPTIONS 142 #define VXWORKS_OVERRIDE_OPTIONS vxworks_override_options () 143 extern void vxworks_override_options (void); 144 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. */ 155 #define SUPPORTS_INIT_PRIORITY \ 156 (TARGET_VXWORKS_HAVE_CTORS_DTORS || HAVE_INITFINI_ARRAY_SUPPORT) 157 158 #if !HAVE_INITFINI_ARRAY_SUPPORT 159 /* VxWorks requires special handling of constructors and destructors. 160 All VxWorks configurations must use these functions. */ 161 #undef TARGET_ASM_CONSTRUCTOR 162 #define TARGET_ASM_CONSTRUCTOR vxworks_asm_out_constructor 163 #undef TARGET_ASM_DESTRUCTOR 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); 167 #endif 168 169 /* Override the vxworks-dummy.h definitions. TARGET_VXWORKS_RTP 170 is defined by vxworks.opt. */ 171 #undef VXWORKS_GOTT_BASE 172 #define VXWORKS_GOTT_BASE "__GOTT_BASE__" 173 #undef VXWORKS_GOTT_INDEX 174 #define VXWORKS_GOTT_INDEX "__GOTT_INDEX__" 175 176 #undef PTRDIFF_TYPE 177 #define PTRDIFF_TYPE (TARGET_VXWORKS64 ? "long int" : "int") 178 179 #undef SIZE_TYPE 180 #define SIZE_TYPE (TARGET_VXWORKS64 ? "long unsigned int" : "unsigned int") 181 182 #undef TARGET_LIBC_HAS_FUNCTION 183 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function 184 185 /* Both kernels and RTPs have the facilities required by this macro. */ 186 #define TARGET_POSIX_IO 187 188 /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS. */ 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 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"); \ 206 builtin_define ("TOOL_FAMILY=" VXWORKS_PERSONALITY); \ 207 builtin_define ("TOOL=" VXWORKS_PERSONALITY); \ 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 } \ 219 } \ 220 while (0) 221 222 #define VXWORKS_KIND VXWORKS_KIND_NORMAL 223 224 /* The diab linker does not handle .gnu_attribute sections. */ 225 #undef HAVE_AS_GNU_ATTRIBUTE 226 227 /* We provide our own version of __clear_cache in libgcc, using a separate C 228 file to facilitate #inclusion of VxWorks header files. */ 229 #undef CLEAR_INSN_CACHE 230 #define CLEAR_INSN_CACHE 1 231 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) 241