vxworks.h revision 1.3
1/* Common VxWorks target definitions for GNU compiler.
2   Copyright (C) 1999-2013 Free Software Foundation, Inc.
3   Contributed by Wind River Systems.
4   Rewritten by CodeSourcery, LLC.
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along 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#undef VXWORKS_ADDITIONAL_CPP_SPEC
40#define VXWORKS_ADDITIONAL_CPP_SPEC		\
41 "%{!nostdinc:					\
42    %{isystem*} -idirafter			\
43    %{mrtp: %:getenv(WIND_USR /h)		\
44      ;:    %:getenv(WIND_BASE /target/h)}}"
45
46/* The references to __init and __fini will be satisfied by
47   libc_internal.a.  */
48#undef VXWORKS_LIB_SPEC
49#define	VXWORKS_LIB_SPEC						\
50"%{mrtp:%{shared:-u " USER_LABEL_PREFIX "__init -u " USER_LABEL_PREFIX "__fini} \
51	%{!shared:%{non-static:-u " USER_LABEL_PREFIX "_STI__6__rtld -ldl} \
52		  --start-group -lc -lgcc -lc_internal -lnet -ldsi	\
53		  --end-group}}"
54
55/* The no-op spec for "-shared" below is present because otherwise GCC
56   will treat it as an unrecognized option.  */
57#undef VXWORKS_LINK_SPEC
58#define VXWORKS_LINK_SPEC				\
59"%{!mrtp:-r}						\
60 %{!shared:						\
61   %{mrtp:-q %{h*}					\
62          %{R*} %{!T*: %(link_start) }			\
63          %(link_target) %(link_os)}}			\
64 %{v:-v}						\
65 %{shared:-shared}					\
66 %{Bstatic:-Bstatic}					\
67 %{Bdynamic:-Bdynamic}					\
68 %{!Xbind-lazy:-z now}					\
69 %{Xbind-now:%{Xbind-lazy:				\
70   %e-Xbind-now and -Xbind-lazy are incompatible}}	\
71 %{mrtp:%{!shared:%{!non-static:-static}		\
72 		  %{non-static:--force-dynamic --export-dynamic}}}"
73
74/* For VxWorks, the system provides libc_internal.a.  This is a superset
75   of libgcc.a; we want to use it.  Make sure not to dynamically export
76   any of its symbols, though.  Always look for libgcc.a first so that
77   we get the latest versions of the GNU intrinsics during our builds.  */
78#undef VXWORKS_LIBGCC_SPEC
79#define VXWORKS_LIBGCC_SPEC \
80  "-lgcc %{mrtp:--exclude-libs=libc_internal,libgcc -lc_internal}"
81
82#undef VXWORKS_STARTFILE_SPEC
83#define	VXWORKS_STARTFILE_SPEC "%{mrtp:%{!shared:-l:crt0.o}}"
84#define VXWORKS_ENDFILE_SPEC ""
85
86/* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE.  */
87#undef VXWORKS_OVERRIDE_OPTIONS
88#define VXWORKS_OVERRIDE_OPTIONS vxworks_override_options ()
89extern void vxworks_override_options (void);
90
91/* Only RTPs support prioritized constructors and destructors:
92   the implementation relies on numbered .ctors* sections.  */
93#define SUPPORTS_INIT_PRIORITY TARGET_VXWORKS_RTP
94
95/* VxWorks requires special handling of constructors and destructors.
96   All VxWorks configurations must use these functions.  */
97#undef TARGET_ASM_CONSTRUCTOR
98#define TARGET_ASM_CONSTRUCTOR vxworks_asm_out_constructor
99#undef TARGET_ASM_DESTRUCTOR
100#define TARGET_ASM_DESTRUCTOR vxworks_asm_out_destructor
101extern void vxworks_asm_out_constructor (rtx symbol, int priority);
102extern void vxworks_asm_out_destructor (rtx symbol, int priority);
103
104/* Override the vxworks-dummy.h definitions.  TARGET_VXWORKS_RTP
105   is defined by vxworks.opt.  */
106#undef VXWORKS_GOTT_BASE
107#define VXWORKS_GOTT_BASE "__GOTT_BASE__"
108#undef VXWORKS_GOTT_INDEX
109#define VXWORKS_GOTT_INDEX "__GOTT_INDEX__"
110
111#undef PTRDIFF_TYPE
112#define PTRDIFF_TYPE "int"
113
114#undef SIZE_TYPE
115#define SIZE_TYPE "unsigned int"
116
117/* Both kernels and RTPs have the facilities required by this macro.  */
118#define TARGET_POSIX_IO
119
120/* A VxWorks implementation of TARGET_OS_CPP_BUILTINS.  */
121#define VXWORKS_OS_CPP_BUILTINS()					\
122  do									\
123    {									\
124      builtin_define ("__vxworks");					\
125      builtin_define ("__VXWORKS__");					\
126      builtin_assert ("system=unix");					\
127      if (TARGET_VXWORKS_RTP)						\
128	builtin_define ("__RTP__");					\
129      else								\
130	builtin_define ("_WRS_KERNEL");					\
131    }									\
132  while (0)
133
134#define VXWORKS_KIND VXWORKS_KIND_NORMAL
135
136/* The diab linker does not handle .gnu_attribute sections.  */
137#undef HAVE_AS_GNU_ATTRIBUTE
138