*** 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:
75f2446e
ILT
43 Parameters(const General_options*, Errors*);
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
53 { return this->output_file_name_; }
7e1edb90
ILT
54
55 // Whether we are generating a regular executable.
56 bool
57 output_is_executable() const
58 { return this->output_file_type_ == OUTPUT_EXECUTABLE; }
59
60 // Whether we are generating a shared library.
61 bool
62 output_is_shared() const
63 { return this->output_file_type_ == OUTPUT_SHARED; }
64
65 // Whether we are generating an object file.
66 bool
67 output_is_object() const
68 { return this->output_file_type_ == OUTPUT_OBJECT; }
69
436ca963
ILT
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
74 bool
75 output_is_position_independent() const
76 { return output_is_shared(); }
77
ad2d6943
ILT
78 // The target system root directory. This is NULL if there isn't
79 // one.
80 const std::string&
81 sysroot() const
82 { return this->sysroot_; }
83
9e2dcb77
ILT
84 // Whether to strip all symbols.
85 bool
86 strip_all() const
87 { return this->strip_ == STRIP_ALL; }
88
89 // Whether to strip debugging information.
90 bool
91 strip_debug() const
92 { return this->strip_ == STRIP_ALL || this->strip_ == STRIP_DEBUG; }
93
51b08ebe
ILT
94 // Whether we are doing a symbolic link, in which all defined
95 // symbols are bound locally.
96 bool
97 symbolic() const
98 { return this->symbolic_; }
99
b3b74ddc
ILT
100 // Whether we are doing a static link--a link in which none of the
101 // input files are shared libraries. This is only known after we
102 // have seen all the input files.
103 bool
104 doing_static_link() const
105 {
106 gold_assert(this->is_doing_static_link_valid_);
107 return this->doing_static_link_;
108 }
109
9025d29d
ILT
110 // The size of the output file we are generating. This should
111 // return 32 or 64.
112 int
113 get_size() const
114 {
115 gold_assert(this->is_size_and_endian_valid_);
116 return this->size_;
117 }
118
119 // Whether the output is big endian.
120 bool
121 is_big_endian() const
122 {
123 gold_assert(this->is_size_and_endian_valid_);
124 return this->is_big_endian_;
125 }
126
7e1edb90
ILT
127 // The general linker optimization level.
128 int
129 optimization_level() const
130 { return this->optimization_level_; }
131
436ca963
ILT
132 // Whether the -E/--export-dynamic flag is set.
133 bool
134 export_dynamic() const
135 { return this->export_dynamic_; }
136
b3b74ddc
ILT
137 // Set whether we are doing a static link.
138 void
139 set_doing_static_link(bool doing_static_link);
140
9025d29d
ILT
141 // Set the size and endianness.
142 void
143 set_size_and_endianness(int size, bool is_big_endian);
144
7e1edb90
ILT
145 private:
146 // The types of output files.
147 enum Output_file_type
148 {
149 // Generating executable.
150 OUTPUT_EXECUTABLE,
151 // Generating shared library.
152 OUTPUT_SHARED,
153 // Generating object file.
154 OUTPUT_OBJECT
155 };
156
9e2dcb77
ILT
157 // Which symbols to strip.
158 enum Strip
159 {
160 // Don't strip any symbols.
161 STRIP_NONE,
162 // Strip all symbols.
163 STRIP_ALL,
164 // Strip debugging information.
165 STRIP_DEBUG
166 };
167
75f2446e
ILT
168 // A pointer to the error handling object.
169 Errors* errors_;
170
171 // The output file name.
172 const char* output_file_name_;
7e1edb90
ILT
173 // The type of the output file.
174 Output_file_type output_file_type_;
ad2d6943
ILT
175 // The target system root directory.
176 std::string sysroot_;
9e2dcb77
ILT
177 // Which symbols to strip.
178 Strip strip_;
51b08ebe
ILT
179 // Whether we are doing a symbolic link.
180 bool symbolic_;
9e2dcb77 181
b3b74ddc
ILT
182 // Whether the doing_static_link_ field is valid.
183 bool is_doing_static_link_valid_;
184 // Whether we are doing a static link.
185 bool doing_static_link_;
9025d29d
ILT
186 // Whether the size_ and is_big_endian_ fields are valid.
187 bool is_size_and_endian_valid_;
188 // The size of the output file--32 or 64.
189 int size_;
190 // Whether the output file is big endian.
191 bool is_big_endian_;
7e1edb90
ILT
192 // The optimization level.
193 int optimization_level_;
436ca963
ILT
194 // Whether the -E/--export-dynamic flag is set.
195 bool export_dynamic_;
7e1edb90
ILT
196};
197
198// This is a global variable.
199extern const Parameters* parameters;
200
201// Initialize the global variable.
75f2446e 202extern void initialize_parameters(const General_options*, Errors*);
7e1edb90 203
9025d29d
ILT
204// Set the size and endianness of the global parameters variable.
205extern void set_parameters_size_and_endianness(int size, bool is_big_endian);
206
b3b74ddc
ILT
207// Set whether we are doing a static link.
208extern void set_parameters_doing_static_link(bool doing_static_link);
209
7e1edb90
ILT
210} // End namespace gold.
211
eb4dfdd4 212#endif // !defined(GOLD_PARAMETERS_H)
This page took 0.037477 seconds and 4 git commands to generate.