Commit | Line | Data |
---|---|---|
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 | ||
26 | namespace gold | |
27 | { | |
28 | ||
29 | class General_options; | |
30 | ||
31 | // Here we define the Parameters class which simply holds simple | |
32 | // general parameters which apply to the entire link. We use a global | |
33 | // variable for this. This is in contrast to the General_options | |
34 | // class, which holds the complete state of position independent | |
35 | // command line options. The hope is that Parameters will stay fairly | |
36 | // simple, so that if this turns into a library it will be clear how | |
37 | // these parameters should be set. | |
38 | ||
39 | class Parameters | |
40 | { | |
41 | public: | |
42 | Parameters(const General_options*); | |
43 | ||
44 | // Whether we are generating a regular executable. | |
45 | bool | |
46 | output_is_executable() const | |
47 | { return this->output_file_type_ == OUTPUT_EXECUTABLE; } | |
48 | ||
49 | // Whether we are generating a shared library. | |
50 | bool | |
51 | output_is_shared() const | |
52 | { return this->output_file_type_ == OUTPUT_SHARED; } | |
53 | ||
54 | // Whether we are generating an object file. | |
55 | bool | |
56 | output_is_object() const | |
57 | { return this->output_file_type_ == OUTPUT_OBJECT; } | |
58 | ||
ad2d6943 ILT |
59 | // The target system root directory. This is NULL if there isn't |
60 | // one. | |
61 | const std::string& | |
62 | sysroot() const | |
63 | { return this->sysroot_; } | |
64 | ||
9e2dcb77 ILT |
65 | // Whether to strip all symbols. |
66 | bool | |
67 | strip_all() const | |
68 | { return this->strip_ == STRIP_ALL; } | |
69 | ||
70 | // Whether to strip debugging information. | |
71 | bool | |
72 | strip_debug() const | |
73 | { return this->strip_ == STRIP_ALL || this->strip_ == STRIP_DEBUG; } | |
74 | ||
b3b74ddc ILT |
75 | // Whether we are doing a static link--a link in which none of the |
76 | // input files are shared libraries. This is only known after we | |
77 | // have seen all the input files. | |
78 | bool | |
79 | doing_static_link() const | |
80 | { | |
81 | gold_assert(this->is_doing_static_link_valid_); | |
82 | return this->doing_static_link_; | |
83 | } | |
84 | ||
9025d29d ILT |
85 | // The size of the output file we are generating. This should |
86 | // return 32 or 64. | |
87 | int | |
88 | get_size() const | |
89 | { | |
90 | gold_assert(this->is_size_and_endian_valid_); | |
91 | return this->size_; | |
92 | } | |
93 | ||
94 | // Whether the output is big endian. | |
95 | bool | |
96 | is_big_endian() const | |
97 | { | |
98 | gold_assert(this->is_size_and_endian_valid_); | |
99 | return this->is_big_endian_; | |
100 | } | |
101 | ||
7e1edb90 ILT |
102 | // The general linker optimization level. |
103 | int | |
104 | optimization_level() const | |
105 | { return this->optimization_level_; } | |
106 | ||
b3b74ddc ILT |
107 | // Set whether we are doing a static link. |
108 | void | |
109 | set_doing_static_link(bool doing_static_link); | |
110 | ||
9025d29d ILT |
111 | // Set the size and endianness. |
112 | void | |
113 | set_size_and_endianness(int size, bool is_big_endian); | |
114 | ||
7e1edb90 ILT |
115 | private: |
116 | // The types of output files. | |
117 | enum Output_file_type | |
118 | { | |
119 | // Generating executable. | |
120 | OUTPUT_EXECUTABLE, | |
121 | // Generating shared library. | |
122 | OUTPUT_SHARED, | |
123 | // Generating object file. | |
124 | OUTPUT_OBJECT | |
125 | }; | |
126 | ||
9e2dcb77 ILT |
127 | // Which symbols to strip. |
128 | enum Strip | |
129 | { | |
130 | // Don't strip any symbols. | |
131 | STRIP_NONE, | |
132 | // Strip all symbols. | |
133 | STRIP_ALL, | |
134 | // Strip debugging information. | |
135 | STRIP_DEBUG | |
136 | }; | |
137 | ||
7e1edb90 ILT |
138 | // The type of the output file. |
139 | Output_file_type output_file_type_; | |
ad2d6943 ILT |
140 | // The target system root directory. |
141 | std::string sysroot_; | |
9e2dcb77 ILT |
142 | // Which symbols to strip. |
143 | Strip strip_; | |
144 | ||
b3b74ddc ILT |
145 | // Whether the doing_static_link_ field is valid. |
146 | bool is_doing_static_link_valid_; | |
147 | // Whether we are doing a static link. | |
148 | bool doing_static_link_; | |
9025d29d ILT |
149 | // Whether the size_ and is_big_endian_ fields are valid. |
150 | bool is_size_and_endian_valid_; | |
151 | // The size of the output file--32 or 64. | |
152 | int size_; | |
153 | // Whether the output file is big endian. | |
154 | bool is_big_endian_; | |
7e1edb90 ILT |
155 | // The optimization level. |
156 | int optimization_level_; | |
157 | }; | |
158 | ||
159 | // This is a global variable. | |
160 | extern const Parameters* parameters; | |
161 | ||
162 | // Initialize the global variable. | |
163 | extern void initialize_parameters(const General_options*); | |
164 | ||
9025d29d ILT |
165 | // Set the size and endianness of the global parameters variable. |
166 | extern void set_parameters_size_and_endianness(int size, bool is_big_endian); | |
167 | ||
b3b74ddc ILT |
168 | // Set whether we are doing a static link. |
169 | extern void set_parameters_doing_static_link(bool doing_static_link); | |
170 | ||
7e1edb90 ILT |
171 | } // End namespace gold. |
172 | ||
eb4dfdd4 | 173 | #endif // !defined(GOLD_PARAMETERS_H) |