1 /* Common VxWorks target definitions for GNU compiler.
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
3 Free Software Foundation, Inc.
4 Contributed by Wind River Systems.
5 Rewritten by CodeSourcery, LLC.
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
23 /* Assert that we are targetting VxWorks. */
25 #define TARGET_VXWORKS 1
27 /* In kernel mode, VxWorks provides all the libraries itself, as well as
28 the functionality of startup files, etc. In RTP mode, it behaves more
29 like a traditional Unix, with more external files. Most of our specs
30 must be aware of the difference. */
32 /* We look for the VxWorks header files using the environment
33 variables that are set in VxWorks to indicate the location of the
34 system header files. We use -idirafter so that the GCC's own
35 header-file directories (containing <stddef.h>, etc.) come before
36 the VxWorks system header directories. */
38 /* Since we provide a default -isystem, expand -isystem on the command
40 #undef VXWORKS_ADDITIONAL_CPP_SPEC
41 #define VXWORKS_ADDITIONAL_CPP_SPEC \
43 %{isystem*} -idirafter \
44 %{mrtp: %:getenv(WIND_USR /h) \
45 ;: %:getenv(WIND_BASE /target/h)}}"
47 /* The references to __init and __fini will be satisfied by
49 #undef VXWORKS_LIB_SPEC
50 #define VXWORKS_LIB_SPEC \
51 "%{mrtp:%{shared:-u " USER_LABEL_PREFIX "__init -u " USER_LABEL_PREFIX "__fini} \
52 %{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \
53 --start-group -lc -lgcc -lc_internal -lnet -ldsi \
56 /* The no-op spec for "-shared" below is present because otherwise GCC
57 will treat it as an unrecognized option. */
58 #undef VXWORKS_LINK_SPEC
59 #define VXWORKS_LINK_SPEC \
63 %{R*} %{!Wl,-T*: %{!T*: %(link_start) }} \
64 %(link_target) %(link_os)}} \
68 %{Bdynamic:-Bdynamic} \
69 %{!Xbind-lazy:-z now} \
70 %{Xbind-now:%{Xbind-lazy: \
71 %e-Xbind-now and -Xbind-lazy are incompatible}} \
72 %{mrtp:%{!shared:%{!non-static:-static} \
73 %{non-static:--force-dynamic --export-dynamic}}}"
75 /* For VxWorks, the system provides libc_internal.a. This is a superset
76 of libgcc.a; we want to use it. Make sure not to dynamically export
77 any of its symbols, though. Always look for libgcc.a first so that
78 we get the latest versions of the GNU intrinsics during our builds. */
79 #undef VXWORKS_LIBGCC_SPEC
80 #define VXWORKS_LIBGCC_SPEC \
81 "-lgcc %{mrtp:--exclude-libs=libc_internal,libgcc -lc_internal}"
83 #undef VXWORKS_STARTFILE_SPEC
84 #define VXWORKS_STARTFILE_SPEC "%{mrtp:%{!shared:-l:crt0.o}}"
85 #define VXWORKS_ENDFILE_SPEC ""
87 /* Do VxWorks-specific parts of OVERRIDE_OPTIONS. */
88 #undef VXWORKS_OVERRIDE_OPTIONS
89 #define VXWORKS_OVERRIDE_OPTIONS vxworks_override_options ()
90 extern void vxworks_override_options (void);
92 /* Only RTPs support prioritized constructors and destructors:
93 the implementation relies on numbered .ctors* sections. */
94 #define SUPPORTS_INIT_PRIORITY TARGET_VXWORKS_RTP
96 /* VxWorks requires special handling of constructors and destructors.
97 All VxWorks configurations must use these functions. */
98 #undef TARGET_ASM_CONSTRUCTOR
99 #define TARGET_ASM_CONSTRUCTOR vxworks_asm_out_constructor
100 #undef TARGET_ASM_DESTRUCTOR
101 #define TARGET_ASM_DESTRUCTOR vxworks_asm_out_destructor
102 extern void vxworks_asm_out_constructor (rtx symbol
, int priority
);
103 extern void vxworks_asm_out_destructor (rtx symbol
, int priority
);
105 /* Override the vxworks-dummy.h definitions. TARGET_VXWORKS_RTP
106 is defined by vxworks.opt. */
107 #undef VXWORKS_GOTT_BASE
108 #define VXWORKS_GOTT_BASE "__GOTT_BASE__"
109 #undef VXWORKS_GOTT_INDEX
110 #define VXWORKS_GOTT_INDEX "__GOTT_INDEX__"
112 /* As for svr4.h (which not all VxWorks targets include). */
114 #define PTRDIFF_TYPE "int"
117 #define SIZE_TYPE "unsigned int"
119 /* Both kernels and RTPs have the facilities required by this macro. */
120 #define TARGET_POSIX_IO
122 /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS. */
123 #define VXWORKS_OS_CPP_BUILTINS() \
126 builtin_define ("__vxworks"); \
127 builtin_define ("__VXWORKS__"); \
128 builtin_assert ("system=unix"); \
129 if (TARGET_VXWORKS_RTP) \
130 builtin_define ("__RTP__"); \
132 builtin_define ("_WRS_KERNEL"); \
136 #define VXWORKS_KIND VXWORKS_KIND_NORMAL
138 /* The diab linker does not handle .gnu_attribute sections. */
139 #undef HAVE_AS_GNU_ATTRIBUTE