*** empty log message ***
[deliverable/binutils-gdb.git] / gold / parameters.h
CommitLineData
7e1edb90
ILT
1// parameters.h -- general parameters for a link using gold -*- C++ -*-
2
6cb15b7f
ILT
3// Copyright 2006, 2007 Free Software Foundation, Inc.
4// Written by Ian Lance Taylor <iant@google.com>.
5
6// This file is part of gold.
7
8// This program is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21// MA 02110-1301, USA.
22
7e1edb90
ILT
23#ifndef GOLD_PARAMETERS_H
24#define GOLD_PARAMETERS_H
25
26namespace gold
27{
28
29class General_options;
75f2446e 30class Errors;
7e1edb90
ILT
31
32// Here we define the Parameters class which simply holds simple
33// general parameters which apply to the entire link. We use a global
34// variable for this. This is in contrast to the General_options
35// class, which holds the complete state of position independent
36// command line options. The hope is that Parameters will stay fairly
37// simple, so that if this turns into a library it will be clear how
38// these parameters should be set.
39
40class Parameters
41{
42 public:
3c2fafa5 43 Parameters(Errors*);
75f2446e
ILT
44
45 // Return the error object.
46 Errors*
47 errors() const
48 { return this->errors_; }
49
50 // Return the output file name.
51 const char*
52 output_file_name() const
3c2fafa5
ILT
53 {
54 gold_assert(this->options_valid_);
55 return this->output_file_name_;
56 }
7e1edb90
ILT
57
58 // Whether we are generating a regular executable.
59 bool
60 output_is_executable() const
3c2fafa5
ILT
61 {
62 gold_assert(this->output_file_type_ != OUTPUT_INVALID);
63 return this->output_file_type_ == OUTPUT_EXECUTABLE;
64 }
7e1edb90
ILT
65
66 // Whether we are generating a shared library.
67 bool
68 output_is_shared() const
3c2fafa5
ILT
69 {
70 gold_assert(this->output_file_type_ != OUTPUT_INVALID);
71 return this->output_file_type_ == OUTPUT_SHARED;
72 }
7e1edb90
ILT
73
74 // Whether we are generating an object file.
75 bool
76 output_is_object() const
3c2fafa5
ILT
77 {
78 gold_assert(this->output_file_type_ != OUTPUT_INVALID);
79 return this->output_file_type_ == OUTPUT_OBJECT;
80 }
7e1edb90 81
436ca963
ILT
82 // Whether we are generating position-independent output.
83 // This is the case when generating either a shared library
84 // or a regular executable with the --pic-executable option.
85 // FIXME: support --pic-executable
86 bool
87 output_is_position_independent() const
88 { return output_is_shared(); }
89
ad2d6943
ILT
90 // The target system root directory. This is NULL if there isn't
91 // one.
92 const std::string&
93 sysroot() const
3c2fafa5
ILT
94 {
95 gold_assert(this->options_valid_);
96 return this->sysroot_;
97 }
ad2d6943 98
9e2dcb77
ILT
99 // Whether to strip all symbols.
100 bool
101 strip_all() const
3c2fafa5
ILT
102 {
103 gold_assert(this->strip_ != STRIP_INVALID);
104 return this->strip_ == STRIP_ALL;
105 }
9e2dcb77
ILT
106
107 // Whether to strip debugging information.
108 bool
109 strip_debug() const
3c2fafa5
ILT
110 {
111 gold_assert(this->strip_ != STRIP_INVALID);
112 return this->strip_ == STRIP_ALL || this->strip_ == STRIP_DEBUG;
113 }
9e2dcb77 114
02d2ba74
ILT
115 // Whether to strip debugging information that's not used by gdb.
116 bool
117 strip_debug_gdb() const
118 {
119 gold_assert(this->strip_ != STRIP_INVALID);
120 return this->strip_debug() || this->strip_ == STRIP_DEBUG_UNUSED_BY_GDB;
121 }
122
e2827e5f
ILT
123 // Whether to permit unresolved references from shared libraries.
124 bool
125 allow_shlib_undefined() const
126 {
127 gold_assert(this->options_valid_);
128 return this->allow_shlib_undefined_;
129 }
130
51b08ebe
ILT
131 // Whether we are doing a symbolic link, in which all defined
132 // symbols are bound locally.
133 bool
134 symbolic() const
3c2fafa5
ILT
135 {
136 gold_assert(this->options_valid_);
137 return this->symbolic_;
138 }
139
a2b1aa12
ILT
140 // Whether we should demangle C++ symbols in our log messages.
141 bool
142 demangle() const
143 { return this->demangle_; }
144
a55ce7fe
ILT
145 // Whether we should try to detect violations of the One Definition Rule.
146 bool
147 detect_odr_violations() const
148 {
149 gold_assert(this->options_valid_);
150 return this->detect_odr_violations_;
151 }
152
3c2fafa5
ILT
153 // The general linker optimization level.
154 int
155 optimization_level() const
156 {
157 gold_assert(this->options_valid_);
158 return this->optimization_level_;
159 }
160
161 // Whether the -E/--export-dynamic flag is set.
162 bool
163 export_dynamic() const
164 {
165 gold_assert(this->options_valid_);
166 return this->export_dynamic_;
167 }
51b08ebe 168
b3b74ddc
ILT
169 // Whether we are doing a static link--a link in which none of the
170 // input files are shared libraries. This is only known after we
171 // have seen all the input files.
172 bool
173 doing_static_link() const
174 {
175 gold_assert(this->is_doing_static_link_valid_);
176 return this->doing_static_link_;
177 }
178
9025d29d
ILT
179 // The size of the output file we are generating. This should
180 // return 32 or 64.
181 int
182 get_size() const
183 {
184 gold_assert(this->is_size_and_endian_valid_);
185 return this->size_;
186 }
187
188 // Whether the output is big endian.
189 bool
190 is_big_endian() const
191 {
192 gold_assert(this->is_size_and_endian_valid_);
193 return this->is_big_endian_;
194 }
195
3c2fafa5
ILT
196 // Set values recorded from options.
197 void
198 set_from_options(const General_options*);
436ca963 199
b3b74ddc
ILT
200 // Set whether we are doing a static link.
201 void
202 set_doing_static_link(bool doing_static_link);
203
9025d29d
ILT
204 // Set the size and endianness.
205 void
206 set_size_and_endianness(int size, bool is_big_endian);
207
7e1edb90
ILT
208 private:
209 // The types of output files.
210 enum Output_file_type
211 {
3c2fafa5
ILT
212 // Uninitialized.
213 OUTPUT_INVALID,
7e1edb90
ILT
214 // Generating executable.
215 OUTPUT_EXECUTABLE,
216 // Generating shared library.
217 OUTPUT_SHARED,
218 // Generating object file.
219 OUTPUT_OBJECT
220 };
221
9e2dcb77
ILT
222 // Which symbols to strip.
223 enum Strip
224 {
3c2fafa5
ILT
225 // Uninitialize.
226 STRIP_INVALID,
9e2dcb77
ILT
227 // Don't strip any symbols.
228 STRIP_NONE,
229 // Strip all symbols.
230 STRIP_ALL,
231 // Strip debugging information.
02d2ba74
ILT
232 STRIP_DEBUG,
233 // Strip debugging information that's not used by gdb (at least <= 6.7)
234 STRIP_DEBUG_UNUSED_BY_GDB
9e2dcb77
ILT
235 };
236
75f2446e
ILT
237 // A pointer to the error handling object.
238 Errors* errors_;
239
3c2fafa5
ILT
240 // Whether the fields set from the options are valid.
241 bool options_valid_;
75f2446e
ILT
242 // The output file name.
243 const char* output_file_name_;
7e1edb90
ILT
244 // The type of the output file.
245 Output_file_type output_file_type_;
ad2d6943
ILT
246 // The target system root directory.
247 std::string sysroot_;
9e2dcb77
ILT
248 // Which symbols to strip.
249 Strip strip_;
e2827e5f
ILT
250 // Whether to allow undefined references from shared libraries.
251 bool allow_shlib_undefined_;
51b08ebe
ILT
252 // Whether we are doing a symbolic link.
253 bool symbolic_;
a2b1aa12
ILT
254 // Whether we should demangle C++ symbols in our log messages.
255 bool demangle_;
a55ce7fe
ILT
256 // Whether we try to detect One Definition Rule violations.
257 bool detect_odr_violations_;
3c2fafa5
ILT
258 // The optimization level.
259 int optimization_level_;
260 // Whether the -E/--export-dynamic flag is set.
261 bool export_dynamic_;
9e2dcb77 262
b3b74ddc
ILT
263 // Whether the doing_static_link_ field is valid.
264 bool is_doing_static_link_valid_;
265 // Whether we are doing a static link.
266 bool doing_static_link_;
9025d29d
ILT
267 // Whether the size_ and is_big_endian_ fields are valid.
268 bool is_size_and_endian_valid_;
269 // The size of the output file--32 or 64.
270 int size_;
271 // Whether the output file is big endian.
272 bool is_big_endian_;
7e1edb90
ILT
273};
274
275// This is a global variable.
276extern const Parameters* parameters;
277
278// Initialize the global variable.
3c2fafa5
ILT
279extern void initialize_parameters(Errors*);
280
281// Set the options.
282extern void set_parameters_from_options(const General_options*);
7e1edb90 283
9025d29d
ILT
284// Set the size and endianness of the global parameters variable.
285extern void set_parameters_size_and_endianness(int size, bool is_big_endian);
286
b3b74ddc
ILT
287// Set whether we are doing a static link.
288extern void set_parameters_doing_static_link(bool doing_static_link);
289
7e1edb90
ILT
290} // End namespace gold.
291
eb4dfdd4 292#endif // !defined(GOLD_PARAMETERS_H)
This page took 0.043463 seconds and 4 git commands to generate.