Run all error handling through an Errors object. Delete output file
[deliverable/binutils-gdb.git] / gold / parameters.h
1 // parameters.h -- general parameters for a link using gold -*- C++ -*-
2
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
23 #ifndef GOLD_PARAMETERS_H
24 #define GOLD_PARAMETERS_H
25
26 namespace gold
27 {
28
29 class General_options;
30 class Errors;
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
40 class Parameters
41 {
42 public:
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_; }
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
70 // The target system root directory. This is NULL if there isn't
71 // one.
72 const std::string&
73 sysroot() const
74 { return this->sysroot_; }
75
76 // Whether to strip all symbols.
77 bool
78 strip_all() const
79 { return this->strip_ == STRIP_ALL; }
80
81 // Whether to strip debugging information.
82 bool
83 strip_debug() const
84 { return this->strip_ == STRIP_ALL || this->strip_ == STRIP_DEBUG; }
85
86 // Whether we are doing a static link--a link in which none of the
87 // input files are shared libraries. This is only known after we
88 // have seen all the input files.
89 bool
90 doing_static_link() const
91 {
92 gold_assert(this->is_doing_static_link_valid_);
93 return this->doing_static_link_;
94 }
95
96 // The size of the output file we are generating. This should
97 // return 32 or 64.
98 int
99 get_size() const
100 {
101 gold_assert(this->is_size_and_endian_valid_);
102 return this->size_;
103 }
104
105 // Whether the output is big endian.
106 bool
107 is_big_endian() const
108 {
109 gold_assert(this->is_size_and_endian_valid_);
110 return this->is_big_endian_;
111 }
112
113 // The general linker optimization level.
114 int
115 optimization_level() const
116 { return this->optimization_level_; }
117
118 // Set whether we are doing a static link.
119 void
120 set_doing_static_link(bool doing_static_link);
121
122 // Set the size and endianness.
123 void
124 set_size_and_endianness(int size, bool is_big_endian);
125
126 private:
127 // The types of output files.
128 enum Output_file_type
129 {
130 // Generating executable.
131 OUTPUT_EXECUTABLE,
132 // Generating shared library.
133 OUTPUT_SHARED,
134 // Generating object file.
135 OUTPUT_OBJECT
136 };
137
138 // Which symbols to strip.
139 enum Strip
140 {
141 // Don't strip any symbols.
142 STRIP_NONE,
143 // Strip all symbols.
144 STRIP_ALL,
145 // Strip debugging information.
146 STRIP_DEBUG
147 };
148
149 // A pointer to the error handling object.
150 Errors* errors_;
151
152 // The output file name.
153 const char* output_file_name_;
154 // The type of the output file.
155 Output_file_type output_file_type_;
156 // The target system root directory.
157 std::string sysroot_;
158 // Which symbols to strip.
159 Strip strip_;
160
161 // Whether the doing_static_link_ field is valid.
162 bool is_doing_static_link_valid_;
163 // Whether we are doing a static link.
164 bool doing_static_link_;
165 // Whether the size_ and is_big_endian_ fields are valid.
166 bool is_size_and_endian_valid_;
167 // The size of the output file--32 or 64.
168 int size_;
169 // Whether the output file is big endian.
170 bool is_big_endian_;
171 // The optimization level.
172 int optimization_level_;
173 };
174
175 // This is a global variable.
176 extern const Parameters* parameters;
177
178 // Initialize the global variable.
179 extern void initialize_parameters(const General_options*, Errors*);
180
181 // Set the size and endianness of the global parameters variable.
182 extern void set_parameters_size_and_endianness(int size, bool is_big_endian);
183
184 // Set whether we are doing a static link.
185 extern void set_parameters_doing_static_link(bool doing_static_link);
186
187 } // End namespace gold.
188
189 #endif // !defined(GOLD_PARAMETERS_H)
This page took 0.033196 seconds and 5 git commands to generate.