1 /* Common VxWorks target definitions for GNU compiler.
2    Copyright (C) 1999-2014 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 #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 ()
89 extern 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
101 extern void vxworks_asm_out_constructor (rtx symbol, int priority);
102 extern 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 #undef TARGET_LIBC_HAS_FUNCTION
118 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
119 
120 /* Both kernels and RTPs have the facilities required by this macro.  */
121 #define TARGET_POSIX_IO
122 
123 /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS.  */
124 #define VXWORKS_OS_CPP_BUILTINS()					\
125   do									\
126     {									\
127       builtin_define ("__vxworks");					\
128       builtin_define ("__VXWORKS__");					\
129       builtin_assert ("system=unix");					\
130       if (TARGET_VXWORKS_RTP)						\
131 	builtin_define ("__RTP__");					\
132       else								\
133 	builtin_define ("_WRS_KERNEL");					\
134     }									\
135   while (0)
136 
137 #define VXWORKS_KIND VXWORKS_KIND_NORMAL
138 
139 /* The diab linker does not handle .gnu_attribute sections.  */
140 #undef HAVE_AS_GNU_ATTRIBUTE
141