1 /* Common VxWorks target definitions for GNU compiler.
2 Copyright (C) 2007-2015 Free Software Foundation, Inc.
3 Contributed by CodeSourcery, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
26 #include "diagnostic-core.h"
31 #include "double-int.h"
38 #include "fold-const.h"
39 #include "stringpool.h"
41 /* Like default_named_section_asm_out_constructor, except that even
42 constructors with DEFAULT_INIT_PRIORITY must go in a numbered
43 section on VxWorks. The VxWorks runtime uses a clever trick to get
44 the sentinel entry (-1) inserted at the beginning of the .ctors
45 segment. This trick will not work if we ever generate any entries
46 in plain .ctors sections; we must always use .ctors.PRIORITY. */
49 vxworks_asm_out_constructor (rtx symbol
, int priority
)
53 sec
= get_cdtor_priority_section (priority
,
54 /*constructor_p=*/true);
55 assemble_addr_to_section (symbol
, sec
);
58 /* See comment for vxworks_asm_out_constructor. */
61 vxworks_asm_out_destructor (rtx symbol
, int priority
)
65 sec
= get_cdtor_priority_section (priority
,
66 /*constructor_p=*/false);
67 assemble_addr_to_section (symbol
, sec
);
70 /* Return the list of FIELD_DECLs that make up an emulated TLS
71 variable's control object. TYPE is the structure these are fields
72 of and *NAME will be filled in with the structure tag that should
76 vxworks_emutls_var_fields (tree type
, tree
*name
)
78 tree field
, next_field
;
80 *name
= get_identifier ("__tls_var");
82 field
= build_decl (BUILTINS_LOCATION
, FIELD_DECL
,
83 get_identifier ("size"), unsigned_type_node
);
84 DECL_CONTEXT (field
) = type
;
87 field
= build_decl (BUILTINS_LOCATION
, FIELD_DECL
,
88 get_identifier ("module_id"), unsigned_type_node
);
89 DECL_CONTEXT (field
) = type
;
90 DECL_CHAIN (field
) = next_field
;
93 field
= build_decl (BUILTINS_LOCATION
, FIELD_DECL
,
94 get_identifier ("offset"), unsigned_type_node
);
95 DECL_CONTEXT (field
) = type
;
96 DECL_CHAIN (field
) = next_field
;
101 /* Return the CONSTRUCTOR to initialize an emulated TLS control
102 object. VAR is the control object. DECL is the TLS object itself
103 and TMPL_ADDR is the address (an ADDR_EXPR) of the initializer for
107 vxworks_emutls_var_init (tree var
, tree decl
, tree tmpl_addr
)
109 vec
<constructor_elt
, va_gc
> *v
;
112 tree type
= TREE_TYPE (var
);
113 tree field
= TYPE_FIELDS (type
);
115 constructor_elt elt
= {field
, fold_convert (TREE_TYPE (field
), tmpl_addr
)};
118 field
= DECL_CHAIN (field
);
120 elt
.value
= build_int_cst (TREE_TYPE (field
), 0);
123 field
= DECL_CHAIN (field
);
125 elt
.value
= fold_convert (TREE_TYPE (field
), DECL_SIZE_UNIT (decl
));
128 return build_constructor (type
, v
);
131 /* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE. */
134 vxworks_override_options (void)
136 /* We don't support __thread via target hooks. */
137 targetm
.have_tls
= false;
139 targetm
.emutls
.get_address
= "__builtin___tls_lookup";
140 targetm
.emutls
.register_common
= NULL
;
141 targetm
.emutls
.var_section
= ".tls_vars";
142 targetm
.emutls
.tmpl_section
= ".tls_data";
143 targetm
.emutls
.var_prefix
= "__tls__";
144 targetm
.emutls
.tmpl_prefix
= "";
145 targetm
.emutls
.var_fields
= vxworks_emutls_var_fields
;
146 targetm
.emutls
.var_init
= vxworks_emutls_var_init
;
147 targetm
.emutls
.var_align_fixed
= true;
148 targetm
.emutls
.debug_form_tls_address
= true;
150 /* We can use .ctors/.dtors sections only in RTP mode. */
151 targetm
.have_ctors_dtors
= TARGET_VXWORKS_RTP
;
153 /* PIC is only supported for RTPs. */
154 if (flag_pic
&& !TARGET_VXWORKS_RTP
)
155 error ("PIC is only supported for RTPs");
157 /* Default to strict dwarf-2 to prevent potential difficulties observed with
158 non-gdb debuggers on extensions > 2. */
159 if (!global_options_set
.x_dwarf_strict
)
162 if (!global_options_set
.x_dwarf_version
)