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 // Return the output file name.
52 output_file_name() const
54 gold_assert(this->options_valid_
);
55 return this->output_file_name_
;
58 // Whether we are generating a regular executable.
60 output_is_executable() const
62 gold_assert(this->output_file_type_
!= OUTPUT_INVALID
);
63 return this->output_file_type_
== OUTPUT_EXECUTABLE
;
66 // Whether we are generating a shared library.
68 output_is_shared() const
70 gold_assert(this->output_file_type_
!= OUTPUT_INVALID
);
71 return this->output_file_type_
== OUTPUT_SHARED
;
74 // Whether we are generating an object file.
76 output_is_object() const
78 gold_assert(this->output_file_type_
!= OUTPUT_INVALID
);
79 return this->output_file_type_
== OUTPUT_OBJECT
;
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
87 output_is_position_independent() const
88 { return output_is_shared(); }
90 // The target system root directory. This is NULL if there isn't
95 gold_assert(this->options_valid_
);
96 return this->sysroot_
;
99 // Whether to strip all symbols.
103 gold_assert(this->strip_
!= STRIP_INVALID
);
104 return this->strip_
== STRIP_ALL
;
107 // Whether to strip debugging information.
111 gold_assert(this->strip_
!= STRIP_INVALID
);
112 return this->strip_
== STRIP_ALL
|| this->strip_
== STRIP_DEBUG
;
115 // Whether to permit unresolved references from shared libraries.
117 allow_shlib_undefined() const
119 gold_assert(this->options_valid_
);
120 return this->allow_shlib_undefined_
;
123 // Whether we are doing a symbolic link, in which all defined
124 // symbols are bound locally.
128 gold_assert(this->options_valid_
);
129 return this->symbolic_
;
132 // Whether we should demangle C++ symbols in our log messages.
135 { return this->demangle_
; }
137 // Whether we should try to detect violations of the One Definition Rule.
139 detect_odr_violations() const
141 gold_assert(this->options_valid_
);
142 return this->detect_odr_violations_
;
145 // The general linker optimization level.
147 optimization_level() const
149 gold_assert(this->options_valid_
);
150 return this->optimization_level_
;
153 // Whether the -E/--export-dynamic flag is set.
155 export_dynamic() const
157 gold_assert(this->options_valid_
);
158 return this->export_dynamic_
;
161 // Whether we are doing a static link--a link in which none of the
162 // input files are shared libraries. This is only known after we
163 // have seen all the input files.
165 doing_static_link() const
167 gold_assert(this->is_doing_static_link_valid_
);
168 return this->doing_static_link_
;
171 // The size of the output file we are generating. This should
176 gold_assert(this->is_size_and_endian_valid_
);
180 // Whether the output is big endian.
182 is_big_endian() const
184 gold_assert(this->is_size_and_endian_valid_
);
185 return this->is_big_endian_
;
188 // Set values recorded from options.
190 set_from_options(const General_options
*);
192 // Set whether we are doing a static link.
194 set_doing_static_link(bool doing_static_link
);
196 // Set the size and endianness.
198 set_size_and_endianness(int size
, bool is_big_endian
);
201 // The types of output files.
202 enum Output_file_type
206 // Generating executable.
208 // Generating shared library.
210 // Generating object file.
214 // Which symbols to strip.
219 // Don't strip any symbols.
221 // Strip all symbols.
223 // Strip debugging information.
227 // A pointer to the error handling object.
230 // Whether the fields set from the options are valid.
232 // The output file name.
233 const char* output_file_name_
;
234 // The type of the output file.
235 Output_file_type output_file_type_
;
236 // The target system root directory.
237 std::string sysroot_
;
238 // Which symbols to strip.
240 // Whether to allow undefined references from shared libraries.
241 bool allow_shlib_undefined_
;
242 // Whether we are doing a symbolic link.
244 // Whether we should demangle C++ symbols in our log messages.
246 // Whether we try to detect One Definition Rule violations.
247 bool detect_odr_violations_
;
248 // The optimization level.
249 int optimization_level_
;
250 // Whether the -E/--export-dynamic flag is set.
251 bool export_dynamic_
;
253 // Whether the doing_static_link_ field is valid.
254 bool is_doing_static_link_valid_
;
255 // Whether we are doing a static link.
256 bool doing_static_link_
;
257 // Whether the size_ and is_big_endian_ fields are valid.
258 bool is_size_and_endian_valid_
;
259 // The size of the output file--32 or 64.
261 // Whether the output file is big endian.
265 // This is a global variable.
266 extern const Parameters
* parameters
;
268 // Initialize the global variable.
269 extern void initialize_parameters(Errors
*);
272 extern void set_parameters_from_options(const General_options
*);
274 // Set the size and endianness of the global parameters variable.
275 extern void set_parameters_size_and_endianness(int size
, bool is_big_endian
);
277 // Set whether we are doing a static link.
278 extern void set_parameters_doing_static_link(bool doing_static_link
);
280 } // End namespace gold.
282 #endif // !defined(GOLD_PARAMETERS_H)