Fix type in the changelog entry,
[official-gcc.git] / gcc / config / vxworks.c
blobe71768406206d6a162203198b90ad2ccafd5d135
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
10 version.
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
15 for more details.
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/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "target.h"
25 #include "diagnostic-core.h"
26 #include "output.h"
27 #include "tm.h"
28 #include "alias.h"
29 #include "tree.h"
30 #include "fold-const.h"
31 #include "stringpool.h"
33 /* Like default_named_section_asm_out_constructor, except that even
34 constructors with DEFAULT_INIT_PRIORITY must go in a numbered
35 section on VxWorks. The VxWorks runtime uses a clever trick to get
36 the sentinel entry (-1) inserted at the beginning of the .ctors
37 segment. This trick will not work if we ever generate any entries
38 in plain .ctors sections; we must always use .ctors.PRIORITY. */
40 void
41 vxworks_asm_out_constructor (rtx symbol, int priority)
43 section *sec;
45 sec = get_cdtor_priority_section (priority,
46 /*constructor_p=*/true);
47 assemble_addr_to_section (symbol, sec);
50 /* See comment for vxworks_asm_out_constructor. */
52 void
53 vxworks_asm_out_destructor (rtx symbol, int priority)
55 section *sec;
57 sec = get_cdtor_priority_section (priority,
58 /*constructor_p=*/false);
59 assemble_addr_to_section (symbol, sec);
62 /* Return the list of FIELD_DECLs that make up an emulated TLS
63 variable's control object. TYPE is the structure these are fields
64 of and *NAME will be filled in with the structure tag that should
65 be used. */
67 static tree
68 vxworks_emutls_var_fields (tree type, tree *name)
70 tree field, next_field;
72 *name = get_identifier ("__tls_var");
74 field = build_decl (BUILTINS_LOCATION, FIELD_DECL,
75 get_identifier ("size"), unsigned_type_node);
76 DECL_CONTEXT (field) = type;
77 next_field = field;
79 field = build_decl (BUILTINS_LOCATION, FIELD_DECL,
80 get_identifier ("module_id"), unsigned_type_node);
81 DECL_CONTEXT (field) = type;
82 DECL_CHAIN (field) = next_field;
83 next_field = field;
85 field = build_decl (BUILTINS_LOCATION, FIELD_DECL,
86 get_identifier ("offset"), unsigned_type_node);
87 DECL_CONTEXT (field) = type;
88 DECL_CHAIN (field) = next_field;
90 return field;
93 /* Return the CONSTRUCTOR to initialize an emulated TLS control
94 object. VAR is the control object. DECL is the TLS object itself
95 and TMPL_ADDR is the address (an ADDR_EXPR) of the initializer for
96 that object. */
98 static tree
99 vxworks_emutls_var_init (tree var, tree decl, tree tmpl_addr)
101 vec<constructor_elt, va_gc> *v;
102 vec_alloc (v, 3);
104 tree type = TREE_TYPE (var);
105 tree field = TYPE_FIELDS (type);
107 constructor_elt elt = {field, fold_convert (TREE_TYPE (field), tmpl_addr)};
108 v->quick_push (elt);
110 field = DECL_CHAIN (field);
111 elt.index = field;
112 elt.value = build_int_cst (TREE_TYPE (field), 0);
113 v->quick_push (elt);
115 field = DECL_CHAIN (field);
116 elt.index = field;
117 elt.value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl));
118 v->quick_push (elt);
120 return build_constructor (type, v);
123 /* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE. */
125 void
126 vxworks_override_options (void)
128 /* We don't support __thread via target hooks. */
129 targetm.have_tls = false;
131 targetm.emutls.get_address = "__builtin___tls_lookup";
132 targetm.emutls.register_common = NULL;
133 targetm.emutls.var_section = ".tls_vars";
134 targetm.emutls.tmpl_section = ".tls_data";
135 targetm.emutls.var_prefix = "__tls__";
136 targetm.emutls.tmpl_prefix = "";
137 targetm.emutls.var_fields = vxworks_emutls_var_fields;
138 targetm.emutls.var_init = vxworks_emutls_var_init;
139 targetm.emutls.var_align_fixed = true;
140 targetm.emutls.debug_form_tls_address = true;
142 /* We can use .ctors/.dtors sections only in RTP mode. */
143 targetm.have_ctors_dtors = TARGET_VXWORKS_RTP;
145 /* PIC is only supported for RTPs. */
146 if (flag_pic && !TARGET_VXWORKS_RTP)
147 error ("PIC is only supported for RTPs");
149 /* Default to strict dwarf-2 to prevent potential difficulties observed with
150 non-gdb debuggers on extensions > 2. */
151 if (!global_options_set.x_dwarf_strict)
152 dwarf_strict = 1;
154 if (!global_options_set.x_dwarf_version)
155 dwarf_version = 2;