Commit | Line | Data |
---|---|---|
bae7f79e ILT |
1 | // options.h -- handle command line options for gold -*- C++ -*- |
2 | ||
e5756efb | 3 | // Copyright 2006, 2007, 2008 Free Software Foundation, Inc. |
6cb15b7f ILT |
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 | ||
bae7f79e | 23 | // General_options (from Command_line::options()) |
ee1fe73e | 24 | // All the options (a.k.a. command-line flags) |
bae7f79e ILT |
25 | // Input_argument (from Command_line::inputs()) |
26 | // The list of input files, including -l options. | |
ee1fe73e ILT |
27 | // Command_line |
28 | // Everything we get from the command line -- the General_options | |
29 | // plus the Input_arguments. | |
30 | // | |
31 | // There are also some smaller classes, such as | |
32 | // Position_dependent_options which hold a subset of General_options | |
33 | // that change as options are parsed (as opposed to the usual behavior | |
34 | // of the last instance of that option specified on the commandline wins). | |
bae7f79e ILT |
35 | |
36 | #ifndef GOLD_OPTIONS_H | |
37 | #define GOLD_OPTIONS_H | |
38 | ||
ca3a67a5 | 39 | #include <cstdlib> |
bae7f79e | 40 | #include <list> |
61ba1cf9 | 41 | #include <string> |
92e059d8 | 42 | #include <vector> |
bae7f79e | 43 | |
0daa6f62 | 44 | #include "elfcpp.h" |
3c2fafa5 ILT |
45 | #include "script.h" |
46 | ||
bae7f79e ILT |
47 | namespace gold |
48 | { | |
49 | ||
50 | class Command_line; | |
ee1fe73e ILT |
51 | class General_options; |
52 | class Search_directory; | |
ead1e424 | 53 | class Input_file_group; |
3c2fafa5 | 54 | class Position_dependent_options; |
0daa6f62 | 55 | class Target; |
bae7f79e | 56 | |
ee1fe73e ILT |
57 | // The nested namespace is to contain all the global variables and |
58 | // structs that need to be defined in the .h file, but do not need to | |
59 | // be used outside this class. | |
c7912668 ILT |
60 | namespace options |
61 | { | |
ee1fe73e ILT |
62 | typedef std::vector<Search_directory> Dir_list; |
63 | ||
64 | // These routines convert from a string option to various types. | |
65 | // Each gives a fatal error if it cannot parse the argument. | |
66 | ||
67 | extern void | |
68 | parse_bool(const char* option_name, const char* arg, bool* retval); | |
69 | ||
70 | extern void | |
71 | parse_uint(const char* option_name, const char* arg, int* retval); | |
72 | ||
73 | extern void | |
74 | parse_uint64(const char* option_name, const char* arg, uint64_t *retval); | |
75 | ||
76 | extern void | |
77 | parse_string(const char* option_name, const char* arg, const char** retval); | |
78 | ||
79 | extern void | |
80 | parse_dirlist(const char* option_name, const char* arg, Dir_list* retval); | |
81 | ||
82 | extern void | |
83 | parse_choices(const char* option_name, const char* arg, const char** retval, | |
84 | const char* choices[], int num_choices); | |
85 | ||
86 | struct Struct_var; | |
87 | ||
88 | // Most options have both a shortname (one letter) and a longname. | |
89 | // This enum controls how many dashes are expected for longname access | |
90 | // -- shortnames always use one dash. Most longnames will accept | |
91 | // either one dash or two; the only difference between ONE_DASH and | |
92 | // TWO_DASHES is how we print the option in --help. However, some | |
93 | // longnames require two dashes, and some require only one. The | |
94 | // special value DASH_Z means that the option is preceded by "-z". | |
95 | enum Dashes | |
96 | { | |
97 | ONE_DASH, TWO_DASHES, EXACTLY_ONE_DASH, EXACTLY_TWO_DASHES, DASH_Z | |
98 | }; | |
99 | ||
100 | // LONGNAME is the long-name of the option with dashes converted to | |
101 | // underscores, or else the short-name if the option has no long-name. | |
102 | // It is never the empty string. | |
103 | // DASHES is an instance of the Dashes enum: ONE_DASH, TWO_DASHES, etc. | |
104 | // SHORTNAME is the short-name of the option, as a char, or '\0' if the | |
105 | // option has no short-name. If the option has no long-name, you | |
106 | // should specify the short-name in *both* VARNAME and here. | |
107 | // DEFAULT_VALUE is the value of the option if not specified on the | |
108 | // commandline, as a string. | |
109 | // HELPSTRING is the descriptive text used with the option via --help | |
110 | // HELPARG is how you define the argument to the option. | |
111 | // --help output is "-shortname HELPARG, --longname HELPARG: HELPSTRING" | |
112 | // HELPARG should be NULL iff the option is a bool and takes no arg. | |
113 | // READER provides parse_to_value, which is a function that will convert | |
114 | // a char* argument into the proper type and store it in some variable. | |
115 | // A One_option struct initializes itself with the global list of options | |
116 | // at constructor time, so be careful making one of these. | |
117 | struct One_option | |
118 | { | |
119 | std::string longname; | |
120 | Dashes dashes; | |
121 | char shortname; | |
122 | const char* default_value; | |
123 | const char* helpstring; | |
124 | const char* helparg; | |
125 | Struct_var* reader; | |
126 | ||
127 | One_option(const char* ln, Dashes d, char sn, const char* dv, | |
128 | const char* hs, const char* ha, Struct_var* r) | |
129 | : longname(ln), dashes(d), shortname(sn), default_value(dv ? dv : ""), | |
130 | helpstring(hs), helparg(ha), reader(r) | |
131 | { | |
132 | // In longname, we convert all underscores to dashes, since GNU | |
133 | // style uses dashes in option names. longname is likely to have | |
134 | // underscores in it because it's also used to declare a C++ | |
135 | // function. | |
136 | const char* pos = strchr(this->longname.c_str(), '_'); | |
137 | for (; pos; pos = strchr(pos, '_')) | |
138 | this->longname[pos - this->longname.c_str()] = '-'; | |
139 | ||
140 | // We only register ourselves if our helpstring is not NULL. This | |
141 | // is to support the "no-VAR" boolean variables, which we | |
142 | // conditionally turn on by defining "no-VAR" help text. | |
143 | if (this->helpstring) | |
144 | this->register_option(); | |
145 | } | |
146 | ||
147 | // This option takes an argument iff helparg is not NULL. | |
148 | bool | |
149 | takes_argument() const | |
150 | { return this->helparg != NULL; } | |
151 | ||
152 | // Register this option with the global list of options. | |
153 | void | |
154 | register_option(); | |
155 | ||
156 | // Print this option to stdout (used with --help). | |
157 | void | |
158 | print() const; | |
159 | }; | |
160 | ||
161 | // All options have a Struct_##varname that inherits from this and | |
162 | // actually implements parse_to_value for that option. | |
163 | struct Struct_var | |
164 | { | |
165 | // OPTION: the name of the option as specified on the commandline, | |
166 | // including leading dashes, and any text following the option: | |
167 | // "-O", "--defsym=mysym=0x1000", etc. | |
168 | // ARG: the arg associated with this option, or NULL if the option | |
169 | // takes no argument: "2", "mysym=0x1000", etc. | |
170 | // CMDLINE: the global Command_line object. Used by DEFINE_special. | |
171 | // OPTIONS: the global General_options object. Used by DEFINE_special. | |
172 | virtual void | |
173 | parse_to_value(const char* option, const char* arg, | |
174 | Command_line* cmdline, General_options* options) = 0; | |
175 | virtual | |
176 | ~Struct_var() // To make gcc happy. | |
177 | { } | |
178 | }; | |
bae7f79e | 179 | |
ee1fe73e ILT |
180 | // This is for "special" options that aren't of any predefined type. |
181 | struct Struct_special : public Struct_var | |
182 | { | |
183 | // If you change this, change the parse-fn in DEFINE_special as well. | |
184 | typedef void (General_options::*Parse_function)(const char*, const char*, | |
185 | Command_line*); | |
186 | Struct_special(const char* varname, Dashes dashes, char shortname, | |
187 | Parse_function parse_function, | |
188 | const char* helpstring, const char* helparg) | |
189 | : option(varname, dashes, shortname, "", helpstring, helparg, this), | |
190 | parse(parse_function) | |
191 | { } | |
192 | ||
193 | void parse_to_value(const char* option, const char* arg, | |
194 | Command_line* cmdline, General_options* options) | |
195 | { (options->*(this->parse))(option, arg, cmdline); } | |
196 | ||
197 | One_option option; | |
198 | Parse_function parse; | |
199 | }; | |
200 | ||
201 | } // End namespace options. | |
202 | ||
203 | ||
204 | // These are helper macros use by DEFINE_uint64/etc below. | |
205 | // This macro is used inside the General_options_ class, so defines | |
206 | // var() and set_var() as General_options methods. Arguments as are | |
207 | // for the constructor for One_option. param_type__ is the same as | |
208 | // type__ for built-in types, and "const type__ &" otherwise. | |
209 | #define DEFINE_var(varname__, dashes__, shortname__, default_value__, \ | |
210 | default_value_as_string__, helpstring__, helparg__, \ | |
211 | type__, param_type__, parse_fn__) \ | |
212 | public: \ | |
213 | param_type__ \ | |
214 | varname__() const \ | |
215 | { return this->varname__##_.value; } \ | |
216 | \ | |
217 | bool \ | |
218 | user_set_##varname__() const \ | |
219 | { return this->varname__##_.user_set_via_option; } \ | |
220 | \ | |
221 | private: \ | |
222 | struct Struct_##varname__ : public options::Struct_var \ | |
223 | { \ | |
224 | Struct_##varname__() \ | |
225 | : option(#varname__, dashes__, shortname__, default_value_as_string__, \ | |
226 | helpstring__, helparg__, this), \ | |
227 | user_set_via_option(false), value(default_value__) \ | |
228 | { } \ | |
229 | \ | |
230 | void \ | |
231 | parse_to_value(const char* option_name, const char* arg, \ | |
232 | Command_line*, General_options*) \ | |
233 | { \ | |
234 | parse_fn__(option_name, arg, &this->value); \ | |
235 | this->user_set_via_option = true; \ | |
236 | } \ | |
237 | \ | |
238 | options::One_option option; \ | |
239 | bool user_set_via_option; \ | |
240 | type__ value; \ | |
241 | }; \ | |
242 | Struct_##varname__ varname__##_; \ | |
243 | void \ | |
244 | set_##varname__(param_type__ value) \ | |
245 | { this->varname__##_.value = value; } | |
246 | ||
247 | // These macros allow for easy addition of a new commandline option. | |
248 | ||
249 | // If no_helpstring__ is not NULL, then in addition to creating | |
250 | // VARNAME, we also create an option called no-VARNAME. | |
251 | #define DEFINE_bool(varname__, dashes__, shortname__, default_value__, \ | |
252 | helpstring__, no_helpstring__) \ | |
253 | DEFINE_var(varname__, dashes__, shortname__, default_value__, \ | |
254 | default_value__ ? "true" : "false", helpstring__, NULL, \ | |
255 | bool, bool, options::parse_bool) \ | |
256 | struct Struct_no_##varname__ : public options::Struct_var \ | |
257 | { \ | |
258 | Struct_no_##varname__() : option("no-" #varname__, dashes__, '\0', \ | |
259 | default_value__ ? "false" : "true", \ | |
260 | no_helpstring__, NULL, this) \ | |
261 | { } \ | |
262 | \ | |
263 | void \ | |
264 | parse_to_value(const char*, const char*, \ | |
265 | Command_line*, General_options* options) \ | |
266 | { options->set_##varname__(false); } \ | |
267 | \ | |
268 | options::One_option option; \ | |
269 | }; \ | |
270 | Struct_no_##varname__ no_##varname__##_initializer_ | |
271 | ||
272 | #define DEFINE_uint(varname__, dashes__, shortname__, default_value__, \ | |
273 | helpstring__, helparg__) \ | |
274 | DEFINE_var(varname__, dashes__, shortname__, default_value__, \ | |
275 | #default_value__, helpstring__, helparg__, \ | |
276 | int, int, options::parse_uint) | |
277 | ||
278 | #define DEFINE_uint64(varname__, dashes__, shortname__, default_value__, \ | |
279 | helpstring__, helparg__) \ | |
280 | DEFINE_var(varname__, dashes__, shortname__, default_value__, \ | |
281 | #default_value__, helpstring__, helparg__, \ | |
282 | uint64_t, uint64_t, options::parse_uint64) | |
283 | ||
284 | #define DEFINE_string(varname__, dashes__, shortname__, default_value__, \ | |
285 | helpstring__, helparg__) \ | |
286 | DEFINE_var(varname__, dashes__, shortname__, default_value__, \ | |
287 | default_value__, helpstring__, helparg__, \ | |
288 | const char*, const char*, options::parse_string) | |
289 | ||
290 | // This is like DEFINE_string, but we convert each occurrence to a | |
291 | // Search_directory and store it in a vector. Thus we also have the | |
292 | // add_to_VARNAME() method, to append to the vector. | |
293 | #define DEFINE_dirlist(varname__, dashes__, shortname__, \ | |
294 | helpstring__, helparg__) \ | |
295 | DEFINE_var(varname__, dashes__, shortname__, , \ | |
296 | "", helpstring__, helparg__, options::Dir_list, \ | |
297 | const options::Dir_list&, options::parse_dirlist) \ | |
298 | void \ | |
299 | add_to_##varname__(const char* new_value) \ | |
300 | { options::parse_dirlist(NULL, new_value, &this->varname__##_.value); } \ | |
301 | void \ | |
302 | add_search_directory_to_##varname__(const Search_directory& dir) \ | |
303 | { this->varname__##_.value.push_back(dir); } | |
304 | ||
305 | // When you have a list of possible values (expressed as string) | |
306 | // After helparg__ should come an initializer list, like | |
307 | // {"foo", "bar", "baz"} | |
308 | #define DEFINE_enum(varname__, dashes__, shortname__, default_value__, \ | |
309 | helpstring__, helparg__, ...) \ | |
310 | DEFINE_var(varname__, dashes__, shortname__, default_value__, \ | |
311 | default_value__, helpstring__, helparg__, \ | |
312 | const char*, const char*, parse_choices_##varname__) \ | |
313 | private: \ | |
314 | static void parse_choices_##varname__(const char* option_name, \ | |
315 | const char* arg, \ | |
316 | const char** retval) { \ | |
317 | const char* choices[] = __VA_ARGS__; \ | |
318 | options::parse_choices(option_name, arg, retval, \ | |
319 | choices, sizeof(choices) / sizeof(*choices)); \ | |
320 | } | |
321 | ||
322 | // This is used for non-standard flags. It defines no functions; it | |
323 | // just calls General_options::parse_VARNAME whenever the flag is | |
324 | // seen. We declare parse_VARNAME as a static member of | |
325 | // General_options; you are responsible for defining it there. | |
326 | // helparg__ should be NULL iff this special-option is a boolean. | |
327 | #define DEFINE_special(varname__, dashes__, shortname__, \ | |
328 | helpstring__, helparg__) \ | |
329 | private: \ | |
330 | void parse_##varname__(const char* option, const char* arg, \ | |
331 | Command_line* inputs); \ | |
332 | struct Struct_##varname__ : public options::Struct_special \ | |
333 | { \ | |
334 | Struct_##varname__() \ | |
335 | : options::Struct_special(#varname__, dashes__, shortname__, \ | |
336 | &General_options::parse_##varname__, \ | |
337 | helpstring__, helparg__) \ | |
338 | { } \ | |
339 | }; \ | |
340 | Struct_##varname__ varname__##_initializer_ | |
bae7f79e | 341 | |
bae7f79e | 342 | |
ad2d6943 ILT |
343 | // A directory to search. For each directory we record whether it is |
344 | // in the sysroot. We need to know this so that, if a linker script | |
345 | // is found within the sysroot, we will apply the sysroot to any files | |
346 | // named by that script. | |
347 | ||
348 | class Search_directory | |
349 | { | |
350 | public: | |
351 | // We need a default constructor because we put this in a | |
352 | // std::vector. | |
353 | Search_directory() | |
354 | : name_(NULL), put_in_sysroot_(false), is_in_sysroot_(false) | |
355 | { } | |
356 | ||
357 | // This is the usual constructor. | |
358 | Search_directory(const char* name, bool put_in_sysroot) | |
359 | : name_(name), put_in_sysroot_(put_in_sysroot), is_in_sysroot_(false) | |
15893b88 ILT |
360 | { |
361 | if (this->name_.empty()) | |
362 | this->name_ = "."; | |
363 | } | |
ad2d6943 ILT |
364 | |
365 | // This is called if we have a sysroot. The sysroot is prefixed to | |
366 | // any entries for which put_in_sysroot_ is true. is_in_sysroot_ is | |
367 | // set to true for any enries which are in the sysroot (this will | |
368 | // naturally include any entries for which put_in_sysroot_ is true). | |
369 | // SYSROOT is the sysroot, CANONICAL_SYSROOT is the result of | |
370 | // passing SYSROOT to lrealpath. | |
371 | void | |
372 | add_sysroot(const char* sysroot, const char* canonical_sysroot); | |
373 | ||
374 | // Get the directory name. | |
375 | const std::string& | |
376 | name() const | |
377 | { return this->name_; } | |
378 | ||
379 | // Return whether this directory is in the sysroot. | |
380 | bool | |
381 | is_in_sysroot() const | |
382 | { return this->is_in_sysroot_; } | |
383 | ||
384 | private: | |
385 | std::string name_; | |
386 | bool put_in_sysroot_; | |
387 | bool is_in_sysroot_; | |
388 | }; | |
389 | ||
bae7f79e ILT |
390 | class General_options |
391 | { | |
ee1fe73e ILT |
392 | private: |
393 | // NOTE: For every option that you add here, also consider if you | |
394 | // should add it to Position_dependent_options. | |
395 | DEFINE_special(help, options::TWO_DASHES, '\0', | |
a4d4b13f | 396 | N_("Report usage information"), NULL); |
ee1fe73e | 397 | DEFINE_special(version, options::TWO_DASHES, 'v', |
a4d4b13f | 398 | N_("Report version information"), NULL); |
ee1fe73e ILT |
399 | |
400 | DEFINE_bool(allow_shlib_undefined, options::TWO_DASHES, '\0', false, | |
a4d4b13f ILT |
401 | N_("Allow unresolved references in shared libraries"), |
402 | N_("Do not allow unresolved references in shared libraries")); | |
ee1fe73e ILT |
403 | |
404 | DEFINE_bool(as_needed, options::TWO_DASHES, '\0', false, | |
a4d4b13f ILT |
405 | N_("Only set DT_NEEDED for dynamic libs if used"), |
406 | N_("Always DT_NEEDED for dynamic libs")); | |
ee1fe73e ILT |
407 | |
408 | DEFINE_bool(Bdynamic, options::ONE_DASH, '\0', true, | |
a4d4b13f | 409 | N_("-l searches for shared libraries"), NULL); |
ee1fe73e ILT |
410 | // Bstatic affects the same variable as Bdynamic, so we have to use |
411 | // the "special" macro to make that happen. | |
412 | DEFINE_special(Bstatic, options::ONE_DASH, '\0', | |
a4d4b13f | 413 | N_("-l does not search for shared libraries"), NULL); |
ee1fe73e ILT |
414 | |
415 | DEFINE_bool(Bsymbolic, options::ONE_DASH, '\0', false, | |
a4d4b13f | 416 | N_("Bind defined symbols locally"), NULL); |
ee1fe73e | 417 | |
09ffbbe0 ILT |
418 | // This should really be an "enum", but it's too easy for folks to |
419 | // forget to update the list as they add new targets. So we just | |
420 | // accept any string. We'll fail later (when the string is parsed), | |
421 | // if the target isn't actually supported. | |
422 | DEFINE_string(format, options::TWO_DASHES, 'b', "elf", | |
a4d4b13f | 423 | N_("Set input format"), ("[elf,binary]")); |
bae7f79e | 424 | |
ee1fe73e ILT |
425 | #ifdef HAVE_ZLIB_H |
426 | DEFINE_enum(compress_debug_sections, options::TWO_DASHES, '\0', "none", | |
a4d4b13f ILT |
427 | N_("Compress .debug_* sections in the output file"), |
428 | ("[none,zlib]"), | |
ee1fe73e ILT |
429 | {"none", "zlib"}); |
430 | #else | |
431 | DEFINE_enum(compress_debug_sections, options::TWO_DASHES, '\0', "none", | |
a4d4b13f ILT |
432 | N_("Compress .debug_* sections in the output file"), |
433 | N_("[none]"), | |
ee1fe73e ILT |
434 | {"none"}); |
435 | #endif | |
0dfbdef4 | 436 | |
ee1fe73e | 437 | DEFINE_bool(define_common, options::TWO_DASHES, 'd', false, |
a4d4b13f ILT |
438 | N_("Define common symbols"), |
439 | N_("Do not define common symbols")); | |
ee1fe73e | 440 | DEFINE_bool(dc, options::ONE_DASH, '\0', false, |
a4d4b13f | 441 | N_("Alias for -d"), NULL); |
ee1fe73e | 442 | DEFINE_bool(dp, options::ONE_DASH, '\0', false, |
a4d4b13f | 443 | N_("Alias for -d"), NULL); |
d391083d | 444 | |
ee1fe73e | 445 | DEFINE_special(defsym, options::TWO_DASHES, '\0', |
a4d4b13f | 446 | N_("Define a symbol"), N_("SYMBOL=EXPRESSION")); |
a6badf5a | 447 | |
ee1fe73e ILT |
448 | DEFINE_bool(demangle, options::TWO_DASHES, '\0', |
449 | getenv("COLLECT_NO_DEMANGLE") == NULL, | |
a4d4b13f ILT |
450 | N_("Demangle C++ symbols in log messages"), |
451 | N_("Do not demangle C++ symbols in log messages")); | |
fced7afd | 452 | |
ee1fe73e | 453 | DEFINE_bool(detect_odr_violations, options::TWO_DASHES, '\0', false, |
a4d4b13f | 454 | N_("Try to detect violations of the One Definition Rule"), |
ee1fe73e ILT |
455 | NULL); |
456 | ||
457 | DEFINE_string(entry, options::TWO_DASHES, 'e', NULL, | |
a4d4b13f | 458 | N_("Set program start address"), N_("ADDRESS")); |
ee1fe73e ILT |
459 | |
460 | DEFINE_bool(export_dynamic, options::TWO_DASHES, 'E', false, | |
a4d4b13f | 461 | N_("Export all dynamic symbols"), NULL); |
dbe717ef | 462 | |
ee1fe73e | 463 | DEFINE_bool(eh_frame_hdr, options::TWO_DASHES, '\0', false, |
a4d4b13f | 464 | N_("Create exception frame header"), NULL); |
ee1fe73e ILT |
465 | |
466 | DEFINE_string(soname, options::ONE_DASH, 'h', NULL, | |
a4d4b13f | 467 | N_("Set shared library name"), N_("FILENAME")); |
ee1fe73e | 468 | |
13670ee6 | 469 | DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "sysv", |
a4d4b13f | 470 | N_("Dynamic hash style"), N_("[sysv,gnu,both]"), |
13670ee6 ILT |
471 | {"sysv", "gnu", "both"}); |
472 | ||
ee1fe73e | 473 | DEFINE_string(dynamic_linker, options::TWO_DASHES, 'I', NULL, |
a4d4b13f | 474 | N_("Set dynamic linker path"), N_("PROGRAM")); |
ee1fe73e ILT |
475 | |
476 | DEFINE_special(library, options::TWO_DASHES, 'l', | |
a4d4b13f | 477 | N_("Search for library LIBNAME"), N_("LIBNAME")); |
bae7f79e | 478 | |
ee1fe73e | 479 | DEFINE_dirlist(library_path, options::TWO_DASHES, 'L', |
a4d4b13f | 480 | N_("Add directory to search path"), N_("DIR")); |
ee1fe73e ILT |
481 | |
482 | DEFINE_string(m, options::EXACTLY_ONE_DASH, 'm', "", | |
a4d4b13f | 483 | N_("Ignored for compatibility"), N_("EMULATION")); |
ee1fe73e ILT |
484 | |
485 | DEFINE_string(output, options::TWO_DASHES, 'o', "a.out", | |
a4d4b13f | 486 | N_("Set output file name"), N_("FILE")); |
ee1fe73e ILT |
487 | |
488 | DEFINE_uint(optimize, options::EXACTLY_ONE_DASH, 'O', 0, | |
a4d4b13f | 489 | N_("Optimize output file size"), N_("LEVEL")); |
ee1fe73e | 490 | |
a4d4b13f ILT |
491 | DEFINE_string(oformat, options::EXACTLY_TWO_DASHES, '\0', "elf", |
492 | N_("Set output format"), N_("[binary]")); | |
ee1fe73e ILT |
493 | |
494 | DEFINE_bool(emit_relocs, options::TWO_DASHES, 'q', false, | |
a4d4b13f | 495 | N_("Generate relocations in output"), NULL); |
ee1fe73e ILT |
496 | |
497 | DEFINE_bool(relocatable, options::EXACTLY_ONE_DASH, 'r', false, | |
a4d4b13f | 498 | N_("Generate relocatable output"), NULL); |
ee1fe73e ILT |
499 | |
500 | // -R really means -rpath, but can mean --just-symbols for | |
501 | // compatibility with GNU ld. -rpath is always -rpath, so we list | |
502 | // it separately. | |
503 | DEFINE_special(R, options::EXACTLY_ONE_DASH, 'R', | |
a4d4b13f | 504 | N_("Add DIR to runtime search path"), N_("DIR")); |
ee1fe73e ILT |
505 | |
506 | DEFINE_dirlist(rpath, options::ONE_DASH, '\0', | |
a4d4b13f | 507 | N_("Add DIR to runtime search path"), N_("DIR")); |
ee1fe73e ILT |
508 | |
509 | DEFINE_special(just_symbols, options::TWO_DASHES, '\0', | |
a4d4b13f | 510 | N_("Read only symbol values from FILE"), N_("FILE")); |
ee1fe73e ILT |
511 | |
512 | DEFINE_dirlist(rpath_link, options::TWO_DASHES, '\0', | |
a4d4b13f ILT |
513 | N_("Add DIR to link time shared library search path"), |
514 | N_("DIR")); | |
ee1fe73e ILT |
515 | |
516 | DEFINE_bool(strip_all, options::TWO_DASHES, 's', false, | |
a4d4b13f | 517 | N_("Strip all symbols"), NULL); |
ee1fe73e | 518 | DEFINE_bool(strip_debug_gdb, options::TWO_DASHES, '\0', false, |
a4d4b13f | 519 | N_("Strip debug symbols that are unused by gdb " |
ee1fe73e ILT |
520 | "(at least versions <= 6.7)"), NULL); |
521 | DEFINE_bool(strip_debug, options::TWO_DASHES, 'S', false, | |
a4d4b13f | 522 | N_("Strip debugging information"), NULL); |
ee1fe73e ILT |
523 | |
524 | DEFINE_bool(shared, options::ONE_DASH, '\0', false, | |
a4d4b13f | 525 | N_("Generate shared library"), NULL); |
ee1fe73e ILT |
526 | |
527 | // This is not actually special in any way, but I need to give it | |
528 | // a non-standard accessor-function name because 'static' is a keyword. | |
529 | DEFINE_special(static, options::ONE_DASH, '\0', | |
a4d4b13f | 530 | N_("Do not link against shared libraries"), NULL); |
ee1fe73e ILT |
531 | |
532 | DEFINE_bool(stats, options::TWO_DASHES, '\0', false, | |
a4d4b13f | 533 | N_("Print resource usage statistics"), NULL); |
ee1fe73e ILT |
534 | |
535 | DEFINE_string(sysroot, options::TWO_DASHES, '\0', "", | |
a4d4b13f | 536 | N_("Set target system root directory"), N_("DIR")); |
ee1fe73e ILT |
537 | |
538 | DEFINE_uint64(Tbss, options::ONE_DASH, '\0', -1U, | |
a4d4b13f | 539 | N_("Set the address of the bss segment"), N_("ADDRESS")); |
ee1fe73e | 540 | DEFINE_uint64(Tdata, options::ONE_DASH, '\0', -1U, |
a4d4b13f | 541 | N_("Set the address of the data segment"), N_("ADDRESS")); |
ee1fe73e | 542 | DEFINE_uint64(Ttext, options::ONE_DASH, '\0', -1U, |
a4d4b13f | 543 | N_("Set the address of the text segment"), N_("ADDRESS")); |
ee1fe73e ILT |
544 | |
545 | DEFINE_special(script, options::TWO_DASHES, 'T', | |
a4d4b13f | 546 | N_("Read linker script"), N_("FILE")); |
ee1fe73e | 547 | DEFINE_special(version_script, options::TWO_DASHES, '\0', |
a4d4b13f | 548 | N_("Read version script"), N_("FILE")); |
ee1fe73e ILT |
549 | |
550 | DEFINE_bool(threads, options::TWO_DASHES, '\0', false, | |
a4d4b13f ILT |
551 | N_("Run the linker multi-threaded"), |
552 | N_("Do not run the linker multi-threaded")); | |
ee1fe73e | 553 | DEFINE_uint(thread_count, options::TWO_DASHES, '\0', 0, |
a4d4b13f | 554 | N_("Number of threads to use"), N_("COUNT")); |
ee1fe73e | 555 | DEFINE_uint(thread_count_initial, options::TWO_DASHES, '\0', 0, |
a4d4b13f | 556 | N_("Number of threads to use in initial pass"), N_("COUNT")); |
ee1fe73e | 557 | DEFINE_uint(thread_count_middle, options::TWO_DASHES, '\0', 0, |
a4d4b13f | 558 | N_("Number of threads to use in middle pass"), N_("COUNT")); |
ee1fe73e | 559 | DEFINE_uint(thread_count_final, options::TWO_DASHES, '\0', 0, |
a4d4b13f | 560 | N_("Number of threads to use in final pass"), N_("COUNT")); |
ee1fe73e ILT |
561 | |
562 | DEFINE_bool(whole_archive, options::TWO_DASHES, '\0', false, | |
a4d4b13f ILT |
563 | N_("Include all archive contents"), |
564 | N_("Include only needed archive contents")); | |
ee1fe73e ILT |
565 | |
566 | DEFINE_special(start_group, options::TWO_DASHES, '(', | |
a4d4b13f | 567 | N_("Start a library search group"), NULL); |
ee1fe73e | 568 | DEFINE_special(end_group, options::TWO_DASHES, ')', |
a4d4b13f | 569 | N_("End a library search group"), NULL); |
ee1fe73e ILT |
570 | |
571 | DEFINE_string(debug, options::TWO_DASHES, '\0', "", | |
a4d4b13f | 572 | N_("Turn on debugging"), N_("[task,script,all][,...]")); |
ee1fe73e ILT |
573 | |
574 | // The -z flags. | |
575 | ||
576 | // Both execstack and noexecstack differ from the default execstack_ | |
577 | // value, so we need to use different variables for them. | |
578 | DEFINE_bool(execstack, options::DASH_Z, '\0', false, | |
a4d4b13f | 579 | N_("Mark output as requiring executable stack"), NULL); |
ee1fe73e | 580 | DEFINE_bool(noexecstack, options::DASH_Z, '\0', false, |
a4d4b13f | 581 | N_("Mark output as not requiring executable stack"), NULL); |
ee1fe73e | 582 | DEFINE_uint64(max_page_size, options::DASH_Z, '\0', 0, |
a4d4b13f | 583 | N_("Set maximum page size to SIZE"), N_("SIZE")); |
ee1fe73e | 584 | DEFINE_uint64(common_page_size, options::DASH_Z, '\0', 0, |
a4d4b13f | 585 | N_("Set common page size to SIZE"), N_("SIZE")); |
bae7f79e | 586 | |
ee1fe73e ILT |
587 | public: |
588 | typedef options::Dir_list Dir_list; | |
ca3a67a5 | 589 | |
ee1fe73e | 590 | General_options(); |
61ba1cf9 | 591 | |
ee1fe73e ILT |
592 | // Does post-processing on flags, making sure they all have |
593 | // non-conflicting values. Also converts some flags from their | |
594 | // "standard" types (string, etc), to another type (enum, DirList), | |
595 | // which can be accessed via a separate method. Dies if it notices | |
596 | // any problems. | |
597 | void finalize(); | |
516cb3d0 | 598 | |
ee1fe73e ILT |
599 | // The macro defines output() (based on --output), but that's a |
600 | // generic name. Provide this alternative name, which is clearer. | |
8851ecca | 601 | const char* |
ee1fe73e ILT |
602 | output_file_name() const |
603 | { return this->output(); } | |
92e059d8 | 604 | |
8851ecca ILT |
605 | // This is not defined via a flag, but combines flags to say whether |
606 | // the output is position-independent or not. | |
607 | bool | |
608 | output_is_position_independent() const | |
609 | { return this->shared(); } | |
610 | ||
ee1fe73e ILT |
611 | // This would normally be static(), and defined automatically, but |
612 | // since static is a keyword, we need to come up with our own name. | |
bae7f79e ILT |
613 | bool |
614 | is_static() const | |
ee1fe73e | 615 | { return static_; } |
756ac4a8 | 616 | |
ee1fe73e ILT |
617 | // In addition to getting the input and output formats as a string |
618 | // (via format() and oformat()), we also give access as an enum. | |
619 | enum Object_format | |
620 | { | |
621 | // Ordinary ELF. | |
622 | OBJECT_FORMAT_ELF, | |
623 | // Straight binary format. | |
624 | OBJECT_FORMAT_BINARY | |
625 | }; | |
fe9a4c12 | 626 | |
ee1fe73e ILT |
627 | // Note: these functions are not very fast. |
628 | Object_format format_enum() const; | |
629 | Object_format oformat_enum() const; | |
fe9a4c12 | 630 | |
ee1fe73e ILT |
631 | // These are the best way to get access to the execstack state, |
632 | // not execstack() and noexecstack() which are hard to use properly. | |
35cdfc9a ILT |
633 | bool |
634 | is_execstack_set() const | |
ee1fe73e | 635 | { return this->execstack_status_ != EXECSTACK_FROM_INPUT; } |
35cdfc9a ILT |
636 | |
637 | bool | |
638 | is_stack_executable() const | |
ee1fe73e | 639 | { return this->execstack_status_ == EXECSTACK_YES; } |
c7912668 | 640 | |
bae7f79e | 641 | private: |
dbe717ef ILT |
642 | // Don't copy this structure. |
643 | General_options(const General_options&); | |
644 | General_options& operator=(const General_options&); | |
645 | ||
35cdfc9a ILT |
646 | // Whether to mark the stack as executable. |
647 | enum Execstack | |
648 | { | |
649 | // Not set on command line. | |
650 | EXECSTACK_FROM_INPUT, | |
ee1fe73e | 651 | // Mark the stack as executable (-z execstack). |
35cdfc9a | 652 | EXECSTACK_YES, |
ee1fe73e | 653 | // Mark the stack as not executable (-z noexecstack). |
35cdfc9a ILT |
654 | EXECSTACK_NO |
655 | }; | |
656 | ||
ee1fe73e | 657 | Execstack execstack_status_; |
92e059d8 | 658 | void |
ee1fe73e ILT |
659 | set_execstack_status(Execstack value) |
660 | { execstack_status_ = value; } | |
92e059d8 | 661 | |
ee1fe73e | 662 | bool static_; |
bae7f79e | 663 | void |
45aa233b | 664 | set_static(bool value) |
ee1fe73e | 665 | { static_ = value; } |
652ec9bd | 666 | |
ee1fe73e | 667 | // These are called by finalize() to set up the search-path correctly. |
35cdfc9a | 668 | void |
ee1fe73e ILT |
669 | add_to_library_path_with_sysroot(const char* arg) |
670 | { this->add_search_directory_to_library_path(Search_directory(arg, true)); } | |
c7912668 | 671 | |
ad2d6943 ILT |
672 | // Apply any sysroot to the directory lists. |
673 | void | |
674 | add_sysroot(); | |
bae7f79e ILT |
675 | }; |
676 | ||
ee1fe73e ILT |
677 | // The position-dependent options. We use this to store the state of |
678 | // the commandline at a particular point in parsing for later | |
679 | // reference. For instance, if we see "ld --whole-archive foo.a | |
680 | // --no-whole-archive," we want to store the whole-archive option with | |
681 | // foo.a, so when the time comes to parse foo.a we know we should do | |
682 | // it in whole-archive mode. We could store all of General_options, | |
683 | // but that's big, so we just pick the subset of flags that actually | |
684 | // change in a position-dependent way. | |
685 | ||
686 | #define DEFINE_posdep(varname__, type__) \ | |
687 | public: \ | |
688 | type__ \ | |
689 | varname__() const \ | |
690 | { return this->varname__##_; } \ | |
691 | \ | |
692 | void \ | |
693 | set_##varname__(type__ value) \ | |
694 | { this->varname__##_ = value; } \ | |
695 | private: \ | |
696 | type__ varname__##_ | |
bae7f79e ILT |
697 | |
698 | class Position_dependent_options | |
699 | { | |
700 | public: | |
ee1fe73e ILT |
701 | Position_dependent_options(const General_options& options |
702 | = Position_dependent_options::default_options_) | |
703 | { copy_from_options(options); } | |
bae7f79e | 704 | |
ee1fe73e ILT |
705 | void copy_from_options(const General_options& options) |
706 | { | |
707 | this->set_as_needed(options.as_needed()); | |
708 | this->set_Bdynamic(options.Bdynamic()); | |
709 | this->set_format_enum(options.format_enum()); | |
710 | this->set_whole_archive(options.whole_archive()); | |
711 | } | |
bc644c6c | 712 | |
ee1fe73e ILT |
713 | DEFINE_posdep(as_needed, bool); |
714 | DEFINE_posdep(Bdynamic, bool); | |
715 | DEFINE_posdep(format_enum, General_options::Object_format); | |
716 | DEFINE_posdep(whole_archive, bool); | |
7cc619c3 | 717 | |
dbe717ef | 718 | private: |
ee1fe73e ILT |
719 | // This is a General_options with everything set to its default |
720 | // value. A Position_dependent_options created with no argument | |
721 | // will take its values from here. | |
722 | static General_options default_options_; | |
bae7f79e ILT |
723 | }; |
724 | ||
ee1fe73e | 725 | |
bae7f79e ILT |
726 | // A single file or library argument from the command line. |
727 | ||
ead1e424 | 728 | class Input_file_argument |
bae7f79e ILT |
729 | { |
730 | public: | |
51dee2fe ILT |
731 | // name: file name or library name |
732 | // is_lib: true if name is a library name: that is, emits the leading | |
733 | // "lib" and trailing ".so"/".a" from the name | |
734 | // extra_search_path: an extra directory to look for the file, prior | |
735 | // to checking the normal library search path. If this is "", | |
736 | // then no extra directory is added. | |
88dd47ac | 737 | // just_symbols: whether this file only defines symbols. |
51dee2fe | 738 | // options: The position dependent options at this point in the |
ad2d6943 | 739 | // command line, such as --whole-archive. |
ead1e424 | 740 | Input_file_argument() |
88dd47ac ILT |
741 | : name_(), is_lib_(false), extra_search_path_(""), just_symbols_(false), |
742 | options_() | |
ead1e424 ILT |
743 | { } |
744 | ||
745 | Input_file_argument(const char* name, bool is_lib, | |
51dee2fe | 746 | const char* extra_search_path, |
ee1fe73e ILT |
747 | bool just_symbols, |
748 | const Position_dependent_options& options) | |
749 | : name_(name), is_lib_(is_lib), extra_search_path_(extra_search_path), | |
750 | just_symbols_(just_symbols), options_(options) | |
751 | { } | |
752 | ||
753 | // You can also pass in a General_options instance instead of a | |
754 | // Position_dependent_options. In that case, we extract the | |
755 | // position-independent vars from the General_options and only store | |
756 | // those. | |
757 | Input_file_argument(const char* name, bool is_lib, | |
758 | const char* extra_search_path, | |
759 | bool just_symbols, | |
760 | const General_options& options) | |
51dee2fe | 761 | : name_(name), is_lib_(is_lib), extra_search_path_(extra_search_path), |
88dd47ac | 762 | just_symbols_(just_symbols), options_(options) |
bae7f79e ILT |
763 | { } |
764 | ||
765 | const char* | |
766 | name() const | |
dbe717ef | 767 | { return this->name_.c_str(); } |
bae7f79e ILT |
768 | |
769 | const Position_dependent_options& | |
770 | options() const | |
771 | { return this->options_; } | |
772 | ||
773 | bool | |
774 | is_lib() const | |
61ba1cf9 | 775 | { return this->is_lib_; } |
bae7f79e | 776 | |
51dee2fe ILT |
777 | const char* |
778 | extra_search_path() const | |
779 | { | |
780 | return (this->extra_search_path_.empty() | |
781 | ? NULL | |
ee1fe73e | 782 | : this->extra_search_path_.c_str()); |
51dee2fe ILT |
783 | } |
784 | ||
88dd47ac ILT |
785 | // Return whether we should only read symbols from this file. |
786 | bool | |
787 | just_symbols() const | |
788 | { return this->just_symbols_; } | |
789 | ||
51dee2fe ILT |
790 | // Return whether this file may require a search using the -L |
791 | // options. | |
792 | bool | |
793 | may_need_search() const | |
794 | { return this->is_lib_ || !this->extra_search_path_.empty(); } | |
795 | ||
bae7f79e | 796 | private: |
dbe717ef ILT |
797 | // We use std::string, not const char*, here for convenience when |
798 | // using script files, so that we do not have to preserve the string | |
799 | // in that case. | |
800 | std::string name_; | |
61ba1cf9 | 801 | bool is_lib_; |
51dee2fe | 802 | std::string extra_search_path_; |
88dd47ac | 803 | bool just_symbols_; |
bae7f79e ILT |
804 | Position_dependent_options options_; |
805 | }; | |
806 | ||
ead1e424 ILT |
807 | // A file or library, or a group, from the command line. |
808 | ||
809 | class Input_argument | |
810 | { | |
811 | public: | |
812 | // Create a file or library argument. | |
813 | explicit Input_argument(Input_file_argument file) | |
814 | : is_file_(true), file_(file), group_(NULL) | |
815 | { } | |
816 | ||
817 | // Create a group argument. | |
818 | explicit Input_argument(Input_file_group* group) | |
819 | : is_file_(false), group_(group) | |
820 | { } | |
821 | ||
822 | // Return whether this is a file. | |
823 | bool | |
824 | is_file() const | |
825 | { return this->is_file_; } | |
826 | ||
827 | // Return whether this is a group. | |
828 | bool | |
829 | is_group() const | |
830 | { return !this->is_file_; } | |
831 | ||
832 | // Return the information about the file. | |
833 | const Input_file_argument& | |
834 | file() const | |
835 | { | |
a3ad94ed | 836 | gold_assert(this->is_file_); |
ead1e424 ILT |
837 | return this->file_; |
838 | } | |
839 | ||
840 | // Return the information about the group. | |
841 | const Input_file_group* | |
842 | group() const | |
843 | { | |
a3ad94ed | 844 | gold_assert(!this->is_file_); |
ead1e424 ILT |
845 | return this->group_; |
846 | } | |
847 | ||
848 | Input_file_group* | |
849 | group() | |
850 | { | |
a3ad94ed | 851 | gold_assert(!this->is_file_); |
ead1e424 ILT |
852 | return this->group_; |
853 | } | |
854 | ||
855 | private: | |
856 | bool is_file_; | |
857 | Input_file_argument file_; | |
858 | Input_file_group* group_; | |
859 | }; | |
860 | ||
861 | // A group from the command line. This is a set of arguments within | |
862 | // --start-group ... --end-group. | |
863 | ||
864 | class Input_file_group | |
92e059d8 | 865 | { |
ead1e424 ILT |
866 | public: |
867 | typedef std::vector<Input_argument> Files; | |
868 | typedef Files::const_iterator const_iterator; | |
869 | ||
870 | Input_file_group() | |
871 | : files_() | |
872 | { } | |
873 | ||
874 | // Add a file to the end of the group. | |
875 | void | |
876 | add_file(const Input_file_argument& arg) | |
877 | { this->files_.push_back(Input_argument(arg)); } | |
878 | ||
879 | // Iterators to iterate over the group contents. | |
880 | ||
881 | const_iterator | |
882 | begin() const | |
883 | { return this->files_.begin(); } | |
884 | ||
885 | const_iterator | |
886 | end() const | |
887 | { return this->files_.end(); } | |
888 | ||
889 | private: | |
890 | Files files_; | |
92e059d8 ILT |
891 | }; |
892 | ||
dbe717ef ILT |
893 | // A list of files from the command line or a script. |
894 | ||
895 | class Input_arguments | |
896 | { | |
897 | public: | |
898 | typedef std::vector<Input_argument> Input_argument_list; | |
899 | typedef Input_argument_list::const_iterator const_iterator; | |
900 | ||
901 | Input_arguments() | |
902 | : input_argument_list_(), in_group_(false) | |
903 | { } | |
904 | ||
905 | // Add a file. | |
906 | void | |
907 | add_file(const Input_file_argument& arg); | |
908 | ||
909 | // Start a group (the --start-group option). | |
910 | void | |
911 | start_group(); | |
912 | ||
913 | // End a group (the --end-group option). | |
914 | void | |
915 | end_group(); | |
916 | ||
917 | // Return whether we are currently in a group. | |
918 | bool | |
919 | in_group() const | |
920 | { return this->in_group_; } | |
921 | ||
fe9a4c12 ILT |
922 | // The number of entries in the list. |
923 | int | |
924 | size() const | |
925 | { return this->input_argument_list_.size(); } | |
926 | ||
dbe717ef ILT |
927 | // Iterators to iterate over the list of input files. |
928 | ||
929 | const_iterator | |
930 | begin() const | |
931 | { return this->input_argument_list_.begin(); } | |
932 | ||
933 | const_iterator | |
934 | end() const | |
935 | { return this->input_argument_list_.end(); } | |
936 | ||
937 | // Return whether the list is empty. | |
938 | bool | |
939 | empty() const | |
940 | { return this->input_argument_list_.empty(); } | |
941 | ||
942 | private: | |
943 | Input_argument_list input_argument_list_; | |
944 | bool in_group_; | |
945 | }; | |
946 | ||
ee1fe73e ILT |
947 | |
948 | // All the information read from the command line. These are held in | |
949 | // three separate structs: one to hold the options (--foo), one to | |
950 | // hold the filenames listed on the commandline, and one to hold | |
951 | // linker script information. This third is not a subset of the other | |
952 | // two because linker scripts can be specified either as options (via | |
953 | // -T) or as a file. | |
bae7f79e ILT |
954 | |
955 | class Command_line | |
956 | { | |
957 | public: | |
ead1e424 ILT |
958 | typedef Input_arguments::const_iterator const_iterator; |
959 | ||
a5dc0706 | 960 | Command_line(); |
bae7f79e ILT |
961 | |
962 | // Process the command line options. This will exit with an | |
963 | // appropriate error message if an unrecognized option is seen. | |
964 | void | |
ee1fe73e | 965 | process(int argc, const char** argv); |
bae7f79e | 966 | |
a0451b38 | 967 | // Process one command-line option. This takes the index of argv to |
ee1fe73e ILT |
968 | // process, and returns the index for the next option. no_more_options |
969 | // is set to true if argv[i] is "--". | |
61ba1cf9 | 970 | int |
ee1fe73e ILT |
971 | process_one_option(int argc, const char** argv, int i, |
972 | bool* no_more_options); | |
3c2fafa5 | 973 | |
61ba1cf9 | 974 | // Get the general options. |
bae7f79e ILT |
975 | const General_options& |
976 | options() const | |
977 | { return this->options_; } | |
978 | ||
3c2fafa5 ILT |
979 | // Get the position dependent options. |
980 | const Position_dependent_options& | |
981 | position_dependent_options() const | |
982 | { return this->position_options_; } | |
983 | ||
a5dc0706 ILT |
984 | // Get the linker-script options. |
985 | Script_options& | |
e5756efb | 986 | script_options() |
a5dc0706 | 987 | { return this->script_options_; } |
e5756efb | 988 | |
a5dc0706 ILT |
989 | // Get the version-script options: a convenience routine. |
990 | const Version_script_info& | |
991 | version_script() const | |
992 | { return *this->script_options_.version_script_info(); } | |
e5756efb | 993 | |
ee1fe73e ILT |
994 | // Get the input files. |
995 | Input_arguments& | |
996 | inputs() | |
997 | { return this->inputs_; } | |
998 | ||
fe9a4c12 ILT |
999 | // The number of input files. |
1000 | int | |
1001 | number_of_input_files() const | |
1002 | { return this->inputs_.size(); } | |
1003 | ||
ead1e424 ILT |
1004 | // Iterators to iterate over the list of input files. |
1005 | ||
1006 | const_iterator | |
1007 | begin() const | |
1008 | { return this->inputs_.begin(); } | |
1009 | ||
1010 | const_iterator | |
1011 | end() const | |
1012 | { return this->inputs_.end(); } | |
bae7f79e ILT |
1013 | |
1014 | private: | |
ead1e424 ILT |
1015 | Command_line(const Command_line&); |
1016 | Command_line& operator=(const Command_line&); | |
1017 | ||
bae7f79e ILT |
1018 | General_options options_; |
1019 | Position_dependent_options position_options_; | |
a5dc0706 | 1020 | Script_options script_options_; |
ead1e424 | 1021 | Input_arguments inputs_; |
bae7f79e ILT |
1022 | }; |
1023 | ||
1024 | } // End namespace gold. | |
1025 | ||
1026 | #endif // !defined(GOLD_OPTIONS_H) |