1 // parameters.h -- general parameters for a link using gold -*- C++ -*-
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
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.
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.
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.
23 #ifndef GOLD_PARAMETERS_H
24 #define GOLD_PARAMETERS_H
29 class General_options
;
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.
45 // Return the error object.
48 { return this->errors_
; }
50 // Whether the options are valid. This should not normally be
51 // called, but it is needed by gold_exit.
54 { return this->options_valid_
; }
56 // Whether to use threads.
60 gold_assert(this->options_valid_
);
61 return this->threads_
;
64 // Return the output file name.
66 output_file_name() const
68 gold_assert(this->options_valid_
);
69 return this->output_file_name_
;
72 // Whether we are generating a regular executable.
74 output_is_executable() const
76 gold_assert(this->output_file_type_
!= OUTPUT_INVALID
);
77 return this->output_file_type_
== OUTPUT_EXECUTABLE
;
80 // Whether we are generating a shared library.
82 output_is_shared() const
84 gold_assert(this->output_file_type_
!= OUTPUT_INVALID
);
85 return this->output_file_type_
== OUTPUT_SHARED
;
88 // Whether we are generating an object file.
90 output_is_object() const
92 gold_assert(this->output_file_type_
!= OUTPUT_INVALID
);
93 return this->output_file_type_
== OUTPUT_OBJECT
;
96 // Whether we are generating position-independent output.
97 // This is the case when generating either a shared library
98 // or a regular executable with the --pic-executable option.
99 // FIXME: support --pic-executable
101 output_is_position_independent() const
102 { return output_is_shared(); }
104 // The target system root directory. This is NULL if there isn't
109 gold_assert(this->options_valid_
);
110 return this->sysroot_
;
113 // Whether to strip all symbols.
117 gold_assert(this->strip_
!= STRIP_INVALID
);
118 return this->strip_
== STRIP_ALL
;
121 // Whether to strip debugging information.
125 gold_assert(this->strip_
!= STRIP_INVALID
);
126 return this->strip_
== STRIP_ALL
|| this->strip_
== STRIP_DEBUG
;
129 // Whether to strip debugging information that's not used by gdb.
131 strip_debug_gdb() const
133 gold_assert(this->strip_
!= STRIP_INVALID
);
134 return this->strip_debug() || this->strip_
== STRIP_DEBUG_UNUSED_BY_GDB
;
137 // Whether to permit unresolved references from shared libraries.
139 allow_shlib_undefined() const
141 gold_assert(this->options_valid_
);
142 return this->allow_shlib_undefined_
;
145 // Whether we are doing a symbolic link, in which all defined
146 // symbols are bound locally.
150 gold_assert(this->options_valid_
);
151 return this->symbolic_
;
154 // Whether we should demangle C++ symbols in our log messages.
157 { return this->demangle_
; }
159 // Whether we should try to detect violations of the One Definition Rule.
161 detect_odr_violations() const
163 gold_assert(this->options_valid_
);
164 return this->detect_odr_violations_
;
167 // The general linker optimization level.
169 optimization_level() const
171 gold_assert(this->options_valid_
);
172 return this->optimization_level_
;
175 // Whether the -E/--export-dynamic flag is set.
177 export_dynamic() const
179 gold_assert(this->options_valid_
);
180 return this->export_dynamic_
;
183 // Return the debug flags. These are the flags for which we should
184 // report internal debugging information.
188 gold_assert(this->options_valid_
);
192 // Whether we are doing a static link--a link in which none of the
193 // input files are shared libraries. This is only known after we
194 // have seen all the input files.
196 doing_static_link() const
198 gold_assert(this->is_doing_static_link_valid_
);
199 return this->doing_static_link_
;
202 // The size of the output file we are generating. This should
207 gold_assert(this->is_size_and_endian_valid_
);
211 // Whether the output is big endian.
213 is_big_endian() const
215 gold_assert(this->is_size_and_endian_valid_
);
216 return this->is_big_endian_
;
219 // Set values recorded from options.
221 set_from_options(const General_options
*);
223 // Set whether we are doing a static link.
225 set_doing_static_link(bool doing_static_link
);
227 // Set the size and endianness.
229 set_size_and_endianness(int size
, bool is_big_endian
);
232 // The types of output files.
233 enum Output_file_type
237 // Generating executable.
239 // Generating shared library.
241 // Generating object file.
245 // Which symbols to strip.
250 // Don't strip any symbols.
252 // Strip all symbols.
254 // Strip debugging information.
256 // Strip debugging information that's not used by gdb (at least <= 6.7)
257 STRIP_DEBUG_UNUSED_BY_GDB
260 // A pointer to the error handling object.
263 // Whether the fields set from the options are valid.
265 // Whether to use threads.
267 // The output file name.
268 const char* output_file_name_
;
269 // The type of the output file.
270 Output_file_type output_file_type_
;
271 // The target system root directory.
272 std::string sysroot_
;
273 // Which symbols to strip.
275 // Whether to allow undefined references from shared libraries.
276 bool allow_shlib_undefined_
;
277 // Whether we are doing a symbolic link.
279 // Whether we should demangle C++ symbols in our log messages.
281 // Whether we try to detect One Definition Rule violations.
282 bool detect_odr_violations_
;
283 // The optimization level.
284 int optimization_level_
;
285 // Whether the -E/--export-dynamic flag is set.
286 bool export_dynamic_
;
290 // Whether the doing_static_link_ field is valid.
291 bool is_doing_static_link_valid_
;
292 // Whether we are doing a static link.
293 bool doing_static_link_
;
294 // Whether the size_ and is_big_endian_ fields are valid.
295 bool is_size_and_endian_valid_
;
296 // The size of the output file--32 or 64.
298 // Whether the output file is big endian.
302 // This is a global variable.
303 extern const Parameters
* parameters
;
305 // Initialize the global variable.
306 extern void initialize_parameters(Errors
*);
309 extern void set_parameters_from_options(const General_options
*);
311 // Set the size and endianness of the global parameters variable.
312 extern void set_parameters_size_and_endianness(int size
, bool is_big_endian
);
314 // Set whether we are doing a static link.
315 extern void set_parameters_doing_static_link(bool doing_static_link
);
317 // Return whether we are doing a particular debugging type. The
318 // argument is one of the flags from debug.h.
321 is_debugging_enabled(unsigned int type
)
322 { return (parameters
->debug() & type
) != 0; }
324 } // End namespace gold.
326 #endif // !defined(GOLD_PARAMETERS_H)