[NDS32] new attribute no_prologue and new option -mret-in-naked-func.
[official-gcc.git] / gcc / config / vxworks.h
blobe37af775157db1a18e22e73972b1b1010746e918
1 /* Common VxWorks target definitions for GNU compiler.
2 Copyright (C) 1999-2018 Free Software Foundation, Inc.
3 Contributed by Wind River Systems.
4 Rewritten by CodeSourcery, LLC.
6 This file is part of GCC.
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.
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.
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/>. */
22 /* Assert that we are targeting VxWorks. */
23 #undef TARGET_VXWORKS
24 #define TARGET_VXWORKS 1
26 /* If TARGET_VXWORKS7 is undefined, then we're not targeting it. */
27 #ifndef TARGET_VXWORKS7
28 #define TARGET_VXWORKS7 0
29 #endif
31 /* In kernel mode, VxWorks provides all the libraries itself, as well as
32 the functionality of startup files, etc. In RTP mode, it behaves more
33 like a traditional Unix, with more external files. Most of our specs
34 must be aware of the difference. */
36 /* We look for the VxWorks header files using the environment
37 variables that are set in VxWorks to indicate the location of the
38 system header files. We use -idirafter so that the GCC's own
39 header-file directories (containing <stddef.h>, etc.) come before
40 the VxWorks system header directories. */
42 /* Since we provide a default -isystem, expand -isystem on the command
43 line early. */
44 #if TARGET_VXWORKS7
46 #undef VXWORKS_ADDITIONAL_CPP_SPEC
47 #define VXWORKS_ADDITIONAL_CPP_SPEC \
48 "%{!nostdinc: \
49 %{isystem*} \
50 %{mrtp: -idirafter %:getenv(VSB_DIR /h) \
51 -idirafter %:getenv(VSB_DIR /share/h) \
52 -idirafter %:getenv(VSB_DIR /usr/h/public) \
53 -idirafter %:getenv(VSB_DIR /usr/h) \
54 ;: -idirafter %:getenv(VSB_DIR /h) \
55 -idirafter %:getenv(VSB_DIR /share/h) \
56 -idirafter %:getenv(VSB_DIR /krnl/h/system) \
57 -idirafter %:getenv(VSB_DIR /krnl/h/public)}}"
59 #else /* TARGET_VXWORKS7 */
61 #undef VXWORKS_ADDITIONAL_CPP_SPEC
62 #define VXWORKS_ADDITIONAL_CPP_SPEC \
63 "%{!nostdinc: \
64 %{isystem*} -idirafter \
65 %{mrtp: %:getenv(WIND_USR /h) \
66 ;: %:getenv(WIND_BASE /target/h)}}"
68 #endif
70 /* The references to __init and __fini will be satisfied by
71 libc_internal.a, and some versions of VxWorks rely on explicit
72 extra libraries for system calls. */
74 #define VXWORKS_SYSCALL_LIBS_RTP
76 #define VXWORKS_LIBS_RTP \
77 VXWORKS_SYSCALL_LIBS_RTP " -lc -lgcc -lc_internal -lnet -ldsi"
79 /* On Vx6 and previous, the libraries to pick up depends on the architecture,
80 so cannot be defined for all archs at once. On Vx7, a VSB is always needed
81 and its structure is fixed and does not depend on the arch. We can thus
82 tell gcc where to look for when linking with RTP libraries. */
84 /* On Vx7 RTP, we need to drag the __tls__ symbol to trigger initialization of
85 tlsLib, responsible for TLS support by the OS. */
87 #if TARGET_VXWORKS7
88 #define VXWORKS_LIBS_DIR_RTP "-L%:getenv(VSB_DIR /usr/lib/common)"
89 #define TLS_SYM "-u __tls__"
90 #else
91 #define VXWORKS_LIBS_DIR_RTP ""
92 #define TLS_SYM ""
93 #endif
95 #undef VXWORKS_LIB_SPEC
96 #define VXWORKS_LIB_SPEC \
97 "%{mrtp:%{shared:-u " USER_LABEL_PREFIX "__init -u " USER_LABEL_PREFIX "__fini} \
98 %{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \
99 " TLS_SYM " \
100 --start-group " VXWORKS_LIBS_RTP " --end-group} \
101 " VXWORKS_LIBS_DIR_RTP "}"
103 /* The no-op spec for "-shared" below is present because otherwise GCC
104 will treat it as an unrecognized option. */
105 #undef VXWORKS_LINK_SPEC
106 #define VXWORKS_LINK_SPEC \
107 "%{!mrtp:-r} \
108 %{!shared: \
109 %{mrtp:-q %{h*} \
110 %{R*} %{!T*: %(link_start) } \
111 %(link_target) %(link_os)}} \
112 %{v:-v} \
113 %{shared:-shared} \
114 %{Bstatic:-Bstatic} \
115 %{Bdynamic:-Bdynamic} \
116 %{!Xbind-lazy:-z now} \
117 %{Xbind-now:%{Xbind-lazy: \
118 %e-Xbind-now and -Xbind-lazy are incompatible}} \
119 %{mrtp:%{!shared:%{!non-static:-static} \
120 %{non-static:--force-dynamic --export-dynamic}}}"
122 /* For VxWorks static rtps, the system provides libc_internal.a, a superset
123 of libgcc.a that we want to use. Make sure not to dynamically export any
124 of its symbols, though, and always look for libgcc.a first so that we get
125 the latest versions of the GNU intrinsics during our builds. */
126 #undef VXWORKS_LIBGCC_SPEC
127 #define VXWORKS_LIBGCC_SPEC \
128 "-lgcc %{mrtp:%{!shared:--exclude-libs=libc_internal,libgcc -lc_internal}}"
130 #undef VXWORKS_STARTFILE_SPEC
131 #define VXWORKS_STARTFILE_SPEC "%{mrtp:%{!shared:-l:crt0.o}}"
132 #define VXWORKS_ENDFILE_SPEC ""
134 /* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE. */
136 #define VXWORKS_HAVE_TLS (TARGET_VXWORKS7 && TARGET_VXWORKS_RTP)
138 #undef VXWORKS_OVERRIDE_OPTIONS
139 #define VXWORKS_OVERRIDE_OPTIONS vxworks_override_options ()
140 extern void vxworks_override_options (void);
142 /* Only RTPs support prioritized constructors and destructors:
143 the implementation relies on numbered .ctors* sections. */
144 #define SUPPORTS_INIT_PRIORITY TARGET_VXWORKS_RTP
146 /* VxWorks requires special handling of constructors and destructors.
147 All VxWorks configurations must use these functions. */
148 #undef TARGET_ASM_CONSTRUCTOR
149 #define TARGET_ASM_CONSTRUCTOR vxworks_asm_out_constructor
150 #undef TARGET_ASM_DESTRUCTOR
151 #define TARGET_ASM_DESTRUCTOR vxworks_asm_out_destructor
152 extern void vxworks_asm_out_constructor (rtx symbol, int priority);
153 extern void vxworks_asm_out_destructor (rtx symbol, int priority);
155 /* Override the vxworks-dummy.h definitions. TARGET_VXWORKS_RTP
156 is defined by vxworks.opt. */
157 #undef VXWORKS_GOTT_BASE
158 #define VXWORKS_GOTT_BASE "__GOTT_BASE__"
159 #undef VXWORKS_GOTT_INDEX
160 #define VXWORKS_GOTT_INDEX "__GOTT_INDEX__"
162 #undef PTRDIFF_TYPE
163 #define PTRDIFF_TYPE "int"
165 #undef SIZE_TYPE
166 #define SIZE_TYPE "unsigned int"
168 #undef TARGET_LIBC_HAS_FUNCTION
169 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
171 /* Both kernels and RTPs have the facilities required by this macro. */
172 #define TARGET_POSIX_IO
174 /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS. */
175 #define VXWORKS_OS_CPP_BUILTINS() \
176 do \
178 builtin_define ("__vxworks"); \
179 builtin_define ("__VXWORKS__"); \
180 builtin_assert ("system=unix"); \
181 if (TARGET_VXWORKS_RTP) \
182 builtin_define ("__RTP__"); \
183 else \
184 builtin_define ("_WRS_KERNEL"); \
185 builtin_define ("_VX_TOOL_FAMILY=gnu"); \
186 builtin_define ("_VX_TOOL=gnu"); \
187 if (TARGET_VXWORKS7) \
189 builtin_define ("_VSB_CONFIG_FILE=<config/vsbConfig.h>"); \
191 /* _ALLOW_KEYWORD_MACROS is needed on VxWorks 7 to \
192 prevent compilation failures triggered by our \
193 definition of "inline" in ansidecl when "inline" \
194 is not a keyword. */ \
195 if (!flag_isoc99 && !c_dialect_cxx()) \
196 builtin_define ("_ALLOW_KEYWORD_MACROS"); \
199 while (0)
201 #define VXWORKS_KIND VXWORKS_KIND_NORMAL
203 /* The diab linker does not handle .gnu_attribute sections. */
204 #undef HAVE_AS_GNU_ATTRIBUTE
206 /* Default dwarf control values, for non-gdb debuggers that come with
207 VxWorks. */
209 #undef VXWORKS_DWARF_VERSION_DEFAULT
210 #define VXWORKS_DWARF_VERSION_DEFAULT (TARGET_VXWORKS7 ? 4 : 2)
212 #undef DWARF_GNAT_ENCODINGS_DEFAULT
213 #define DWARF_GNAT_ENCODINGS_DEFAULT \
214 (TARGET_VXWORKS7 ? DWARF_GNAT_ENCODINGS_MINIMAL : DWARF_GNAT_ENCODINGS_ALL)