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.
43 Parameters(const General_options*, Errors*);
45 // Return the error object.
48 { return this->errors_; }
50 // Return the output file name.
52 output_file_name() const
53 { return this->output_file_name_; }
55 // Whether we are generating a regular executable.
57 output_is_executable() const
58 { return this->output_file_type_ == OUTPUT_EXECUTABLE; }
60 // Whether we are generating a shared library.
62 output_is_shared() const
63 { return this->output_file_type_ == OUTPUT_SHARED; }
65 // Whether we are generating an object file.
67 output_is_object() const
68 { return this->output_file_type_ == OUTPUT_OBJECT; }
70 // Whether we are generating position-independent output.
71 // This is the case when generating either a shared library
72 // or a regular executable with the --pic-executable option.
73 // FIXME: support --pic-executable
75 output_is_position_independent() const
76 { return output_is_shared(); }
78 // The target system root directory. This is NULL if there isn't
82 { return this->sysroot_; }
84 // Whether to strip all symbols.
87 { return this->strip_ == STRIP_ALL; }
89 // Whether to strip debugging information.
92 { return this->strip_ == STRIP_ALL || this->strip_ == STRIP_DEBUG; }
94 // Whether we are doing a static link--a link in which none of the
95 // input files are shared libraries. This is only known after we
96 // have seen all the input files.
98 doing_static_link() const
100 gold_assert(this->is_doing_static_link_valid_);
101 return this->doing_static_link_;
104 // The size of the output file we are generating. This should
109 gold_assert(this->is_size_and_endian_valid_);
113 // Whether the output is big endian.
115 is_big_endian() const
117 gold_assert(this->is_size_and_endian_valid_);
118 return this->is_big_endian_;
121 // The general linker optimization level.
123 optimization_level() const
124 { return this->optimization_level_; }
126 // Whether the -E/--export-dynamic flag is set.
128 export_dynamic() const
129 { return this->export_dynamic_; }
131 // Set whether we are doing a static link.
133 set_doing_static_link(bool doing_static_link);
135 // Set the size and endianness.
137 set_size_and_endianness(int size, bool is_big_endian);
140 // The types of output files.
141 enum Output_file_type
143 // Generating executable.
145 // Generating shared library.
147 // Generating object file.
151 // Which symbols to strip.
154 // Don't strip any symbols.
156 // Strip all symbols.
158 // Strip debugging information.
162 // A pointer to the error handling object.
165 // The output file name.
166 const char* output_file_name_;
167 // The type of the output file.
168 Output_file_type output_file_type_;
169 // The target system root directory.
170 std::string sysroot_;
171 // Which symbols to strip.
174 // Whether the doing_static_link_ field is valid.
175 bool is_doing_static_link_valid_;
176 // Whether we are doing a static link.
177 bool doing_static_link_;
178 // Whether the size_ and is_big_endian_ fields are valid.
179 bool is_size_and_endian_valid_;
180 // The size of the output file--32 or 64.
182 // Whether the output file is big endian.
184 // The optimization level.
185 int optimization_level_;
186 // Whether the -E/--export-dynamic flag is set.
187 bool export_dynamic_;
190 // This is a global variable.
191 extern const Parameters* parameters;
193 // Initialize the global variable.
194 extern void initialize_parameters(const General_options*, Errors*);
196 // Set the size and endianness of the global parameters variable.
197 extern void set_parameters_size_and_endianness(int size, bool is_big_endian);
199 // Set whether we are doing a static link.
200 extern void set_parameters_doing_static_link(bool doing_static_link);
202 } // End namespace gold.
204 #endif // !defined(GOLD_PARAMETERS_H)