xref: /dflybsd-src/contrib/binutils-2.34/gold/options.h (revision b52ef7118d1621abed722c5bbbd542210290ecef)
1*fae548d3Szrj // options.h -- handle command line options for gold  -*- C++ -*-
2*fae548d3Szrj 
3*fae548d3Szrj // Copyright (C) 2006-2020 Free Software Foundation, Inc.
4*fae548d3Szrj // Written by Ian Lance Taylor <iant@google.com>.
5*fae548d3Szrj 
6*fae548d3Szrj // This file is part of gold.
7*fae548d3Szrj 
8*fae548d3Szrj // This program is free software; you can redistribute it and/or modify
9*fae548d3Szrj // it under the terms of the GNU General Public License as published by
10*fae548d3Szrj // the Free Software Foundation; either version 3 of the License, or
11*fae548d3Szrj // (at your option) any later version.
12*fae548d3Szrj 
13*fae548d3Szrj // This program is distributed in the hope that it will be useful,
14*fae548d3Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
15*fae548d3Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*fae548d3Szrj // GNU General Public License for more details.
17*fae548d3Szrj 
18*fae548d3Szrj // You should have received a copy of the GNU General Public License
19*fae548d3Szrj // along with this program; if not, write to the Free Software
20*fae548d3Szrj // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21*fae548d3Szrj // MA 02110-1301, USA.
22*fae548d3Szrj 
23*fae548d3Szrj // General_options (from Command_line::options())
24*fae548d3Szrj //   All the options (a.k.a. command-line flags)
25*fae548d3Szrj // Input_argument (from Command_line::inputs())
26*fae548d3Szrj //   The list of input files, including -l options.
27*fae548d3Szrj // Command_line
28*fae548d3Szrj //   Everything we get from the command line -- the General_options
29*fae548d3Szrj //   plus the Input_arguments.
30*fae548d3Szrj //
31*fae548d3Szrj // There are also some smaller classes, such as
32*fae548d3Szrj // Position_dependent_options which hold a subset of General_options
33*fae548d3Szrj // that change as options are parsed (as opposed to the usual behavior
34*fae548d3Szrj // of the last instance of that option specified on the commandline wins).
35*fae548d3Szrj 
36*fae548d3Szrj #ifndef GOLD_OPTIONS_H
37*fae548d3Szrj #define GOLD_OPTIONS_H
38*fae548d3Szrj 
39*fae548d3Szrj #include <cstdlib>
40*fae548d3Szrj #include <cstring>
41*fae548d3Szrj #include <list>
42*fae548d3Szrj #include <map>
43*fae548d3Szrj #include <string>
44*fae548d3Szrj #include <vector>
45*fae548d3Szrj 
46*fae548d3Szrj #include "elfcpp.h"
47*fae548d3Szrj #include "script.h"
48*fae548d3Szrj 
49*fae548d3Szrj namespace gold
50*fae548d3Szrj {
51*fae548d3Szrj 
52*fae548d3Szrj class Command_line;
53*fae548d3Szrj class General_options;
54*fae548d3Szrj class Search_directory;
55*fae548d3Szrj class Input_file_group;
56*fae548d3Szrj class Input_file_lib;
57*fae548d3Szrj class Position_dependent_options;
58*fae548d3Szrj class Target;
59*fae548d3Szrj class Plugin_manager;
60*fae548d3Szrj class Script_info;
61*fae548d3Szrj 
62*fae548d3Szrj // Incremental build action for a specific file, as selected by the user.
63*fae548d3Szrj 
64*fae548d3Szrj enum Incremental_disposition
65*fae548d3Szrj {
66*fae548d3Szrj   // Startup files that appear before the first disposition option.
67*fae548d3Szrj   // These will default to INCREMENTAL_CHECK unless the
68*fae548d3Szrj   // --incremental-startup-unchanged option is given.
69*fae548d3Szrj   // (For files added implicitly by gcc before any user options.)
70*fae548d3Szrj   INCREMENTAL_STARTUP,
71*fae548d3Szrj   // Determine the status from the timestamp (default).
72*fae548d3Szrj   INCREMENTAL_CHECK,
73*fae548d3Szrj   // Assume the file changed from the previous build.
74*fae548d3Szrj   INCREMENTAL_CHANGED,
75*fae548d3Szrj   // Assume the file didn't change from the previous build.
76*fae548d3Szrj   INCREMENTAL_UNCHANGED
77*fae548d3Szrj };
78*fae548d3Szrj 
79*fae548d3Szrj // The nested namespace is to contain all the global variables and
80*fae548d3Szrj // structs that need to be defined in the .h file, but do not need to
81*fae548d3Szrj // be used outside this class.
82*fae548d3Szrj namespace options
83*fae548d3Szrj {
84*fae548d3Szrj typedef std::vector<Search_directory> Dir_list;
85*fae548d3Szrj typedef Unordered_set<std::string> String_set;
86*fae548d3Szrj 
87*fae548d3Szrj // These routines convert from a string option to various types.
88*fae548d3Szrj // Each gives a fatal error if it cannot parse the argument.
89*fae548d3Szrj 
90*fae548d3Szrj extern void
91*fae548d3Szrj parse_bool(const char* option_name, const char* arg, bool* retval);
92*fae548d3Szrj 
93*fae548d3Szrj extern void
94*fae548d3Szrj parse_int(const char* option_name, const char* arg, int* retval);
95*fae548d3Szrj 
96*fae548d3Szrj extern void
97*fae548d3Szrj parse_uint(const char* option_name, const char* arg, int* retval);
98*fae548d3Szrj 
99*fae548d3Szrj extern void
100*fae548d3Szrj parse_uint64(const char* option_name, const char* arg, uint64_t* retval);
101*fae548d3Szrj 
102*fae548d3Szrj extern void
103*fae548d3Szrj parse_double(const char* option_name, const char* arg, double* retval);
104*fae548d3Szrj 
105*fae548d3Szrj extern void
106*fae548d3Szrj parse_percent(const char* option_name, const char* arg, double* retval);
107*fae548d3Szrj 
108*fae548d3Szrj extern void
109*fae548d3Szrj parse_string(const char* option_name, const char* arg, const char** retval);
110*fae548d3Szrj 
111*fae548d3Szrj extern void
112*fae548d3Szrj parse_optional_string(const char* option_name, const char* arg,
113*fae548d3Szrj 		      const char** retval);
114*fae548d3Szrj 
115*fae548d3Szrj extern void
116*fae548d3Szrj parse_dirlist(const char* option_name, const char* arg, Dir_list* retval);
117*fae548d3Szrj 
118*fae548d3Szrj extern void
119*fae548d3Szrj parse_set(const char* option_name, const char* arg, String_set* retval);
120*fae548d3Szrj 
121*fae548d3Szrj extern void
122*fae548d3Szrj parse_choices(const char* option_name, const char* arg, const char** retval,
123*fae548d3Szrj 	      const char* choices[], int num_choices);
124*fae548d3Szrj 
125*fae548d3Szrj struct Struct_var;
126*fae548d3Szrj 
127*fae548d3Szrj // Most options have both a shortname (one letter) and a longname.
128*fae548d3Szrj // This enum controls how many dashes are expected for longname access
129*fae548d3Szrj // -- shortnames always use one dash.  Most longnames will accept
130*fae548d3Szrj // either one dash or two; the only difference between ONE_DASH and
131*fae548d3Szrj // TWO_DASHES is how we print the option in --help.  However, some
132*fae548d3Szrj // longnames require two dashes, and some require only one.  The
133*fae548d3Szrj // special value DASH_Z means that the option is preceded by "-z".
134*fae548d3Szrj enum Dashes
135*fae548d3Szrj {
136*fae548d3Szrj   ONE_DASH, TWO_DASHES, EXACTLY_ONE_DASH, EXACTLY_TWO_DASHES, DASH_Z
137*fae548d3Szrj };
138*fae548d3Szrj 
139*fae548d3Szrj // LONGNAME is the long-name of the option with dashes converted to
140*fae548d3Szrj //    underscores, or else the short-name if the option has no long-name.
141*fae548d3Szrj //    It is never the empty string.
142*fae548d3Szrj // DASHES is an instance of the Dashes enum: ONE_DASH, TWO_DASHES, etc.
143*fae548d3Szrj // SHORTNAME is the short-name of the option, as a char, or '\0' if the
144*fae548d3Szrj //    option has no short-name.  If the option has no long-name, you
145*fae548d3Szrj //    should specify the short-name in *both* VARNAME and here.
146*fae548d3Szrj // DEFAULT_VALUE is the value of the option if not specified on the
147*fae548d3Szrj //    commandline, as a string.
148*fae548d3Szrj // HELPSTRING is the descriptive text used with the option via --help
149*fae548d3Szrj // HELPARG is how you define the argument to the option.
150*fae548d3Szrj //    --help output is "-shortname HELPARG, --longname HELPARG: HELPSTRING"
151*fae548d3Szrj //    HELPARG should be NULL iff the option is a bool and takes no arg.
152*fae548d3Szrj // OPTIONAL_ARG is true if this option takes an optional argument.  An
153*fae548d3Szrj //    optional argument must be specifid as --OPTION=VALUE, not
154*fae548d3Szrj //    --OPTION VALUE.
155*fae548d3Szrj // READER provides parse_to_value, which is a function that will convert
156*fae548d3Szrj //    a char* argument into the proper type and store it in some variable.
157*fae548d3Szrj // IS_DEFAULT is true for boolean options that are on by default,
158*fae548d3Szrj //    and thus should have "(default)" printed with the helpstring.
159*fae548d3Szrj // A One_option struct initializes itself with the global list of options
160*fae548d3Szrj // at constructor time, so be careful making one of these.
161*fae548d3Szrj struct One_option
162*fae548d3Szrj {
163*fae548d3Szrj   std::string longname;
164*fae548d3Szrj   Dashes dashes;
165*fae548d3Szrj   char shortname;
166*fae548d3Szrj   const char* default_value;
167*fae548d3Szrj   const char* helpstring;
168*fae548d3Szrj   const char* helparg;
169*fae548d3Szrj   bool optional_arg;
170*fae548d3Szrj   Struct_var* reader;
171*fae548d3Szrj   bool is_default;
172*fae548d3Szrj 
One_optionOne_option173*fae548d3Szrj   One_option(const char* ln, Dashes d, char sn, const char* dv,
174*fae548d3Szrj 	     const char* hs, const char* ha, bool oa, Struct_var* r,
175*fae548d3Szrj 	     bool id)
176*fae548d3Szrj     : longname(ln), dashes(d), shortname(sn), default_value(dv ? dv : ""),
177*fae548d3Szrj       helpstring(hs), helparg(ha), optional_arg(oa), reader(r),
178*fae548d3Szrj       is_default(id)
179*fae548d3Szrj   {
180*fae548d3Szrj     // In longname, we convert all underscores to dashes, since GNU
181*fae548d3Szrj     // style uses dashes in option names.  longname is likely to have
182*fae548d3Szrj     // underscores in it because it's also used to declare a C++
183*fae548d3Szrj     // function.
184*fae548d3Szrj     const char* pos = strchr(this->longname.c_str(), '_');
185*fae548d3Szrj     for (; pos; pos = strchr(pos, '_'))
186*fae548d3Szrj       this->longname[pos - this->longname.c_str()] = '-';
187*fae548d3Szrj 
188*fae548d3Szrj     // We only register ourselves if our helpstring is not NULL.  This
189*fae548d3Szrj     // is to support the "no-VAR" boolean variables, which we
190*fae548d3Szrj     // conditionally turn on by defining "no-VAR" help text.
191*fae548d3Szrj     if (this->helpstring)
192*fae548d3Szrj       this->register_option();
193*fae548d3Szrj   }
194*fae548d3Szrj 
195*fae548d3Szrj   // This option takes an argument iff helparg is not NULL.
196*fae548d3Szrj   bool
takes_argumentOne_option197*fae548d3Szrj   takes_argument() const
198*fae548d3Szrj   { return this->helparg != NULL; }
199*fae548d3Szrj 
200*fae548d3Szrj   // Whether the argument is optional.
201*fae548d3Szrj   bool
takes_optional_argumentOne_option202*fae548d3Szrj   takes_optional_argument() const
203*fae548d3Szrj   { return this->optional_arg; }
204*fae548d3Szrj 
205*fae548d3Szrj   // Register this option with the global list of options.
206*fae548d3Szrj   void
207*fae548d3Szrj   register_option();
208*fae548d3Szrj 
209*fae548d3Szrj   // Print this option to stdout (used with --help).
210*fae548d3Szrj   void
211*fae548d3Szrj   print() const;
212*fae548d3Szrj };
213*fae548d3Szrj 
214*fae548d3Szrj // All options have a Struct_##varname that inherits from this and
215*fae548d3Szrj // actually implements parse_to_value for that option.
216*fae548d3Szrj struct Struct_var
217*fae548d3Szrj {
218*fae548d3Szrj   // OPTION: the name of the option as specified on the commandline,
219*fae548d3Szrj   //    including leading dashes, and any text following the option:
220*fae548d3Szrj   //    "-O", "--defsym=mysym=0x1000", etc.
221*fae548d3Szrj   // ARG: the arg associated with this option, or NULL if the option
222*fae548d3Szrj   //    takes no argument: "2", "mysym=0x1000", etc.
223*fae548d3Szrj   // CMDLINE: the global Command_line object.  Used by DEFINE_special.
224*fae548d3Szrj   // OPTIONS: the global General_options object.  Used by DEFINE_special.
225*fae548d3Szrj   virtual void
226*fae548d3Szrj   parse_to_value(const char* option, const char* arg,
227*fae548d3Szrj 		 Command_line* cmdline, General_options* options) = 0;
228*fae548d3Szrj   virtual
~Struct_varStruct_var229*fae548d3Szrj   ~Struct_var()  // To make gcc happy.
230*fae548d3Szrj   { }
231*fae548d3Szrj };
232*fae548d3Szrj 
233*fae548d3Szrj // This is for "special" options that aren't of any predefined type.
234*fae548d3Szrj struct Struct_special : public Struct_var
235*fae548d3Szrj {
236*fae548d3Szrj   // If you change this, change the parse-fn in DEFINE_special as well.
237*fae548d3Szrj   typedef void (General_options::*Parse_function)(const char*, const char*,
238*fae548d3Szrj 						  Command_line*);
Struct_specialStruct_special239*fae548d3Szrj   Struct_special(const char* varname, Dashes dashes, char shortname,
240*fae548d3Szrj 		 Parse_function parse_function,
241*fae548d3Szrj 		 const char* helpstring, const char* helparg)
242*fae548d3Szrj     : option(varname, dashes, shortname, "", helpstring, helparg, false, this,
243*fae548d3Szrj 	     false),
244*fae548d3Szrj       parse(parse_function)
245*fae548d3Szrj   { }
246*fae548d3Szrj 
parse_to_valueStruct_special247*fae548d3Szrj   void parse_to_value(const char* option, const char* arg,
248*fae548d3Szrj 		      Command_line* cmdline, General_options* options)
249*fae548d3Szrj   { (options->*(this->parse))(option, arg, cmdline); }
250*fae548d3Szrj 
251*fae548d3Szrj   One_option option;
252*fae548d3Szrj   Parse_function parse;
253*fae548d3Szrj };
254*fae548d3Szrj 
255*fae548d3Szrj }  // End namespace options.
256*fae548d3Szrj 
257*fae548d3Szrj 
258*fae548d3Szrj // These are helper macros use by DEFINE_uint64/etc below.
259*fae548d3Szrj // This macro is used inside the General_options_ class, so defines
260*fae548d3Szrj // var() and set_var() as General_options methods.  Arguments as are
261*fae548d3Szrj // for the constructor for One_option.  param_type__ is the same as
262*fae548d3Szrj // type__ for built-in types, and "const type__ &" otherwise.
263*fae548d3Szrj //
264*fae548d3Szrj // When we define the linker command option "assert", the macro argument
265*fae548d3Szrj // varname__ of DEFINE_var below will be replaced by "assert".  On Mac OSX
266*fae548d3Szrj // assert.h is included implicitly by one of the library headers we use.  To
267*fae548d3Szrj // avoid unintended macro substitution of "assert()", we need to enclose
268*fae548d3Szrj // varname__ with parenthese.
269*fae548d3Szrj #define DEFINE_var(varname__, dashes__, shortname__, default_value__,        \
270*fae548d3Szrj 		   default_value_as_string__, helpstring__, helparg__,       \
271*fae548d3Szrj 		   optional_arg__, type__, param_type__, parse_fn__,         \
272*fae548d3Szrj 		   is_default__)					     \
273*fae548d3Szrj  public:                                                                     \
274*fae548d3Szrj   param_type__                                                               \
275*fae548d3Szrj   (varname__)() const                                                        \
276*fae548d3Szrj   { return this->varname__##_.value; }                                       \
277*fae548d3Szrj 									     \
278*fae548d3Szrj   bool                                                                       \
279*fae548d3Szrj   user_set_##varname__() const                                               \
280*fae548d3Szrj   { return this->varname__##_.user_set_via_option; }                         \
281*fae548d3Szrj 									     \
282*fae548d3Szrj   void									     \
283*fae548d3Szrj   set_user_set_##varname__()						     \
284*fae548d3Szrj   { this->varname__##_.user_set_via_option = true; }			     \
285*fae548d3Szrj 									     \
286*fae548d3Szrj   static const bool varname__##is_default = is_default__;		     \
287*fae548d3Szrj 									     \
288*fae548d3Szrj  private:                                                                    \
289*fae548d3Szrj   struct Struct_##varname__ : public options::Struct_var                     \
290*fae548d3Szrj   {                                                                          \
291*fae548d3Szrj     Struct_##varname__()                                                     \
292*fae548d3Szrj       : option(#varname__, dashes__, shortname__, default_value_as_string__, \
293*fae548d3Szrj 	       helpstring__, helparg__, optional_arg__, this, is_default__), \
294*fae548d3Szrj 	user_set_via_option(false), value(default_value__)                   \
295*fae548d3Szrj     { }                                                                      \
296*fae548d3Szrj 									     \
297*fae548d3Szrj     void                                                                     \
298*fae548d3Szrj     parse_to_value(const char* option_name, const char* arg,                 \
299*fae548d3Szrj 		   Command_line*, General_options*)                          \
300*fae548d3Szrj     {                                                                        \
301*fae548d3Szrj       parse_fn__(option_name, arg, &this->value);                            \
302*fae548d3Szrj       this->user_set_via_option = true;                                      \
303*fae548d3Szrj     }                                                                        \
304*fae548d3Szrj 									     \
305*fae548d3Szrj     options::One_option option;                                              \
306*fae548d3Szrj     bool user_set_via_option;                                                \
307*fae548d3Szrj     type__ value;                                                            \
308*fae548d3Szrj   };                                                                         \
309*fae548d3Szrj   Struct_##varname__ varname__##_;                                           \
310*fae548d3Szrj   void                                                                       \
311*fae548d3Szrj   set_##varname__(param_type__ value)                                        \
312*fae548d3Szrj   { this->varname__##_.value = value; }
313*fae548d3Szrj 
314*fae548d3Szrj // These macros allow for easy addition of a new commandline option.
315*fae548d3Szrj 
316*fae548d3Szrj // If no_helpstring__ is not NULL, then in addition to creating
317*fae548d3Szrj // VARNAME, we also create an option called no-VARNAME (or, for a -z
318*fae548d3Szrj // option, noVARNAME).
319*fae548d3Szrj #define DEFINE_bool(varname__, dashes__, shortname__, default_value__,   \
320*fae548d3Szrj 		    helpstring__, no_helpstring__)                       \
321*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, default_value__,          \
322*fae548d3Szrj 	     default_value__ ? "true" : "false", helpstring__, NULL,     \
323*fae548d3Szrj 	     false, bool, bool, options::parse_bool, default_value__)	 \
324*fae548d3Szrj   struct Struct_no_##varname__ : public options::Struct_var              \
325*fae548d3Szrj   {                                                                      \
326*fae548d3Szrj     Struct_no_##varname__() : option((dashes__ == options::DASH_Z	 \
327*fae548d3Szrj 				      ? "no" #varname__			 \
328*fae548d3Szrj 				      : "no-" #varname__),		 \
329*fae548d3Szrj 				     dashes__, '\0',			 \
330*fae548d3Szrj 				     default_value__ ? "false" : "true", \
331*fae548d3Szrj 				     no_helpstring__, NULL, false, this, \
332*fae548d3Szrj 				     !(default_value__))                 \
333*fae548d3Szrj     { }                                                                  \
334*fae548d3Szrj 									 \
335*fae548d3Szrj     void                                                                 \
336*fae548d3Szrj     parse_to_value(const char*, const char*,                             \
337*fae548d3Szrj 		   Command_line*, General_options* options)              \
338*fae548d3Szrj     {                                                                    \
339*fae548d3Szrj       options->set_##varname__(false);                                   \
340*fae548d3Szrj       options->set_user_set_##varname__();                               \
341*fae548d3Szrj     }                                                                    \
342*fae548d3Szrj 									 \
343*fae548d3Szrj     options::One_option option;                                          \
344*fae548d3Szrj   };                                                                     \
345*fae548d3Szrj   Struct_no_##varname__ no_##varname__##_initializer_
346*fae548d3Szrj 
347*fae548d3Szrj #define DEFINE_bool_ignore(varname__, dashes__, shortname__,		 \
348*fae548d3Szrj 		    helpstring__, no_helpstring__)                       \
349*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, false,			 \
350*fae548d3Szrj 	     "false", helpstring__, NULL,				 \
351*fae548d3Szrj 	     false, bool, bool, options::parse_bool, false)		 \
352*fae548d3Szrj   struct Struct_no_##varname__ : public options::Struct_var              \
353*fae548d3Szrj   {                                                                      \
354*fae548d3Szrj     Struct_no_##varname__() : option((dashes__ == options::DASH_Z	 \
355*fae548d3Szrj 				      ? "no" #varname__			 \
356*fae548d3Szrj 				      : "no-" #varname__),		 \
357*fae548d3Szrj 				     dashes__, '\0',			 \
358*fae548d3Szrj 				     "false",				 \
359*fae548d3Szrj 				     no_helpstring__, NULL, false, this, \
360*fae548d3Szrj 				     false)				 \
361*fae548d3Szrj     { }                                                                  \
362*fae548d3Szrj 									 \
363*fae548d3Szrj     void                                                                 \
364*fae548d3Szrj     parse_to_value(const char*, const char*,                             \
365*fae548d3Szrj 		   Command_line*, General_options* options)              \
366*fae548d3Szrj     {                                                                    \
367*fae548d3Szrj       options->set_##varname__(false);                                   \
368*fae548d3Szrj       options->set_user_set_##varname__();                               \
369*fae548d3Szrj     }                                                                    \
370*fae548d3Szrj 									 \
371*fae548d3Szrj     options::One_option option;                                          \
372*fae548d3Szrj   };                                                                     \
373*fae548d3Szrj   Struct_no_##varname__ no_##varname__##_initializer_
374*fae548d3Szrj 
375*fae548d3Szrj #define DEFINE_enable(varname__, dashes__, shortname__, default_value__, \
376*fae548d3Szrj 		      helpstring__, no_helpstring__)                     \
377*fae548d3Szrj   DEFINE_var(enable_##varname__, dashes__, shortname__, default_value__, \
378*fae548d3Szrj 	     default_value__ ? "true" : "false", helpstring__, NULL,     \
379*fae548d3Szrj 	     false, bool, bool, options::parse_bool, default_value__)	 \
380*fae548d3Szrj   struct Struct_disable_##varname__ : public options::Struct_var         \
381*fae548d3Szrj   {                                                                      \
382*fae548d3Szrj     Struct_disable_##varname__() : option("disable-" #varname__,         \
383*fae548d3Szrj 				     dashes__, '\0',                     \
384*fae548d3Szrj 				     default_value__ ? "false" : "true", \
385*fae548d3Szrj 				     no_helpstring__, NULL, false, this, \
386*fae548d3Szrj 				     !default_value__)                   \
387*fae548d3Szrj     { }                                                                  \
388*fae548d3Szrj 									 \
389*fae548d3Szrj     void                                                                 \
390*fae548d3Szrj     parse_to_value(const char*, const char*,                             \
391*fae548d3Szrj 		   Command_line*, General_options* options)              \
392*fae548d3Szrj     { options->set_enable_##varname__(false); }                          \
393*fae548d3Szrj 									 \
394*fae548d3Szrj     options::One_option option;                                          \
395*fae548d3Szrj   };                                                                     \
396*fae548d3Szrj   Struct_disable_##varname__ disable_##varname__##_initializer_
397*fae548d3Szrj 
398*fae548d3Szrj #define DEFINE_int(varname__, dashes__, shortname__, default_value__,   \
399*fae548d3Szrj 		   helpstring__, helparg__)                             \
400*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, default_value__,         \
401*fae548d3Szrj 	     #default_value__, helpstring__, helparg__, false,		\
402*fae548d3Szrj 	     int, int, options::parse_int, false)
403*fae548d3Szrj 
404*fae548d3Szrj #define DEFINE_uint(varname__, dashes__, shortname__, default_value__,  \
405*fae548d3Szrj 		   helpstring__, helparg__)                             \
406*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, default_value__,         \
407*fae548d3Szrj 	     #default_value__, helpstring__, helparg__, false,		\
408*fae548d3Szrj 	     int, int, options::parse_uint, false)
409*fae548d3Szrj 
410*fae548d3Szrj #define DEFINE_uint64(varname__, dashes__, shortname__, default_value__, \
411*fae548d3Szrj 		      helpstring__, helparg__)                           \
412*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, default_value__,          \
413*fae548d3Szrj 	     #default_value__, helpstring__, helparg__, false,		 \
414*fae548d3Szrj 	     uint64_t, uint64_t, options::parse_uint64, false)
415*fae548d3Szrj 
416*fae548d3Szrj #define DEFINE_double(varname__, dashes__, shortname__, default_value__, \
417*fae548d3Szrj 		      helpstring__, helparg__)				 \
418*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, default_value__,		 \
419*fae548d3Szrj 	     #default_value__, helpstring__, helparg__, false,		 \
420*fae548d3Szrj 	     double, double, options::parse_double, false)
421*fae548d3Szrj 
422*fae548d3Szrj #define DEFINE_percent(varname__, dashes__, shortname__, default_value__, \
423*fae548d3Szrj 		       helpstring__, helparg__)				  \
424*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, default_value__ / 100.0,	  \
425*fae548d3Szrj 	     #default_value__, helpstring__, helparg__, false,		  \
426*fae548d3Szrj 	     double, double, options::parse_percent, false)
427*fae548d3Szrj 
428*fae548d3Szrj #define DEFINE_string(varname__, dashes__, shortname__, default_value__, \
429*fae548d3Szrj 		      helpstring__, helparg__)                           \
430*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, default_value__,          \
431*fae548d3Szrj 	     default_value__, helpstring__, helparg__, false,		 \
432*fae548d3Szrj 	     const char*, const char*, options::parse_string, false)
433*fae548d3Szrj 
434*fae548d3Szrj // This is like DEFINE_string, but we convert each occurrence to a
435*fae548d3Szrj // Search_directory and store it in a vector.  Thus we also have the
436*fae548d3Szrj // add_to_VARNAME() method, to append to the vector.
437*fae548d3Szrj #define DEFINE_dirlist(varname__, dashes__, shortname__,                  \
438*fae548d3Szrj 			   helpstring__, helparg__)                       \
439*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, ,                          \
440*fae548d3Szrj 	     "", helpstring__, helparg__, false, options::Dir_list,	  \
441*fae548d3Szrj 	     const options::Dir_list&, options::parse_dirlist, false)     \
442*fae548d3Szrj   void                                                                    \
443*fae548d3Szrj   add_to_##varname__(const char* new_value)                               \
444*fae548d3Szrj   { options::parse_dirlist(NULL, new_value, &this->varname__##_.value); } \
445*fae548d3Szrj   void                                                                    \
446*fae548d3Szrj   add_search_directory_to_##varname__(const Search_directory& dir)        \
447*fae548d3Szrj   { this->varname__##_.value.push_back(dir); }
448*fae548d3Szrj 
449*fae548d3Szrj // This is like DEFINE_string, but we store a set of strings.
450*fae548d3Szrj #define DEFINE_set(varname__, dashes__, shortname__,                      \
451*fae548d3Szrj 		   helpstring__, helparg__)                               \
452*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, ,                          \
453*fae548d3Szrj 	     "", helpstring__, helparg__, false, options::String_set,     \
454*fae548d3Szrj 	     const options::String_set&, options::parse_set, false)       \
455*fae548d3Szrj  public:                                                                  \
456*fae548d3Szrj   bool                                                                    \
457*fae548d3Szrj   any_##varname__() const                                                 \
458*fae548d3Szrj   { return !this->varname__##_.value.empty(); }                           \
459*fae548d3Szrj 									  \
460*fae548d3Szrj   bool                                                                    \
461*fae548d3Szrj   is_##varname__(const char* symbol) const                                \
462*fae548d3Szrj   {                                                                       \
463*fae548d3Szrj     return (!this->varname__##_.value.empty()                             \
464*fae548d3Szrj 	    && (this->varname__##_.value.find(std::string(symbol))        \
465*fae548d3Szrj 		!= this->varname__##_.value.end()));                      \
466*fae548d3Szrj   }									  \
467*fae548d3Szrj 									  \
468*fae548d3Szrj   options::String_set::const_iterator					  \
469*fae548d3Szrj   varname__##_begin() const						  \
470*fae548d3Szrj   { return this->varname__##_.value.begin(); }				  \
471*fae548d3Szrj 									  \
472*fae548d3Szrj   options::String_set::const_iterator					  \
473*fae548d3Szrj   varname__##_end() const						  \
474*fae548d3Szrj   { return this->varname__##_.value.end(); }                              \
475*fae548d3Szrj                                                                           \
476*fae548d3Szrj   options::String_set::size_type                                          \
477*fae548d3Szrj   varname__##_size() const                                                \
478*fae548d3Szrj   { return this->varname__##_.value.size(); }                             \
479*fae548d3Szrj 
480*fae548d3Szrj // When you have a list of possible values (expressed as string)
481*fae548d3Szrj // After helparg__ should come an initializer list, like
482*fae548d3Szrj //   {"foo", "bar", "baz"}
483*fae548d3Szrj #define DEFINE_enum(varname__, dashes__, shortname__, default_value__,   \
484*fae548d3Szrj 		    helpstring__, helparg__, ...)                        \
485*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, default_value__,          \
486*fae548d3Szrj 	     default_value__, helpstring__, helparg__, false,		 \
487*fae548d3Szrj 	     const char*, const char*, parse_choices_##varname__, false) \
488*fae548d3Szrj  private:                                                                \
489*fae548d3Szrj   static void parse_choices_##varname__(const char* option_name,         \
490*fae548d3Szrj 					const char* arg,                 \
491*fae548d3Szrj 					const char** retval) {           \
492*fae548d3Szrj     const char* choices[] = __VA_ARGS__;                                 \
493*fae548d3Szrj     options::parse_choices(option_name, arg, retval,                     \
494*fae548d3Szrj 			   choices, sizeof(choices) / sizeof(*choices)); \
495*fae548d3Szrj   }
496*fae548d3Szrj 
497*fae548d3Szrj // This is like DEFINE_bool, but VARNAME is the name of a different
498*fae548d3Szrj // option.  This option becomes an alias for that one.  INVERT is true
499*fae548d3Szrj // if this option is an inversion of the other one.
500*fae548d3Szrj #define DEFINE_bool_alias(option__, varname__, dashes__, shortname__,	\
501*fae548d3Szrj 			  helpstring__, no_helpstring__, invert__)	\
502*fae548d3Szrj  private:								\
503*fae548d3Szrj   struct Struct_##option__ : public options::Struct_var			\
504*fae548d3Szrj   {									\
505*fae548d3Szrj     Struct_##option__()							\
506*fae548d3Szrj       : option(#option__, dashes__, shortname__, "", helpstring__,	\
507*fae548d3Szrj 	       NULL, false, this,					\
508*fae548d3Szrj 	       General_options::varname__##is_default ^ invert__)	\
509*fae548d3Szrj     { }									\
510*fae548d3Szrj 									\
511*fae548d3Szrj     void								\
512*fae548d3Szrj     parse_to_value(const char*, const char*,				\
513*fae548d3Szrj 		   Command_line*, General_options* options)		\
514*fae548d3Szrj     {									\
515*fae548d3Szrj       options->set_##varname__(!invert__);				\
516*fae548d3Szrj       options->set_user_set_##varname__();				\
517*fae548d3Szrj     }									\
518*fae548d3Szrj 									\
519*fae548d3Szrj     options::One_option option;						\
520*fae548d3Szrj   };									\
521*fae548d3Szrj   Struct_##option__ option__##_;					\
522*fae548d3Szrj 									\
523*fae548d3Szrj   struct Struct_no_##option__ : public options::Struct_var		\
524*fae548d3Szrj   {									\
525*fae548d3Szrj     Struct_no_##option__()						\
526*fae548d3Szrj       : option((dashes__ == options::DASH_Z				\
527*fae548d3Szrj 		? "no" #option__					\
528*fae548d3Szrj 		: "no-" #option__),					\
529*fae548d3Szrj 	       dashes__, '\0', "", no_helpstring__,			\
530*fae548d3Szrj 	       NULL, false, this,					\
531*fae548d3Szrj 	       !General_options::varname__##is_default ^ invert__)	\
532*fae548d3Szrj     { }									\
533*fae548d3Szrj 									\
534*fae548d3Szrj     void								\
535*fae548d3Szrj     parse_to_value(const char*, const char*,				\
536*fae548d3Szrj 		   Command_line*, General_options* options)		\
537*fae548d3Szrj     {									\
538*fae548d3Szrj       options->set_##varname__(invert__);				\
539*fae548d3Szrj       options->set_user_set_##varname__();				\
540*fae548d3Szrj     }									\
541*fae548d3Szrj 									\
542*fae548d3Szrj     options::One_option option;						\
543*fae548d3Szrj   };									\
544*fae548d3Szrj   Struct_no_##option__ no_##option__##_initializer_
545*fae548d3Szrj 
546*fae548d3Szrj // This is like DEFINE_uint64, but VARNAME is the name of a different
547*fae548d3Szrj // option.  This option becomes an alias for that one.
548*fae548d3Szrj #define DEFINE_uint64_alias(option__, varname__, dashes__, shortname__,	\
549*fae548d3Szrj 			    helpstring__, helparg__)			\
550*fae548d3Szrj  private:								\
551*fae548d3Szrj   struct Struct_##option__ : public options::Struct_var			\
552*fae548d3Szrj   {									\
553*fae548d3Szrj     Struct_##option__()							\
554*fae548d3Szrj       : option(#option__, dashes__, shortname__, "", helpstring__,	\
555*fae548d3Szrj 	       helparg__, false, this, false)				\
556*fae548d3Szrj     { }									\
557*fae548d3Szrj 									\
558*fae548d3Szrj     void								\
559*fae548d3Szrj     parse_to_value(const char* option_name, const char* arg,		\
560*fae548d3Szrj 		   Command_line*, General_options* options)		\
561*fae548d3Szrj     {									\
562*fae548d3Szrj       uint64_t value;							\
563*fae548d3Szrj       options::parse_uint64(option_name, arg, &value);			\
564*fae548d3Szrj       options->set_##varname__(value);					\
565*fae548d3Szrj       options->set_user_set_##varname__();				\
566*fae548d3Szrj     }									\
567*fae548d3Szrj 									\
568*fae548d3Szrj     options::One_option option;						\
569*fae548d3Szrj   };									\
570*fae548d3Szrj   Struct_##option__ option__##_;
571*fae548d3Szrj 
572*fae548d3Szrj // This is used for non-standard flags.  It defines no functions; it
573*fae548d3Szrj // just calls General_options::parse_VARNAME whenever the flag is
574*fae548d3Szrj // seen.  We declare parse_VARNAME as a static member of
575*fae548d3Szrj // General_options; you are responsible for defining it there.
576*fae548d3Szrj // helparg__ should be NULL iff this special-option is a boolean.
577*fae548d3Szrj #define DEFINE_special(varname__, dashes__, shortname__,                \
578*fae548d3Szrj 		       helpstring__, helparg__)                         \
579*fae548d3Szrj  private:                                                               \
580*fae548d3Szrj   void parse_##varname__(const char* option, const char* arg,           \
581*fae548d3Szrj 			 Command_line* inputs);                         \
582*fae548d3Szrj   struct Struct_##varname__ : public options::Struct_special            \
583*fae548d3Szrj   {                                                                     \
584*fae548d3Szrj     Struct_##varname__()                                                \
585*fae548d3Szrj       : options::Struct_special(#varname__, dashes__, shortname__,      \
586*fae548d3Szrj 				&General_options::parse_##varname__,    \
587*fae548d3Szrj 				helpstring__, helparg__)                \
588*fae548d3Szrj     { }                                                                 \
589*fae548d3Szrj   };                                                                    \
590*fae548d3Szrj   Struct_##varname__ varname__##_initializer_
591*fae548d3Szrj 
592*fae548d3Szrj // An option that takes an optional string argument.  If the option is
593*fae548d3Szrj // used with no argument, the value will be the default, and
594*fae548d3Szrj // user_set_via_option will be true.
595*fae548d3Szrj #define DEFINE_optional_string(varname__, dashes__, shortname__,	\
596*fae548d3Szrj 			       default_value__,				\
597*fae548d3Szrj 			       helpstring__, helparg__)			\
598*fae548d3Szrj   DEFINE_var(varname__, dashes__, shortname__, default_value__,		\
599*fae548d3Szrj 	     default_value__, helpstring__, helparg__, true,		\
600*fae548d3Szrj 	     const char*, const char*, options::parse_optional_string,  \
601*fae548d3Szrj 	     false)
602*fae548d3Szrj 
603*fae548d3Szrj // A directory to search.  For each directory we record whether it is
604*fae548d3Szrj // in the sysroot.  We need to know this so that, if a linker script
605*fae548d3Szrj // is found within the sysroot, we will apply the sysroot to any files
606*fae548d3Szrj // named by that script.
607*fae548d3Szrj 
608*fae548d3Szrj class Search_directory
609*fae548d3Szrj {
610*fae548d3Szrj  public:
611*fae548d3Szrj   // We need a default constructor because we put this in a
612*fae548d3Szrj   // std::vector.
Search_directory()613*fae548d3Szrj   Search_directory()
614*fae548d3Szrj     : name_(NULL), put_in_sysroot_(false), is_in_sysroot_(false)
615*fae548d3Szrj   { }
616*fae548d3Szrj 
617*fae548d3Szrj   // This is the usual constructor.
Search_directory(const std::string & name,bool put_in_sysroot)618*fae548d3Szrj   Search_directory(const std::string& name, bool put_in_sysroot)
619*fae548d3Szrj     : name_(name), put_in_sysroot_(put_in_sysroot), is_in_sysroot_(false)
620*fae548d3Szrj   {
621*fae548d3Szrj     if (this->name_.empty())
622*fae548d3Szrj       this->name_ = ".";
623*fae548d3Szrj   }
624*fae548d3Szrj 
625*fae548d3Szrj   // This is called if we have a sysroot.  The sysroot is prefixed to
626*fae548d3Szrj   // any entries for which put_in_sysroot_ is true.  is_in_sysroot_ is
627*fae548d3Szrj   // set to true for any enries which are in the sysroot (this will
628*fae548d3Szrj   // naturally include any entries for which put_in_sysroot_ is true).
629*fae548d3Szrj   // SYSROOT is the sysroot, CANONICAL_SYSROOT is the result of
630*fae548d3Szrj   // passing SYSROOT to lrealpath.
631*fae548d3Szrj   void
632*fae548d3Szrj   add_sysroot(const char* sysroot, const char* canonical_sysroot);
633*fae548d3Szrj 
634*fae548d3Szrj   // Get the directory name.
635*fae548d3Szrj   const std::string&
name()636*fae548d3Szrj   name() const
637*fae548d3Szrj   { return this->name_; }
638*fae548d3Szrj 
639*fae548d3Szrj   // Return whether this directory is in the sysroot.
640*fae548d3Szrj   bool
is_in_sysroot()641*fae548d3Szrj   is_in_sysroot() const
642*fae548d3Szrj   { return this->is_in_sysroot_; }
643*fae548d3Szrj 
644*fae548d3Szrj   // Return whether this is considered a system directory.
645*fae548d3Szrj   bool
is_system_directory()646*fae548d3Szrj   is_system_directory() const
647*fae548d3Szrj   { return this->put_in_sysroot_ || this->is_in_sysroot_; }
648*fae548d3Szrj 
649*fae548d3Szrj  private:
650*fae548d3Szrj   // The directory name.
651*fae548d3Szrj   std::string name_;
652*fae548d3Szrj   // True if the sysroot should be added as a prefix for this
653*fae548d3Szrj   // directory (if there is a sysroot).  This is true for system
654*fae548d3Szrj   // directories that we search by default.
655*fae548d3Szrj   bool put_in_sysroot_;
656*fae548d3Szrj   // True if this directory is in the sysroot (if there is a sysroot).
657*fae548d3Szrj   // This is true if there is a sysroot and either 1) put_in_sysroot_
658*fae548d3Szrj   // is true, or 2) the directory happens to be in the sysroot based
659*fae548d3Szrj   // on a pathname comparison.
660*fae548d3Szrj   bool is_in_sysroot_;
661*fae548d3Szrj };
662*fae548d3Szrj 
663*fae548d3Szrj class General_options
664*fae548d3Szrj {
665*fae548d3Szrj  private:
666*fae548d3Szrj   // NOTE: For every option that you add here, also consider if you
667*fae548d3Szrj   // should add it to Position_dependent_options.
668*fae548d3Szrj   DEFINE_special(help, options::TWO_DASHES, '\0',
669*fae548d3Szrj 		 N_("Report usage information"), NULL);
670*fae548d3Szrj   DEFINE_special(version, options::TWO_DASHES, 'v',
671*fae548d3Szrj 		 N_("Report version information"), NULL);
672*fae548d3Szrj   DEFINE_special(V, options::EXACTLY_ONE_DASH, '\0',
673*fae548d3Szrj 		 N_("Report version and target information"), NULL);
674*fae548d3Szrj 
675*fae548d3Szrj   // These options are sorted approximately so that for each letter in
676*fae548d3Szrj   // the alphabet, we show the option whose shortname is that letter
677*fae548d3Szrj   // (if any) and then every longname that starts with that letter (in
678*fae548d3Szrj   // alphabetical order).  For both, lowercase sorts before uppercase.
679*fae548d3Szrj   // The -z options come last.
680*fae548d3Szrj 
681*fae548d3Szrj   // a
682*fae548d3Szrj 
683*fae548d3Szrj   DEFINE_bool(add_needed, options::TWO_DASHES, '\0', false,
684*fae548d3Szrj 	      N_("Not supported"),
685*fae548d3Szrj 	      N_("Do not copy DT_NEEDED tags from shared libraries"));
686*fae548d3Szrj 
687*fae548d3Szrj   DEFINE_bool_alias(allow_multiple_definition, muldefs, options::TWO_DASHES,
688*fae548d3Szrj 		    '\0',
689*fae548d3Szrj 		    N_("Allow multiple definitions of symbols"),
690*fae548d3Szrj 		    N_("Do not allow multiple definitions"), false);
691*fae548d3Szrj 
692*fae548d3Szrj   DEFINE_bool(allow_shlib_undefined, options::TWO_DASHES, '\0', false,
693*fae548d3Szrj 	      N_("Allow unresolved references in shared libraries"),
694*fae548d3Szrj 	      N_("Do not allow unresolved references in shared libraries"));
695*fae548d3Szrj 
696*fae548d3Szrj   DEFINE_bool(apply_dynamic_relocs, options::TWO_DASHES, '\0', true,
697*fae548d3Szrj 	      N_("Apply link-time values for dynamic relocations"),
698*fae548d3Szrj 	      N_("(aarch64 only) Do not apply link-time values "
699*fae548d3Szrj 		 "for dynamic relocations"));
700*fae548d3Szrj 
701*fae548d3Szrj   DEFINE_bool(as_needed, options::TWO_DASHES, '\0', false,
702*fae548d3Szrj 	      N_("Use DT_NEEDED only for shared libraries that are used"),
703*fae548d3Szrj 	      N_("Use DT_NEEDED for all shared libraries"));
704*fae548d3Szrj 
705*fae548d3Szrj   DEFINE_enum(assert, options::ONE_DASH, '\0', NULL,
706*fae548d3Szrj 	      N_("Ignored"), N_("[ignored]"),
707*fae548d3Szrj 	      {"definitions", "nodefinitions", "nosymbolic", "pure-text"});
708*fae548d3Szrj 
709*fae548d3Szrj   // b
710*fae548d3Szrj 
711*fae548d3Szrj   // This should really be an "enum", but it's too easy for folks to
712*fae548d3Szrj   // forget to update the list as they add new targets.  So we just
713*fae548d3Szrj   // accept any string.  We'll fail later (when the string is parsed),
714*fae548d3Szrj   // if the target isn't actually supported.
715*fae548d3Szrj   DEFINE_string(format, options::TWO_DASHES, 'b', "elf",
716*fae548d3Szrj 		N_("Set input format"), ("[elf,binary]"));
717*fae548d3Szrj 
718*fae548d3Szrj   DEFINE_bool(be8, options::TWO_DASHES, '\0', false,
719*fae548d3Szrj 	      N_("Output BE8 format image"), NULL);
720*fae548d3Szrj 
721*fae548d3Szrj   DEFINE_optional_string(build_id, options::TWO_DASHES, '\0', "tree",
722*fae548d3Szrj 			 N_("Generate build ID note"),
723*fae548d3Szrj 			 N_("[=STYLE]"));
724*fae548d3Szrj 
725*fae548d3Szrj   DEFINE_uint64(build_id_chunk_size_for_treehash,
726*fae548d3Szrj 		options::TWO_DASHES, '\0', 2 << 20,
727*fae548d3Szrj 		N_("Chunk size for '--build-id=tree'"), N_("SIZE"));
728*fae548d3Szrj 
729*fae548d3Szrj   DEFINE_uint64(build_id_min_file_size_for_treehash, options::TWO_DASHES,
730*fae548d3Szrj 		'\0', 40 << 20,
731*fae548d3Szrj 		N_("Minimum output file size for '--build-id=tree' to work"
732*fae548d3Szrj 		   " differently than '--build-id=sha1'"), N_("SIZE"));
733*fae548d3Szrj 
734*fae548d3Szrj   DEFINE_bool(Bdynamic, options::ONE_DASH, '\0', true,
735*fae548d3Szrj 	      N_("-l searches for shared libraries"), NULL);
736*fae548d3Szrj   DEFINE_bool_alias(Bstatic, Bdynamic, options::ONE_DASH, '\0',
737*fae548d3Szrj 		    N_("-l does not search for shared libraries"), NULL,
738*fae548d3Szrj 		    true);
739*fae548d3Szrj   DEFINE_bool_alias(dy, Bdynamic, options::ONE_DASH, '\0',
740*fae548d3Szrj 		    N_("alias for -Bdynamic"), NULL, false);
741*fae548d3Szrj   DEFINE_bool_alias(dn, Bdynamic, options::ONE_DASH, '\0',
742*fae548d3Szrj 		    N_("alias for -Bstatic"), NULL, true);
743*fae548d3Szrj 
744*fae548d3Szrj   DEFINE_bool(Bgroup, options::ONE_DASH, '\0', false,
745*fae548d3Szrj 	      N_("Use group name lookup rules for shared library"), NULL);
746*fae548d3Szrj 
747*fae548d3Szrj   DEFINE_bool(Bshareable, options::ONE_DASH, '\0', false,
748*fae548d3Szrj 	      N_("Generate shared library (alias for -G/-shared)"), NULL);
749*fae548d3Szrj 
750*fae548d3Szrj   DEFINE_bool(Bsymbolic, options::ONE_DASH, '\0', false,
751*fae548d3Szrj 	      N_("Bind defined symbols locally"), NULL);
752*fae548d3Szrj 
753*fae548d3Szrj   DEFINE_bool(Bsymbolic_functions, options::ONE_DASH, '\0', false,
754*fae548d3Szrj 	      N_("Bind defined function symbols locally"), NULL);
755*fae548d3Szrj 
756*fae548d3Szrj   // c
757*fae548d3Szrj 
758*fae548d3Szrj   DEFINE_bool(check_sections, options::TWO_DASHES, '\0', true,
759*fae548d3Szrj 	      N_("Check segment addresses for overlaps"),
760*fae548d3Szrj 	      N_("Do not check segment addresses for overlaps"));
761*fae548d3Szrj 
762*fae548d3Szrj   DEFINE_enum(compress_debug_sections, options::TWO_DASHES, '\0', "none",
763*fae548d3Szrj 	      N_("Compress .debug_* sections in the output file"),
764*fae548d3Szrj 	      ("[none,zlib,zlib-gnu,zlib-gabi]"),
765*fae548d3Szrj 	      {"none", "zlib", "zlib-gnu", "zlib-gabi"});
766*fae548d3Szrj 
767*fae548d3Szrj   DEFINE_bool(copy_dt_needed_entries, options::TWO_DASHES, '\0', false,
768*fae548d3Szrj 	      N_("Not supported"),
769*fae548d3Szrj 	      N_("Do not copy DT_NEEDED tags from shared libraries"));
770*fae548d3Szrj 
771*fae548d3Szrj   DEFINE_bool(cref, options::TWO_DASHES, '\0', false,
772*fae548d3Szrj 	      N_("Output cross reference table"),
773*fae548d3Szrj 	      N_("Do not output cross reference table"));
774*fae548d3Szrj 
775*fae548d3Szrj   DEFINE_bool(ctors_in_init_array, options::TWO_DASHES, '\0', true,
776*fae548d3Szrj 	      N_("Use DT_INIT_ARRAY for all constructors"),
777*fae548d3Szrj 	      N_("Handle constructors as directed by compiler"));
778*fae548d3Szrj 
779*fae548d3Szrj   // d
780*fae548d3Szrj 
781*fae548d3Szrj   DEFINE_bool(define_common, options::TWO_DASHES, 'd', false,
782*fae548d3Szrj 	      N_("Define common symbols"),
783*fae548d3Szrj 	      N_("Do not define common symbols in relocatable output"));
784*fae548d3Szrj   DEFINE_bool(dc, options::ONE_DASH, '\0', false,
785*fae548d3Szrj 	      N_("Alias for -d"), NULL);
786*fae548d3Szrj   DEFINE_bool(dp, options::ONE_DASH, '\0', false,
787*fae548d3Szrj 	      N_("Alias for -d"), NULL);
788*fae548d3Szrj 
789*fae548d3Szrj   DEFINE_string(debug, options::TWO_DASHES, '\0', "",
790*fae548d3Szrj 		N_("Turn on debugging"),
791*fae548d3Szrj 		N_("[all,files,script,task][,...]"));
792*fae548d3Szrj 
793*fae548d3Szrj   DEFINE_special(defsym, options::TWO_DASHES, '\0',
794*fae548d3Szrj 		 N_("Define a symbol"), N_("SYMBOL=EXPRESSION"));
795*fae548d3Szrj 
796*fae548d3Szrj   DEFINE_optional_string(demangle, options::TWO_DASHES, '\0', NULL,
797*fae548d3Szrj 			 N_("Demangle C++ symbols in log messages"),
798*fae548d3Szrj 			 N_("[=STYLE]"));
799*fae548d3Szrj   DEFINE_bool(no_demangle, options::TWO_DASHES, '\0', false,
800*fae548d3Szrj 	      N_("Do not demangle C++ symbols in log messages"),
801*fae548d3Szrj 	      NULL);
802*fae548d3Szrj 
803*fae548d3Szrj   DEFINE_bool(detect_odr_violations, options::TWO_DASHES, '\0', false,
804*fae548d3Szrj 	      N_("Look for violations of the C++ One Definition Rule"),
805*fae548d3Szrj 	      N_("Do not look for violations of the C++ One Definition Rule"));
806*fae548d3Szrj 
807*fae548d3Szrj   DEFINE_bool(dynamic_list_data, options::TWO_DASHES, '\0', false,
808*fae548d3Szrj 	      N_("Add data symbols to dynamic symbols"), NULL);
809*fae548d3Szrj 
810*fae548d3Szrj   DEFINE_bool(dynamic_list_cpp_new, options::TWO_DASHES, '\0', false,
811*fae548d3Szrj 	      N_("Add C++ operator new/delete to dynamic symbols"), NULL);
812*fae548d3Szrj 
813*fae548d3Szrj   DEFINE_bool(dynamic_list_cpp_typeinfo, options::TWO_DASHES, '\0', false,
814*fae548d3Szrj 	      N_("Add C++ typeinfo to dynamic symbols"), NULL);
815*fae548d3Szrj 
816*fae548d3Szrj   DEFINE_special(dynamic_list, options::TWO_DASHES, '\0',
817*fae548d3Szrj 		 N_("Read a list of dynamic symbols"), N_("FILE"));
818*fae548d3Szrj 
819*fae548d3Szrj   // e
820*fae548d3Szrj 
821*fae548d3Szrj   DEFINE_bool(emit_stub_syms, options::TWO_DASHES, '\0', true,
822*fae548d3Szrj 	      N_("(PowerPC only) Label linker stubs with a symbol"),
823*fae548d3Szrj 	      N_("(PowerPC only) Do not label linker stubs with a symbol"));
824*fae548d3Szrj 
825*fae548d3Szrj   DEFINE_string(entry, options::TWO_DASHES, 'e', NULL,
826*fae548d3Szrj 		N_("Set program start address"), N_("ADDRESS"));
827*fae548d3Szrj 
828*fae548d3Szrj   DEFINE_bool(eh_frame_hdr, options::TWO_DASHES, '\0', false,
829*fae548d3Szrj 	      N_("Create exception frame header"),
830*fae548d3Szrj 	      N_("Do not create exception frame header"));
831*fae548d3Szrj 
832*fae548d3Szrj   // Alphabetized under 'e' because the option is spelled --enable-new-dtags.
833*fae548d3Szrj   DEFINE_enable(new_dtags, options::EXACTLY_TWO_DASHES, '\0', true,
834*fae548d3Szrj 		N_("Enable use of DT_RUNPATH"),
835*fae548d3Szrj 		N_("Disable use of DT_RUNPATH"));
836*fae548d3Szrj 
837*fae548d3Szrj   DEFINE_bool(enum_size_warning, options::TWO_DASHES, '\0', true, NULL,
838*fae548d3Szrj 	      N_("(ARM only) Do not warn about objects with incompatible "
839*fae548d3Szrj 		 "enum sizes"));
840*fae548d3Szrj 
841*fae548d3Szrj   DEFINE_special(exclude_libs, options::TWO_DASHES, '\0',
842*fae548d3Szrj 		 N_("Exclude libraries from automatic export"),
843*fae548d3Szrj 		 N_(("lib,lib ...")));
844*fae548d3Szrj 
845*fae548d3Szrj   DEFINE_bool(export_dynamic, options::TWO_DASHES, 'E', false,
846*fae548d3Szrj 	      N_("Export all dynamic symbols"),
847*fae548d3Szrj 	      N_("Do not export all dynamic symbols"));
848*fae548d3Szrj 
849*fae548d3Szrj   DEFINE_set(export_dynamic_symbol, options::TWO_DASHES, '\0',
850*fae548d3Szrj 	     N_("Export SYMBOL to dynamic symbol table"), N_("SYMBOL"));
851*fae548d3Szrj 
852*fae548d3Szrj   DEFINE_special(EB, options::ONE_DASH, '\0',
853*fae548d3Szrj 		 N_("Link big-endian objects."), NULL);
854*fae548d3Szrj   DEFINE_special(EL, options::ONE_DASH, '\0',
855*fae548d3Szrj 		 N_("Link little-endian objects."), NULL);
856*fae548d3Szrj 
857*fae548d3Szrj   // f
858*fae548d3Szrj 
859*fae548d3Szrj   DEFINE_set(auxiliary, options::TWO_DASHES, 'f',
860*fae548d3Szrj 	     N_("Auxiliary filter for shared object symbol table"),
861*fae548d3Szrj 	     N_("SHLIB"));
862*fae548d3Szrj 
863*fae548d3Szrj   DEFINE_string(filter, options::TWO_DASHES, 'F', NULL,
864*fae548d3Szrj 		N_("Filter for shared object symbol table"),
865*fae548d3Szrj 		N_("SHLIB"));
866*fae548d3Szrj 
867*fae548d3Szrj   DEFINE_bool(fatal_warnings, options::TWO_DASHES, '\0', false,
868*fae548d3Szrj 	      N_("Treat warnings as errors"),
869*fae548d3Szrj 	      N_("Do not treat warnings as errors"));
870*fae548d3Szrj 
871*fae548d3Szrj   DEFINE_string(fini, options::ONE_DASH, '\0', "_fini",
872*fae548d3Szrj 		N_("Call SYMBOL at unload-time"), N_("SYMBOL"));
873*fae548d3Szrj 
874*fae548d3Szrj   DEFINE_bool(fix_arm1176, options::TWO_DASHES, '\0', true,
875*fae548d3Szrj 	      N_("(ARM only) Fix binaries for ARM1176 erratum"),
876*fae548d3Szrj 	      N_("(ARM only) Do not fix binaries for ARM1176 erratum"));
877*fae548d3Szrj 
878*fae548d3Szrj   DEFINE_bool(fix_cortex_a8, options::TWO_DASHES, '\0', false,
879*fae548d3Szrj 	      N_("(ARM only) Fix binaries for Cortex-A8 erratum"),
880*fae548d3Szrj 	      N_("(ARM only) Do not fix binaries for Cortex-A8 erratum"));
881*fae548d3Szrj 
882*fae548d3Szrj   DEFINE_bool(fix_cortex_a53_843419, options::TWO_DASHES, '\0', false,
883*fae548d3Szrj 	      N_("(AArch64 only) Fix Cortex-A53 erratum 843419"),
884*fae548d3Szrj 	      N_("(AArch64 only) Do not fix Cortex-A53 erratum 843419"));
885*fae548d3Szrj 
886*fae548d3Szrj   DEFINE_bool(fix_cortex_a53_835769, options::TWO_DASHES, '\0', false,
887*fae548d3Szrj 	      N_("(AArch64 only) Fix Cortex-A53 erratum 835769"),
888*fae548d3Szrj 	      N_("(AArch64 only) Do not fix Cortex-A53 erratum 835769"));
889*fae548d3Szrj 
890*fae548d3Szrj   DEFINE_special(fix_v4bx, options::TWO_DASHES, '\0',
891*fae548d3Szrj 		 N_("(ARM only) Rewrite BX rn as MOV pc, rn for ARMv4"),
892*fae548d3Szrj 		 NULL);
893*fae548d3Szrj 
894*fae548d3Szrj   DEFINE_special(fix_v4bx_interworking, options::TWO_DASHES, '\0',
895*fae548d3Szrj 		 N_("(ARM only) Rewrite BX rn branch to ARMv4 interworking "
896*fae548d3Szrj 		    "veneer"),
897*fae548d3Szrj 		 NULL);
898*fae548d3Szrj 
899*fae548d3Szrj   DEFINE_string(fuse_ld, options::ONE_DASH, '\0', "",
900*fae548d3Szrj 		N_("Ignored for GCC linker option compatibility"),
901*fae548d3Szrj 		N_("[gold,bfd]"));
902*fae548d3Szrj 
903*fae548d3Szrj   // g
904*fae548d3Szrj 
905*fae548d3Szrj   DEFINE_bool(g, options::EXACTLY_ONE_DASH, '\0', false,
906*fae548d3Szrj 	      N_("Ignored"), NULL);
907*fae548d3Szrj 
908*fae548d3Szrj   DEFINE_bool(gc_sections, options::TWO_DASHES, '\0', false,
909*fae548d3Szrj 	      N_("Remove unused sections"),
910*fae548d3Szrj 	      N_("Don't remove unused sections"));
911*fae548d3Szrj 
912*fae548d3Szrj   DEFINE_bool(gdb_index, options::TWO_DASHES, '\0', false,
913*fae548d3Szrj 	      N_("Generate .gdb_index section"),
914*fae548d3Szrj 	      N_("Do not generate .gdb_index section"));
915*fae548d3Szrj 
916*fae548d3Szrj   DEFINE_bool(gnu_unique, options::TWO_DASHES, '\0', true,
917*fae548d3Szrj 	      N_("Enable STB_GNU_UNIQUE symbol binding"),
918*fae548d3Szrj 	      N_("Disable STB_GNU_UNIQUE symbol binding"));
919*fae548d3Szrj 
920*fae548d3Szrj   DEFINE_bool(shared, options::ONE_DASH, 'G', false,
921*fae548d3Szrj 	      N_("Generate shared library"), NULL);
922*fae548d3Szrj 
923*fae548d3Szrj   // h
924*fae548d3Szrj 
925*fae548d3Szrj   DEFINE_string(soname, options::ONE_DASH, 'h', NULL,
926*fae548d3Szrj 		N_("Set shared library name"), N_("FILENAME"));
927*fae548d3Szrj 
928*fae548d3Szrj   DEFINE_double(hash_bucket_empty_fraction, options::TWO_DASHES, '\0', 0.0,
929*fae548d3Szrj 		N_("Min fraction of empty buckets in dynamic hash"),
930*fae548d3Szrj 		N_("FRACTION"));
931*fae548d3Szrj 
932*fae548d3Szrj   DEFINE_enum(hash_style, options::TWO_DASHES, '\0', DEFAULT_HASH_STYLE,
933*fae548d3Szrj 	      N_("Dynamic hash style"), N_("[sysv,gnu,both]"),
934*fae548d3Szrj 	      {"sysv", "gnu", "both"});
935*fae548d3Szrj 
936*fae548d3Szrj   // i
937*fae548d3Szrj 
938*fae548d3Szrj   DEFINE_bool_alias(i, relocatable, options::EXACTLY_ONE_DASH, '\0',
939*fae548d3Szrj 		    N_("Alias for -r"), NULL, false);
940*fae548d3Szrj 
941*fae548d3Szrj   DEFINE_enum(icf, options::TWO_DASHES, '\0', "none",
942*fae548d3Szrj 	      N_("Identical Code Folding. "
943*fae548d3Szrj 		 "\'--icf=safe\' Folds ctors, dtors and functions whose"
944*fae548d3Szrj 		 " pointers are definitely not taken"),
945*fae548d3Szrj 	      ("[none,all,safe]"),
946*fae548d3Szrj 	      {"none", "all", "safe"});
947*fae548d3Szrj 
948*fae548d3Szrj   DEFINE_uint(icf_iterations, options::TWO_DASHES , '\0', 0,
949*fae548d3Szrj 	      N_("Number of iterations of ICF (default 3)"), N_("COUNT"));
950*fae548d3Szrj 
951*fae548d3Szrj   DEFINE_special(incremental, options::TWO_DASHES, '\0',
952*fae548d3Szrj 		 N_("Do an incremental link if possible; "
953*fae548d3Szrj 		    "otherwise, do a full link and prepare output "
954*fae548d3Szrj 		    "for incremental linking"), NULL);
955*fae548d3Szrj 
956*fae548d3Szrj   DEFINE_special(no_incremental, options::TWO_DASHES, '\0',
957*fae548d3Szrj 		 N_("Do a full link (default)"), NULL);
958*fae548d3Szrj 
959*fae548d3Szrj   DEFINE_special(incremental_full, options::TWO_DASHES, '\0',
960*fae548d3Szrj 		 N_("Do a full link and "
961*fae548d3Szrj 		    "prepare output for incremental linking"), NULL);
962*fae548d3Szrj 
963*fae548d3Szrj   DEFINE_special(incremental_update, options::TWO_DASHES, '\0',
964*fae548d3Szrj 		 N_("Do an incremental link; exit if not possible"), NULL);
965*fae548d3Szrj 
966*fae548d3Szrj   DEFINE_string(incremental_base, options::TWO_DASHES, '\0', NULL,
967*fae548d3Szrj 		N_("Set base file for incremental linking"
968*fae548d3Szrj 		   " (default is output file)"),
969*fae548d3Szrj 		N_("FILE"));
970*fae548d3Szrj 
971*fae548d3Szrj   DEFINE_special(incremental_changed, options::TWO_DASHES, '\0',
972*fae548d3Szrj 		 N_("Assume files changed"), NULL);
973*fae548d3Szrj 
974*fae548d3Szrj   DEFINE_special(incremental_unchanged, options::TWO_DASHES, '\0',
975*fae548d3Szrj 		 N_("Assume files didn't change"), NULL);
976*fae548d3Szrj 
977*fae548d3Szrj   DEFINE_special(incremental_unknown, options::TWO_DASHES, '\0',
978*fae548d3Szrj 		 N_("Use timestamps to check files (default)"), NULL);
979*fae548d3Szrj 
980*fae548d3Szrj   DEFINE_special(incremental_startup_unchanged, options::TWO_DASHES, '\0',
981*fae548d3Szrj 		 N_("Assume startup files unchanged "
982*fae548d3Szrj 		    "(files preceding this option)"), NULL);
983*fae548d3Szrj 
984*fae548d3Szrj   DEFINE_percent(incremental_patch, options::TWO_DASHES, '\0', 10,
985*fae548d3Szrj 		 N_("Amount of extra space to allocate for patches "
986*fae548d3Szrj 		    "(default 10)"),
987*fae548d3Szrj 		 N_("PERCENT"));
988*fae548d3Szrj 
989*fae548d3Szrj   DEFINE_string(init, options::ONE_DASH, '\0', "_init",
990*fae548d3Szrj 		N_("Call SYMBOL at load-time"), N_("SYMBOL"));
991*fae548d3Szrj 
992*fae548d3Szrj   DEFINE_string(dynamic_linker, options::TWO_DASHES, 'I', NULL,
993*fae548d3Szrj 		N_("Set dynamic linker path"), N_("PROGRAM"));
994*fae548d3Szrj 
995*fae548d3Szrj   // j
996*fae548d3Szrj 
997*fae548d3Szrj   DEFINE_special(just_symbols, options::TWO_DASHES, '\0',
998*fae548d3Szrj 		 N_("Read only symbol values from FILE"), N_("FILE"));
999*fae548d3Szrj 
1000*fae548d3Szrj   // k
1001*fae548d3Szrj 
1002*fae548d3Szrj   DEFINE_bool(keep_files_mapped, options::TWO_DASHES, '\0', true,
1003*fae548d3Szrj 	      N_("Keep files mapped across passes"),
1004*fae548d3Szrj 	      N_("Release mapped files after each pass"));
1005*fae548d3Szrj 
1006*fae548d3Szrj   DEFINE_set(keep_unique, options::TWO_DASHES, '\0',
1007*fae548d3Szrj 	     N_("Do not fold this symbol during ICF"), N_("SYMBOL"));
1008*fae548d3Szrj 
1009*fae548d3Szrj   // l
1010*fae548d3Szrj 
1011*fae548d3Szrj   DEFINE_special(library, options::TWO_DASHES, 'l',
1012*fae548d3Szrj 		 N_("Search for library LIBNAME"), N_("LIBNAME"));
1013*fae548d3Szrj 
1014*fae548d3Szrj   DEFINE_bool(ld_generated_unwind_info, options::TWO_DASHES, '\0', true,
1015*fae548d3Szrj 	      N_("Generate unwind information for PLT"),
1016*fae548d3Szrj 	      N_("Do not generate unwind information for PLT"));
1017*fae548d3Szrj 
1018*fae548d3Szrj   DEFINE_dirlist(library_path, options::TWO_DASHES, 'L',
1019*fae548d3Szrj 		 N_("Add directory to search path"), N_("DIR"));
1020*fae548d3Szrj 
1021*fae548d3Szrj   DEFINE_bool(long_plt, options::TWO_DASHES, '\0', false,
1022*fae548d3Szrj 	      N_("(ARM only) Generate long PLT entries"),
1023*fae548d3Szrj 	      N_("(ARM only) Do not generate long PLT entries"));
1024*fae548d3Szrj 
1025*fae548d3Szrj   // m
1026*fae548d3Szrj 
1027*fae548d3Szrj   DEFINE_string(m, options::EXACTLY_ONE_DASH, 'm', "",
1028*fae548d3Szrj 		N_("Set GNU linker emulation; obsolete"), N_("EMULATION"));
1029*fae548d3Szrj 
1030*fae548d3Szrj   DEFINE_bool(map_whole_files, options::TWO_DASHES, '\0',
1031*fae548d3Szrj 	      sizeof(void*) >= 8,
1032*fae548d3Szrj 	      N_("Map whole files to memory"),
1033*fae548d3Szrj 	      N_("Map relevant file parts to memory"));
1034*fae548d3Szrj 
1035*fae548d3Szrj   DEFINE_bool(merge_exidx_entries, options::TWO_DASHES, '\0', true,
1036*fae548d3Szrj 	      N_("(ARM only) Merge exidx entries in debuginfo"),
1037*fae548d3Szrj 	      N_("(ARM only) Do not merge exidx entries in debuginfo"));
1038*fae548d3Szrj 
1039*fae548d3Szrj   DEFINE_bool(mmap_output_file, options::TWO_DASHES, '\0', true,
1040*fae548d3Szrj 	      N_("Map the output file for writing"),
1041*fae548d3Szrj 	      N_("Do not map the output file for writing"));
1042*fae548d3Szrj 
1043*fae548d3Szrj   DEFINE_bool(print_map, options::TWO_DASHES, 'M', false,
1044*fae548d3Szrj 	      N_("Write map file on standard output"), NULL);
1045*fae548d3Szrj 
1046*fae548d3Szrj   DEFINE_string(Map, options::ONE_DASH, '\0', NULL, N_("Write map file"),
1047*fae548d3Szrj 		N_("MAPFILENAME"));
1048*fae548d3Szrj 
1049*fae548d3Szrj   // n
1050*fae548d3Szrj 
1051*fae548d3Szrj   DEFINE_bool(nmagic, options::TWO_DASHES, 'n', false,
1052*fae548d3Szrj 	      N_("Do not page align data"), NULL);
1053*fae548d3Szrj   DEFINE_bool(omagic, options::EXACTLY_TWO_DASHES, 'N', false,
1054*fae548d3Szrj 	      N_("Do not page align data, do not make text readonly"),
1055*fae548d3Szrj 	      N_("Page align data, make text readonly"));
1056*fae548d3Szrj 
1057*fae548d3Szrj   DEFINE_bool(no_keep_memory, options::TWO_DASHES, '\0', false,
1058*fae548d3Szrj 	      N_("Use less memory and more disk I/O "
1059*fae548d3Szrj 		 "(included only for compatibility with GNU ld)"), NULL);
1060*fae548d3Szrj 
1061*fae548d3Szrj   DEFINE_bool_alias(no_undefined, defs, options::TWO_DASHES, '\0',
1062*fae548d3Szrj 		    N_("Report undefined symbols (even with --shared)"),
1063*fae548d3Szrj 		    NULL, false);
1064*fae548d3Szrj 
1065*fae548d3Szrj   DEFINE_bool(noinhibit_exec, options::TWO_DASHES, '\0', false,
1066*fae548d3Szrj 	      N_("Create an output file even if errors occur"), NULL);
1067*fae548d3Szrj 
1068*fae548d3Szrj   DEFINE_bool(nostdlib, options::ONE_DASH, '\0', false,
1069*fae548d3Szrj 	      N_("Only search directories specified on the command line"),
1070*fae548d3Szrj 	      NULL);
1071*fae548d3Szrj 
1072*fae548d3Szrj   // o
1073*fae548d3Szrj 
1074*fae548d3Szrj   DEFINE_string(output, options::TWO_DASHES, 'o', "a.out",
1075*fae548d3Szrj 		N_("Set output file name"), N_("FILE"));
1076*fae548d3Szrj 
1077*fae548d3Szrj   DEFINE_string(oformat, options::EXACTLY_TWO_DASHES, '\0', "elf",
1078*fae548d3Szrj 		N_("Set output format"), N_("[binary]"));
1079*fae548d3Szrj 
1080*fae548d3Szrj   DEFINE_uint(optimize, options::EXACTLY_ONE_DASH, 'O', 0,
1081*fae548d3Szrj 	      N_("Optimize output file size"), N_("LEVEL"));
1082*fae548d3Szrj 
1083*fae548d3Szrj   DEFINE_enum(orphan_handling, options::TWO_DASHES, '\0', "place",
1084*fae548d3Szrj 	      N_("Orphan section handling"), N_("[place,discard,warn,error]"),
1085*fae548d3Szrj 	      {"place", "discard", "warn", "error"});
1086*fae548d3Szrj 
1087*fae548d3Szrj   // p
1088*fae548d3Szrj 
1089*fae548d3Szrj   DEFINE_bool(p, options::ONE_DASH, 'p', false,
1090*fae548d3Szrj 	      N_("Ignored for ARM compatibility"), NULL);
1091*fae548d3Szrj 
1092*fae548d3Szrj   DEFINE_bool(pie, options::ONE_DASH, '\0', false,
1093*fae548d3Szrj 	      N_("Create a position independent executable"),
1094*fae548d3Szrj 	      N_("Do not create a position independent executable"));
1095*fae548d3Szrj   DEFINE_bool_alias(pic_executable, pie, options::TWO_DASHES, '\0',
1096*fae548d3Szrj 		    N_("Create a position independent executable"),
1097*fae548d3Szrj 		    N_("Do not create a position independent executable"),
1098*fae548d3Szrj 		    false);
1099*fae548d3Szrj 
1100*fae548d3Szrj   DEFINE_bool(pic_veneer, options::TWO_DASHES, '\0', false,
1101*fae548d3Szrj 	      N_("Force PIC sequences for ARM/Thumb interworking veneers"),
1102*fae548d3Szrj 	      NULL);
1103*fae548d3Szrj 
1104*fae548d3Szrj   DEFINE_bool(pipeline_knowledge, options::ONE_DASH, '\0', false,
1105*fae548d3Szrj 	      NULL, N_("(ARM only) Ignore for backward compatibility"));
1106*fae548d3Szrj 
1107*fae548d3Szrj   DEFINE_var(plt_align, options::TWO_DASHES, '\0', 0, "5",
1108*fae548d3Szrj 	     N_("(PowerPC only) Align PLT call stubs to fit cache lines"),
1109*fae548d3Szrj 	     N_("[=P2ALIGN]"), true, int, int, options::parse_uint, false);
1110*fae548d3Szrj 
1111*fae548d3Szrj   DEFINE_bool(plt_localentry, options::TWO_DASHES, '\0', false,
1112*fae548d3Szrj 	      N_("(PowerPC64 only) Optimize calls to ELFv2 localentry:0 functions"),
1113*fae548d3Szrj 	      N_("(PowerPC64 only) Don't optimize ELFv2 calls"));
1114*fae548d3Szrj 
1115*fae548d3Szrj   DEFINE_bool(plt_static_chain, options::TWO_DASHES, '\0', false,
1116*fae548d3Szrj 	      N_("(PowerPC64 only) PLT call stubs should load r11"),
1117*fae548d3Szrj 	      N_("(PowerPC64 only) PLT call stubs should not load r11"));
1118*fae548d3Szrj 
1119*fae548d3Szrj   DEFINE_bool(plt_thread_safe, options::TWO_DASHES, '\0', false,
1120*fae548d3Szrj 	      N_("(PowerPC64 only) PLT call stubs with load-load barrier"),
1121*fae548d3Szrj 	      N_("(PowerPC64 only) PLT call stubs without barrier"));
1122*fae548d3Szrj 
1123*fae548d3Szrj #ifdef ENABLE_PLUGINS
1124*fae548d3Szrj   DEFINE_special(plugin, options::TWO_DASHES, '\0',
1125*fae548d3Szrj 		 N_("Load a plugin library"), N_("PLUGIN"));
1126*fae548d3Szrj   DEFINE_special(plugin_opt, options::TWO_DASHES, '\0',
1127*fae548d3Szrj 		 N_("Pass an option to the plugin"), N_("OPTION"));
1128*fae548d3Szrj #else
1129*fae548d3Szrj   DEFINE_special(plugin, options::TWO_DASHES, '\0',
1130*fae548d3Szrj 		 N_("Load a plugin library (not supported)"), N_("PLUGIN"));
1131*fae548d3Szrj   DEFINE_special(plugin_opt, options::TWO_DASHES, '\0',
1132*fae548d3Szrj 		 N_("Pass an option to the plugin (not supported)"),
1133*fae548d3Szrj 		 N_("OPTION"));
1134*fae548d3Szrj #endif
1135*fae548d3Szrj 
1136*fae548d3Szrj   DEFINE_bool(posix_fallocate, options::TWO_DASHES, '\0', true,
1137*fae548d3Szrj 	      N_("Use posix_fallocate to reserve space in the output file"),
1138*fae548d3Szrj 	      N_("Use fallocate or ftruncate to reserve space"));
1139*fae548d3Szrj 
1140*fae548d3Szrj   DEFINE_bool(preread_archive_symbols, options::TWO_DASHES, '\0', false,
1141*fae548d3Szrj 	      N_("Preread archive symbols when multi-threaded"), NULL);
1142*fae548d3Szrj 
1143*fae548d3Szrj   DEFINE_bool(print_gc_sections, options::TWO_DASHES, '\0', false,
1144*fae548d3Szrj 	      N_("List removed unused sections on stderr"),
1145*fae548d3Szrj 	      N_("Do not list removed unused sections"));
1146*fae548d3Szrj 
1147*fae548d3Szrj   DEFINE_bool(print_icf_sections, options::TWO_DASHES, '\0', false,
1148*fae548d3Szrj 	      N_("List folded identical sections on stderr"),
1149*fae548d3Szrj 	      N_("Do not list folded identical sections"));
1150*fae548d3Szrj 
1151*fae548d3Szrj   DEFINE_bool(print_output_format, options::TWO_DASHES, '\0', false,
1152*fae548d3Szrj 	      N_("Print default output format"), NULL);
1153*fae548d3Szrj 
1154*fae548d3Szrj   DEFINE_string(print_symbol_counts, options::TWO_DASHES, '\0', NULL,
1155*fae548d3Szrj 		N_("Print symbols defined and used for each input"),
1156*fae548d3Szrj 		N_("FILENAME"));
1157*fae548d3Szrj 
1158*fae548d3Szrj   DEFINE_special(push_state, options::TWO_DASHES, '\0',
1159*fae548d3Szrj 		 N_("Save the state of flags related to input files"), NULL);
1160*fae548d3Szrj   DEFINE_special(pop_state, options::TWO_DASHES, '\0',
1161*fae548d3Szrj 		 N_("Restore the state of flags related to input files"), NULL);
1162*fae548d3Szrj 
1163*fae548d3Szrj   // q
1164*fae548d3Szrj 
1165*fae548d3Szrj   DEFINE_bool(emit_relocs, options::TWO_DASHES, 'q', false,
1166*fae548d3Szrj 	      N_("Generate relocations in output"), NULL);
1167*fae548d3Szrj 
1168*fae548d3Szrj   DEFINE_bool(Qy, options::EXACTLY_ONE_DASH, '\0', false,
1169*fae548d3Szrj 	      N_("Ignored for SVR4 compatibility"), NULL);
1170*fae548d3Szrj 
1171*fae548d3Szrj   // r
1172*fae548d3Szrj 
1173*fae548d3Szrj   DEFINE_bool(relocatable, options::EXACTLY_ONE_DASH, 'r', false,
1174*fae548d3Szrj 	      N_("Generate relocatable output"), NULL);
1175*fae548d3Szrj 
1176*fae548d3Szrj   DEFINE_bool(relax, options::TWO_DASHES, '\0', false,
1177*fae548d3Szrj 	      N_("Relax branches on certain targets"),
1178*fae548d3Szrj 	      N_("Do not relax branches"));
1179*fae548d3Szrj 
1180*fae548d3Szrj   DEFINE_string(retain_symbols_file, options::TWO_DASHES, '\0', NULL,
1181*fae548d3Szrj 		N_("keep only symbols listed in this file"), N_("FILE"));
1182*fae548d3Szrj 
1183*fae548d3Szrj   DEFINE_bool(rosegment, options::TWO_DASHES, '\0', false,
1184*fae548d3Szrj 	      N_("Put read-only non-executable sections in their own segment"),
1185*fae548d3Szrj 	      NULL);
1186*fae548d3Szrj 
1187*fae548d3Szrj   DEFINE_uint64(rosegment_gap, options::TWO_DASHES, '\0', -1U,
1188*fae548d3Szrj 		N_("Set offset between executable and read-only segments"),
1189*fae548d3Szrj 		N_("OFFSET"));
1190*fae548d3Szrj 
1191*fae548d3Szrj   // -R really means -rpath, but can mean --just-symbols for
1192*fae548d3Szrj   // compatibility with GNU ld.  -rpath is always -rpath, so we list
1193*fae548d3Szrj   // it separately.
1194*fae548d3Szrj   DEFINE_special(R, options::EXACTLY_ONE_DASH, 'R',
1195*fae548d3Szrj 		 N_("Add DIR to runtime search path"), N_("DIR"));
1196*fae548d3Szrj 
1197*fae548d3Szrj   DEFINE_dirlist(rpath, options::ONE_DASH, '\0',
1198*fae548d3Szrj 		 N_("Add DIR to runtime search path"), N_("DIR"));
1199*fae548d3Szrj 
1200*fae548d3Szrj   DEFINE_dirlist(rpath_link, options::TWO_DASHES, '\0',
1201*fae548d3Szrj 		 N_("Add DIR to link time shared library search path"),
1202*fae548d3Szrj 		 N_("DIR"));
1203*fae548d3Szrj 
1204*fae548d3Szrj   // s
1205*fae548d3Szrj 
1206*fae548d3Szrj   DEFINE_bool(strip_all, options::TWO_DASHES, 's', false,
1207*fae548d3Szrj 	      N_("Strip all symbols"), NULL);
1208*fae548d3Szrj   DEFINE_bool(strip_debug, options::TWO_DASHES, 'S', false,
1209*fae548d3Szrj 	      N_("Strip debugging information"), NULL);
1210*fae548d3Szrj   DEFINE_bool(strip_debug_non_line, options::TWO_DASHES, '\0', false,
1211*fae548d3Szrj 	      N_("Emit only debug line number information"), NULL);
1212*fae548d3Szrj   DEFINE_bool(strip_debug_gdb, options::TWO_DASHES, '\0', false,
1213*fae548d3Szrj 	      N_("Strip debug symbols that are unused by gdb "
1214*fae548d3Szrj 		 "(at least versions <= 7.4)"), NULL);
1215*fae548d3Szrj   DEFINE_bool(strip_lto_sections, options::TWO_DASHES, '\0', true,
1216*fae548d3Szrj 	      N_("Strip LTO intermediate code sections"), NULL);
1217*fae548d3Szrj 
1218*fae548d3Szrj   DEFINE_string(section_ordering_file, options::TWO_DASHES, '\0', NULL,
1219*fae548d3Szrj 		N_("Layout sections in the order specified"),
1220*fae548d3Szrj 		N_("FILENAME"));
1221*fae548d3Szrj 
1222*fae548d3Szrj   DEFINE_special(section_start, options::TWO_DASHES, '\0',
1223*fae548d3Szrj 		 N_("Set address of section"), N_("SECTION=ADDRESS"));
1224*fae548d3Szrj 
1225*fae548d3Szrj   DEFINE_bool(secure_plt, options::TWO_DASHES , '\0', true,
1226*fae548d3Szrj 	      N_("(PowerPC only) Use new-style PLT"), NULL);
1227*fae548d3Szrj 
1228*fae548d3Szrj   DEFINE_optional_string(sort_common, options::TWO_DASHES, '\0', NULL,
1229*fae548d3Szrj 			 N_("Sort common symbols by alignment"),
1230*fae548d3Szrj 			 N_("[={ascending,descending}]"));
1231*fae548d3Szrj 
1232*fae548d3Szrj   DEFINE_enum(sort_section, options::TWO_DASHES, '\0', "none",
1233*fae548d3Szrj 	      N_("Sort sections by name.  \'--no-text-reorder\'"
1234*fae548d3Szrj 		 " will override \'--sort-section=name\' for .text"),
1235*fae548d3Szrj 	      N_("[none,name]"),
1236*fae548d3Szrj 	      {"none", "name"});
1237*fae548d3Szrj 
1238*fae548d3Szrj   DEFINE_uint(spare_dynamic_tags, options::TWO_DASHES, '\0', 5,
1239*fae548d3Szrj 	      N_("Dynamic tag slots to reserve (default 5)"),
1240*fae548d3Szrj 	      N_("COUNT"));
1241*fae548d3Szrj 
1242*fae548d3Szrj   DEFINE_int(stub_group_size, options::TWO_DASHES , '\0', 1,
1243*fae548d3Szrj 	     N_("(ARM, PowerPC only) The maximum distance from instructions "
1244*fae548d3Szrj 		"in a group of sections to their stubs. Negative values mean "
1245*fae548d3Szrj 		"stubs are always after the group. 1 means use default size"),
1246*fae548d3Szrj 	     N_("SIZE"));
1247*fae548d3Szrj 
1248*fae548d3Szrj   DEFINE_bool(stub_group_multi, options::TWO_DASHES, '\0', true,
1249*fae548d3Szrj 	      N_("(PowerPC only) Allow a group of stubs to serve multiple "
1250*fae548d3Szrj 		 "output sections"),
1251*fae548d3Szrj 	      N_("(PowerPC only) Each output section has its own stubs"));
1252*fae548d3Szrj 
1253*fae548d3Szrj   DEFINE_uint(split_stack_adjust_size, options::TWO_DASHES, '\0', 0x4000,
1254*fae548d3Szrj 	      N_("Stack size when -fsplit-stack function calls non-split"),
1255*fae548d3Szrj 	      N_("SIZE"));
1256*fae548d3Szrj 
1257*fae548d3Szrj   // This is not actually special in any way, but I need to give it
1258*fae548d3Szrj   // a non-standard accessor-function name because 'static' is a keyword.
1259*fae548d3Szrj   DEFINE_special(static, options::ONE_DASH, '\0',
1260*fae548d3Szrj 		 N_("Do not link against shared libraries"), NULL);
1261*fae548d3Szrj 
1262*fae548d3Szrj   DEFINE_special(start_lib, options::TWO_DASHES, '\0',
1263*fae548d3Szrj 		 N_("Start a library"), NULL);
1264*fae548d3Szrj   DEFINE_special(end_lib, options::TWO_DASHES, '\0',
1265*fae548d3Szrj 		 N_("End a library "), NULL);
1266*fae548d3Szrj 
1267*fae548d3Szrj   DEFINE_bool(stats, options::TWO_DASHES, '\0', false,
1268*fae548d3Szrj 	      N_("Print resource usage statistics"), NULL);
1269*fae548d3Szrj 
1270*fae548d3Szrj   DEFINE_string(sysroot, options::TWO_DASHES, '\0', "",
1271*fae548d3Szrj 		N_("Set target system root directory"), N_("DIR"));
1272*fae548d3Szrj 
1273*fae548d3Szrj   // t
1274*fae548d3Szrj 
1275*fae548d3Szrj   DEFINE_bool(trace, options::TWO_DASHES, 't', false,
1276*fae548d3Szrj 	      N_("Print the name of each input file"), NULL);
1277*fae548d3Szrj 
1278*fae548d3Szrj   DEFINE_bool(target1_abs, options::TWO_DASHES, '\0', false,
1279*fae548d3Szrj 	      N_("(ARM only) Force R_ARM_TARGET1 type to R_ARM_ABS32"),
1280*fae548d3Szrj 	      NULL);
1281*fae548d3Szrj   DEFINE_bool(target1_rel, options::TWO_DASHES, '\0', false,
1282*fae548d3Szrj 	      N_("(ARM only) Force R_ARM_TARGET1 type to R_ARM_REL32"),
1283*fae548d3Szrj 	      NULL);
1284*fae548d3Szrj   DEFINE_enum(target2, options::TWO_DASHES, '\0', NULL,
1285*fae548d3Szrj 	      N_("(ARM only) Set R_ARM_TARGET2 relocation type"),
1286*fae548d3Szrj 	      N_("[rel, abs, got-rel"),
1287*fae548d3Szrj 	      {"rel", "abs", "got-rel"});
1288*fae548d3Szrj 
1289*fae548d3Szrj   DEFINE_bool(text_reorder, options::TWO_DASHES, '\0', true,
1290*fae548d3Szrj 	      N_("Enable text section reordering for GCC section names"),
1291*fae548d3Szrj 	      N_("Disable text section reordering for GCC section names"));
1292*fae548d3Szrj 
1293*fae548d3Szrj   DEFINE_bool(threads, options::TWO_DASHES, '\0', false,
1294*fae548d3Szrj 	      N_("Run the linker multi-threaded"),
1295*fae548d3Szrj 	      N_("Do not run the linker multi-threaded"));
1296*fae548d3Szrj   DEFINE_uint(thread_count, options::TWO_DASHES, '\0', 0,
1297*fae548d3Szrj 	      N_("Number of threads to use"), N_("COUNT"));
1298*fae548d3Szrj   DEFINE_uint(thread_count_initial, options::TWO_DASHES, '\0', 0,
1299*fae548d3Szrj 	      N_("Number of threads to use in initial pass"), N_("COUNT"));
1300*fae548d3Szrj   DEFINE_uint(thread_count_middle, options::TWO_DASHES, '\0', 0,
1301*fae548d3Szrj 	      N_("Number of threads to use in middle pass"), N_("COUNT"));
1302*fae548d3Szrj   DEFINE_uint(thread_count_final, options::TWO_DASHES, '\0', 0,
1303*fae548d3Szrj 	      N_("Number of threads to use in final pass"), N_("COUNT"));
1304*fae548d3Szrj 
1305*fae548d3Szrj   DEFINE_bool(tls_optimize, options::TWO_DASHES, '\0', true,
1306*fae548d3Szrj 	      N_("(PowerPC/64 only) Optimize GD/LD/IE code to IE/LE"),
1307*fae548d3Szrj 	      N_("(PowerPC/64 only) Don'\''t try to optimize TLS accesses"));
1308*fae548d3Szrj   DEFINE_bool(tls_get_addr_optimize, options::TWO_DASHES, '\0', true,
1309*fae548d3Szrj 	      N_("(PowerPC/64 only) Use a special __tls_get_addr call"),
1310*fae548d3Szrj 	      N_("(PowerPC/64 only) Don't use a special __tls_get_addr call"));
1311*fae548d3Szrj 
1312*fae548d3Szrj   DEFINE_bool(toc_optimize, options::TWO_DASHES, '\0', true,
1313*fae548d3Szrj 	      N_("(PowerPC64 only) Optimize TOC code sequences"),
1314*fae548d3Szrj 	      N_("(PowerPC64 only) Don't optimize TOC code sequences"));
1315*fae548d3Szrj 
1316*fae548d3Szrj   DEFINE_bool(toc_sort, options::TWO_DASHES, '\0', true,
1317*fae548d3Szrj 	      N_("(PowerPC64 only) Sort TOC and GOT sections"),
1318*fae548d3Szrj 	      N_("(PowerPC64 only) Don't sort TOC and GOT sections"));
1319*fae548d3Szrj 
1320*fae548d3Szrj   DEFINE_special(script, options::TWO_DASHES, 'T',
1321*fae548d3Szrj 		 N_("Read linker script"), N_("FILE"));
1322*fae548d3Szrj 
1323*fae548d3Szrj   DEFINE_uint64(Tbss, options::ONE_DASH, '\0', -1U,
1324*fae548d3Szrj 		N_("Set the address of the bss segment"), N_("ADDRESS"));
1325*fae548d3Szrj   DEFINE_uint64(Tdata, options::ONE_DASH, '\0', -1U,
1326*fae548d3Szrj 		N_("Set the address of the data segment"), N_("ADDRESS"));
1327*fae548d3Szrj   DEFINE_uint64(Ttext, options::ONE_DASH, '\0', -1U,
1328*fae548d3Szrj 		N_("Set the address of the text segment"), N_("ADDRESS"));
1329*fae548d3Szrj   DEFINE_uint64_alias(Ttext_segment, Ttext, options::ONE_DASH, '\0',
1330*fae548d3Szrj 		      N_("Set the address of the text segment"),
1331*fae548d3Szrj 		      N_("ADDRESS"));
1332*fae548d3Szrj   DEFINE_uint64(Trodata_segment, options::ONE_DASH, '\0', -1U,
1333*fae548d3Szrj 		N_("Set the address of the rodata segment"), N_("ADDRESS"));
1334*fae548d3Szrj 
1335*fae548d3Szrj   // u
1336*fae548d3Szrj 
1337*fae548d3Szrj   DEFINE_set(undefined, options::TWO_DASHES, 'u',
1338*fae548d3Szrj 	     N_("Create undefined reference to SYMBOL"), N_("SYMBOL"));
1339*fae548d3Szrj 
1340*fae548d3Szrj   DEFINE_enum(unresolved_symbols, options::TWO_DASHES, '\0', NULL,
1341*fae548d3Szrj 	      N_("How to handle unresolved symbols"),
1342*fae548d3Szrj 	      ("ignore-all,report-all,ignore-in-object-files,"
1343*fae548d3Szrj 	       "ignore-in-shared-libs"),
1344*fae548d3Szrj 	      {"ignore-all", "report-all", "ignore-in-object-files",
1345*fae548d3Szrj 		  "ignore-in-shared-libs"});
1346*fae548d3Szrj 
1347*fae548d3Szrj   // v
1348*fae548d3Szrj 
1349*fae548d3Szrj   DEFINE_bool(verbose, options::TWO_DASHES, '\0', false,
1350*fae548d3Szrj 	      N_("Alias for --debug=files"), NULL);
1351*fae548d3Szrj 
1352*fae548d3Szrj   DEFINE_special(version_script, options::TWO_DASHES, '\0',
1353*fae548d3Szrj 		 N_("Read version script"), N_("FILE"));
1354*fae548d3Szrj 
1355*fae548d3Szrj   // w
1356*fae548d3Szrj 
1357*fae548d3Szrj   DEFINE_bool(warn_common, options::TWO_DASHES, '\0', false,
1358*fae548d3Szrj 	      N_("Warn about duplicate common symbols"),
1359*fae548d3Szrj 	      N_("Do not warn about duplicate common symbols"));
1360*fae548d3Szrj 
1361*fae548d3Szrj   DEFINE_bool_ignore(warn_constructors, options::TWO_DASHES, '\0',
1362*fae548d3Szrj 		     N_("Ignored"), N_("Ignored"));
1363*fae548d3Szrj 
1364*fae548d3Szrj   DEFINE_bool(warn_drop_version, options::TWO_DASHES, '\0', false,
1365*fae548d3Szrj 	      N_("Warn when discarding version information"),
1366*fae548d3Szrj 	      N_("Do not warn when discarding version information"));
1367*fae548d3Szrj 
1368*fae548d3Szrj   DEFINE_bool(warn_execstack, options::TWO_DASHES, '\0', false,
1369*fae548d3Szrj 	      N_("Warn if the stack is executable"),
1370*fae548d3Szrj 	      N_("Do not warn if the stack is executable"));
1371*fae548d3Szrj 
1372*fae548d3Szrj   DEFINE_bool(warn_mismatch, options::TWO_DASHES, '\0', true,
1373*fae548d3Szrj 	      NULL, N_("Don't warn about mismatched input files"));
1374*fae548d3Szrj 
1375*fae548d3Szrj   DEFINE_bool(warn_multiple_gp, options::TWO_DASHES, '\0', false,
1376*fae548d3Szrj 	      N_("Ignored"), NULL);
1377*fae548d3Szrj 
1378*fae548d3Szrj   DEFINE_bool(warn_search_mismatch, options::TWO_DASHES, '\0', true,
1379*fae548d3Szrj 	      N_("Warn when skipping an incompatible library"),
1380*fae548d3Szrj 	      N_("Don't warn when skipping an incompatible library"));
1381*fae548d3Szrj 
1382*fae548d3Szrj   DEFINE_bool(warn_shared_textrel, options::TWO_DASHES, '\0', false,
1383*fae548d3Szrj 	      N_("Warn if text segment is not shareable"),
1384*fae548d3Szrj 	      N_("Do not warn if text segment is not shareable"));
1385*fae548d3Szrj 
1386*fae548d3Szrj   DEFINE_bool(warn_unresolved_symbols, options::TWO_DASHES, '\0', false,
1387*fae548d3Szrj 	      N_("Report unresolved symbols as warnings"),
1388*fae548d3Szrj 	      NULL);
1389*fae548d3Szrj   DEFINE_bool_alias(error_unresolved_symbols, warn_unresolved_symbols,
1390*fae548d3Szrj 		    options::TWO_DASHES, '\0',
1391*fae548d3Szrj 		    N_("Report unresolved symbols as errors"),
1392*fae548d3Szrj 		    NULL, true);
1393*fae548d3Szrj 
1394*fae548d3Szrj   DEFINE_bool(wchar_size_warning, options::TWO_DASHES, '\0', true, NULL,
1395*fae548d3Szrj 	      N_("(ARM only) Do not warn about objects with incompatible "
1396*fae548d3Szrj 		 "wchar_t sizes"));
1397*fae548d3Szrj 
1398*fae548d3Szrj   DEFINE_bool(weak_unresolved_symbols, options::TWO_DASHES, '\0', false,
1399*fae548d3Szrj 	      N_("Convert unresolved symbols to weak references"),
1400*fae548d3Szrj 	      NULL);
1401*fae548d3Szrj 
1402*fae548d3Szrj   DEFINE_bool(whole_archive, options::TWO_DASHES, '\0', false,
1403*fae548d3Szrj 	      N_("Include all archive contents"),
1404*fae548d3Szrj 	      N_("Include only needed archive contents"));
1405*fae548d3Szrj 
1406*fae548d3Szrj   DEFINE_set(wrap, options::TWO_DASHES, '\0',
1407*fae548d3Szrj 	     N_("Use wrapper functions for SYMBOL"), N_("SYMBOL"));
1408*fae548d3Szrj 
1409*fae548d3Szrj   // x
1410*fae548d3Szrj 
1411*fae548d3Szrj   DEFINE_special(discard_all, options::TWO_DASHES, 'x',
1412*fae548d3Szrj 		 N_("Delete all local symbols"), NULL);
1413*fae548d3Szrj   DEFINE_special(discard_locals, options::TWO_DASHES, 'X',
1414*fae548d3Szrj 		 N_("Delete all temporary local symbols"), NULL);
1415*fae548d3Szrj   DEFINE_special(discard_none, options::TWO_DASHES, '\0',
1416*fae548d3Szrj 		 N_("Keep all local symbols"), NULL);
1417*fae548d3Szrj 
1418*fae548d3Szrj   // y
1419*fae548d3Szrj 
1420*fae548d3Szrj   DEFINE_set(trace_symbol, options::TWO_DASHES, 'y',
1421*fae548d3Szrj 	     N_("Trace references to symbol"), N_("SYMBOL"));
1422*fae548d3Szrj 
1423*fae548d3Szrj   DEFINE_bool(undefined_version, options::TWO_DASHES, '\0', true,
1424*fae548d3Szrj 	      N_("Allow unused version in script"),
1425*fae548d3Szrj 	      N_("Do not allow unused version in script"));
1426*fae548d3Szrj 
1427*fae548d3Szrj   DEFINE_string(Y, options::EXACTLY_ONE_DASH, 'Y', "",
1428*fae548d3Szrj 		N_("Default search path for Solaris compatibility"),
1429*fae548d3Szrj 		N_("PATH"));
1430*fae548d3Szrj 
1431*fae548d3Szrj   // special characters
1432*fae548d3Szrj 
1433*fae548d3Szrj   DEFINE_special(start_group, options::TWO_DASHES, '(',
1434*fae548d3Szrj 		 N_("Start a library search group"), NULL);
1435*fae548d3Szrj   DEFINE_special(end_group, options::TWO_DASHES, ')',
1436*fae548d3Szrj 		 N_("End a library search group"), NULL);
1437*fae548d3Szrj 
1438*fae548d3Szrj   // The -z options.
1439*fae548d3Szrj 
1440*fae548d3Szrj   DEFINE_bool(bndplt, options::DASH_Z, '\0', false,
1441*fae548d3Szrj 	      N_("(x86-64 only) Generate a BND PLT for Intel MPX"),
1442*fae548d3Szrj 	      N_("Generate a regular PLT"));
1443*fae548d3Szrj   DEFINE_bool(combreloc, options::DASH_Z, '\0', true,
1444*fae548d3Szrj 	      N_("Sort dynamic relocs"),
1445*fae548d3Szrj 	      N_("Do not sort dynamic relocs"));
1446*fae548d3Szrj   DEFINE_uint64(common_page_size, options::DASH_Z, '\0', 0,
1447*fae548d3Szrj 		N_("Set common page size to SIZE"), N_("SIZE"));
1448*fae548d3Szrj   DEFINE_bool(defs, options::DASH_Z, '\0', false,
1449*fae548d3Szrj 	      N_("Report undefined symbols (even with --shared)"),
1450*fae548d3Szrj 	      NULL);
1451*fae548d3Szrj   DEFINE_bool(execstack, options::DASH_Z, '\0', false,
1452*fae548d3Szrj 	      N_("Mark output as requiring executable stack"), NULL);
1453*fae548d3Szrj   DEFINE_bool(global, options::DASH_Z, '\0', false,
1454*fae548d3Szrj 	      N_("Make symbols in DSO available for subsequently loaded "
1455*fae548d3Szrj 		 "objects"), NULL);
1456*fae548d3Szrj   DEFINE_bool(initfirst, options::DASH_Z, '\0', false,
1457*fae548d3Szrj 	      N_("Mark DSO to be initialized first at runtime"),
1458*fae548d3Szrj 	      NULL);
1459*fae548d3Szrj   DEFINE_bool(interpose, options::DASH_Z, '\0', false,
1460*fae548d3Szrj 	      N_("Mark object to interpose all DSOs but executable"),
1461*fae548d3Szrj 	      NULL);
1462*fae548d3Szrj   DEFINE_bool_alias(lazy, now, options::DASH_Z, '\0',
1463*fae548d3Szrj 		    N_("Mark object for lazy runtime binding"),
1464*fae548d3Szrj 		    NULL, true);
1465*fae548d3Szrj   DEFINE_bool(loadfltr, options::DASH_Z, '\0', false,
1466*fae548d3Szrj 	      N_("Mark object requiring immediate process"),
1467*fae548d3Szrj 	      NULL);
1468*fae548d3Szrj   DEFINE_uint64(max_page_size, options::DASH_Z, '\0', 0,
1469*fae548d3Szrj 		N_("Set maximum page size to SIZE"), N_("SIZE"));
1470*fae548d3Szrj   DEFINE_bool(muldefs, options::DASH_Z, '\0', false,
1471*fae548d3Szrj 	      N_("Allow multiple definitions of symbols"),
1472*fae548d3Szrj 	      NULL);
1473*fae548d3Szrj   // copyreloc is here in the list because there is only -z
1474*fae548d3Szrj   // nocopyreloc, not -z copyreloc.
1475*fae548d3Szrj   DEFINE_bool(copyreloc, options::DASH_Z, '\0', true,
1476*fae548d3Szrj 	      NULL,
1477*fae548d3Szrj 	      N_("Do not create copy relocs"));
1478*fae548d3Szrj   DEFINE_bool(nodefaultlib, options::DASH_Z, '\0', false,
1479*fae548d3Szrj 	      N_("Mark object not to use default search paths"),
1480*fae548d3Szrj 	      NULL);
1481*fae548d3Szrj   DEFINE_bool(nodelete, options::DASH_Z, '\0', false,
1482*fae548d3Szrj 	      N_("Mark DSO non-deletable at runtime"),
1483*fae548d3Szrj 	      NULL);
1484*fae548d3Szrj   DEFINE_bool(nodlopen, options::DASH_Z, '\0', false,
1485*fae548d3Szrj 	      N_("Mark DSO not available to dlopen"),
1486*fae548d3Szrj 	      NULL);
1487*fae548d3Szrj   DEFINE_bool(nodump, options::DASH_Z, '\0', false,
1488*fae548d3Szrj 	      N_("Mark DSO not available to dldump"),
1489*fae548d3Szrj 	      NULL);
1490*fae548d3Szrj   DEFINE_bool(noexecstack, options::DASH_Z, '\0', false,
1491*fae548d3Szrj 	      N_("Mark output as not requiring executable stack"), NULL);
1492*fae548d3Szrj   DEFINE_bool(now, options::DASH_Z, '\0', false,
1493*fae548d3Szrj 	      N_("Mark object for immediate function binding"),
1494*fae548d3Szrj 	      NULL);
1495*fae548d3Szrj   DEFINE_bool(origin, options::DASH_Z, '\0', false,
1496*fae548d3Szrj 	      N_("Mark DSO to indicate that needs immediate $ORIGIN "
1497*fae548d3Szrj 		 "processing at runtime"), NULL);
1498*fae548d3Szrj   DEFINE_bool(relro, options::DASH_Z, '\0', DEFAULT_LD_Z_RELRO,
1499*fae548d3Szrj 	      N_("Where possible mark variables read-only after relocation"),
1500*fae548d3Szrj 	      N_("Don't mark variables read-only after relocation"));
1501*fae548d3Szrj   DEFINE_uint64(stack_size, options::DASH_Z, '\0', 0,
1502*fae548d3Szrj 		N_("Set PT_GNU_STACK segment p_memsz to SIZE"), N_("SIZE"));
1503*fae548d3Szrj   DEFINE_bool(text, options::DASH_Z, '\0', false,
1504*fae548d3Szrj 	      N_("Do not permit relocations in read-only segments"),
1505*fae548d3Szrj 	      N_("Permit relocations in read-only segments"));
1506*fae548d3Szrj   DEFINE_bool_alias(textoff, text, options::DASH_Z, '\0',
1507*fae548d3Szrj 		    N_("Permit relocations in read-only segments"),
1508*fae548d3Szrj 		    NULL, true);
1509*fae548d3Szrj   DEFINE_bool(text_unlikely_segment, options::DASH_Z, '\0', false,
1510*fae548d3Szrj 	      N_("Move .text.unlikely sections to a separate segment."),
1511*fae548d3Szrj 	      N_("Do not move .text.unlikely sections to a separate "
1512*fae548d3Szrj 		 "segment."));
1513*fae548d3Szrj   DEFINE_bool(keep_text_section_prefix, options::DASH_Z, '\0', false,
1514*fae548d3Szrj 	      N_("Keep .text.hot, .text.startup, .text.exit and .text.unlikely "
1515*fae548d3Szrj 		 "as separate sections in the final binary."),
1516*fae548d3Szrj 	      N_("Merge all .text.* prefix sections."));
1517*fae548d3Szrj 
1518*fae548d3Szrj 
1519*fae548d3Szrj  public:
1520*fae548d3Szrj   typedef options::Dir_list Dir_list;
1521*fae548d3Szrj 
1522*fae548d3Szrj   General_options();
1523*fae548d3Szrj 
1524*fae548d3Szrj   // Does post-processing on flags, making sure they all have
1525*fae548d3Szrj   // non-conflicting values.  Also converts some flags from their
1526*fae548d3Szrj   // "standard" types (string, etc), to another type (enum, DirList),
1527*fae548d3Szrj   // which can be accessed via a separate method.  Dies if it notices
1528*fae548d3Szrj   // any problems.
1529*fae548d3Szrj   void finalize();
1530*fae548d3Szrj 
1531*fae548d3Szrj   // True if we printed the version information.
1532*fae548d3Szrj   bool
printed_version()1533*fae548d3Szrj   printed_version() const
1534*fae548d3Szrj   { return this->printed_version_; }
1535*fae548d3Szrj 
1536*fae548d3Szrj   // The macro defines output() (based on --output), but that's a
1537*fae548d3Szrj   // generic name.  Provide this alternative name, which is clearer.
1538*fae548d3Szrj   const char*
output_file_name()1539*fae548d3Szrj   output_file_name() const
1540*fae548d3Szrj   { return this->output(); }
1541*fae548d3Szrj 
1542*fae548d3Szrj   // This is not defined via a flag, but combines flags to say whether
1543*fae548d3Szrj   // the output is position-independent or not.
1544*fae548d3Szrj   bool
output_is_position_independent()1545*fae548d3Szrj   output_is_position_independent() const
1546*fae548d3Szrj   { return this->shared() || this->pie(); }
1547*fae548d3Szrj 
1548*fae548d3Szrj   // Return true if the output is something that can be exec()ed, such
1549*fae548d3Szrj   // as a static executable, or a position-dependent or
1550*fae548d3Szrj   // position-independent executable, but not a dynamic library or an
1551*fae548d3Szrj   // object file.
1552*fae548d3Szrj   bool
output_is_executable()1553*fae548d3Szrj   output_is_executable() const
1554*fae548d3Szrj   { return !this->shared() && !this->relocatable(); }
1555*fae548d3Szrj 
1556*fae548d3Szrj   // This would normally be static(), and defined automatically, but
1557*fae548d3Szrj   // since static is a keyword, we need to come up with our own name.
1558*fae548d3Szrj   bool
is_static()1559*fae548d3Szrj   is_static() const
1560*fae548d3Szrj   { return static_; }
1561*fae548d3Szrj 
1562*fae548d3Szrj   // In addition to getting the input and output formats as a string
1563*fae548d3Szrj   // (via format() and oformat()), we also give access as an enum.
1564*fae548d3Szrj   enum Object_format
1565*fae548d3Szrj   {
1566*fae548d3Szrj     // Ordinary ELF.
1567*fae548d3Szrj     OBJECT_FORMAT_ELF,
1568*fae548d3Szrj     // Straight binary format.
1569*fae548d3Szrj     OBJECT_FORMAT_BINARY
1570*fae548d3Szrj   };
1571*fae548d3Szrj 
1572*fae548d3Szrj   // Convert a string to an Object_format.  Gives an error if the
1573*fae548d3Szrj   // string is not recognized.
1574*fae548d3Szrj   static Object_format
1575*fae548d3Szrj   string_to_object_format(const char* arg);
1576*fae548d3Szrj 
1577*fae548d3Szrj   // Convert an Object_format to string.
1578*fae548d3Szrj   static const char*
1579*fae548d3Szrj   object_format_to_string(Object_format);
1580*fae548d3Szrj 
1581*fae548d3Szrj   // Note: these functions are not very fast.
1582*fae548d3Szrj   Object_format format_enum() const;
1583*fae548d3Szrj   Object_format oformat_enum() const;
1584*fae548d3Szrj 
1585*fae548d3Szrj   // Return whether FILENAME is in a system directory.
1586*fae548d3Szrj   bool
1587*fae548d3Szrj   is_in_system_directory(const std::string& name) const;
1588*fae548d3Szrj 
1589*fae548d3Szrj   // RETURN whether SYMBOL_NAME should be kept, according to symbols_to_retain_.
1590*fae548d3Szrj   bool
should_retain_symbol(const char * symbol_name)1591*fae548d3Szrj   should_retain_symbol(const char* symbol_name) const
1592*fae548d3Szrj     {
1593*fae548d3Szrj       if (symbols_to_retain_.empty())    // means flag wasn't specified
1594*fae548d3Szrj 	return true;
1595*fae548d3Szrj       return symbols_to_retain_.find(symbol_name) != symbols_to_retain_.end();
1596*fae548d3Szrj     }
1597*fae548d3Szrj 
1598*fae548d3Szrj   // These are the best way to get access to the execstack state,
1599*fae548d3Szrj   // not execstack() and noexecstack() which are hard to use properly.
1600*fae548d3Szrj   bool
is_execstack_set()1601*fae548d3Szrj   is_execstack_set() const
1602*fae548d3Szrj   { return this->execstack_status_ != EXECSTACK_FROM_INPUT; }
1603*fae548d3Szrj 
1604*fae548d3Szrj   bool
is_stack_executable()1605*fae548d3Szrj   is_stack_executable() const
1606*fae548d3Szrj   { return this->execstack_status_ == EXECSTACK_YES; }
1607*fae548d3Szrj 
1608*fae548d3Szrj   bool
icf_enabled()1609*fae548d3Szrj   icf_enabled() const
1610*fae548d3Szrj   { return this->icf_status_ != ICF_NONE; }
1611*fae548d3Szrj 
1612*fae548d3Szrj   bool
icf_safe_folding()1613*fae548d3Szrj   icf_safe_folding() const
1614*fae548d3Szrj   { return this->icf_status_ == ICF_SAFE; }
1615*fae548d3Szrj 
1616*fae548d3Szrj   // The --demangle option takes an optional string, and there is also
1617*fae548d3Szrj   // a --no-demangle option.  This is the best way to decide whether
1618*fae548d3Szrj   // to demangle or not.
1619*fae548d3Szrj   bool
do_demangle()1620*fae548d3Szrj   do_demangle() const
1621*fae548d3Szrj   { return this->do_demangle_; }
1622*fae548d3Szrj 
1623*fae548d3Szrj   // Returns TRUE if any plugin libraries have been loaded.
1624*fae548d3Szrj   bool
has_plugins()1625*fae548d3Szrj   has_plugins() const
1626*fae548d3Szrj   { return this->plugins_ != NULL; }
1627*fae548d3Szrj 
1628*fae548d3Szrj   // Return a pointer to the plugin manager.
1629*fae548d3Szrj   Plugin_manager*
plugins()1630*fae548d3Szrj   plugins() const
1631*fae548d3Szrj   { return this->plugins_; }
1632*fae548d3Szrj 
1633*fae548d3Szrj   // True iff SYMBOL was found in the file specified by dynamic-list.
1634*fae548d3Szrj   bool
in_dynamic_list(const char * symbol)1635*fae548d3Szrj   in_dynamic_list(const char* symbol) const
1636*fae548d3Szrj   { return this->dynamic_list_.version_script_info()->symbol_is_local(symbol); }
1637*fae548d3Szrj 
1638*fae548d3Szrj   // True if a --dynamic-list script was provided.
1639*fae548d3Szrj   bool
have_dynamic_list()1640*fae548d3Szrj   have_dynamic_list() const
1641*fae548d3Szrj   { return this->have_dynamic_list_; }
1642*fae548d3Szrj 
1643*fae548d3Szrj   // Finalize the dynamic list.
1644*fae548d3Szrj   void
finalize_dynamic_list()1645*fae548d3Szrj   finalize_dynamic_list()
1646*fae548d3Szrj   { this->dynamic_list_.version_script_info()->finalize(); }
1647*fae548d3Szrj 
1648*fae548d3Szrj   // The mode selected by the --incremental options.
1649*fae548d3Szrj   enum Incremental_mode
1650*fae548d3Szrj   {
1651*fae548d3Szrj     // No incremental linking (--no-incremental).
1652*fae548d3Szrj     INCREMENTAL_OFF,
1653*fae548d3Szrj     // Incremental update only (--incremental-update).
1654*fae548d3Szrj     INCREMENTAL_UPDATE,
1655*fae548d3Szrj     // Force a full link, but prepare for subsequent incremental link
1656*fae548d3Szrj     // (--incremental-full).
1657*fae548d3Szrj     INCREMENTAL_FULL,
1658*fae548d3Szrj     // Incremental update if possible, fallback to full link  (--incremental).
1659*fae548d3Szrj     INCREMENTAL_AUTO
1660*fae548d3Szrj   };
1661*fae548d3Szrj 
1662*fae548d3Szrj   // The incremental linking mode.
1663*fae548d3Szrj   Incremental_mode
incremental_mode()1664*fae548d3Szrj   incremental_mode() const
1665*fae548d3Szrj   { return this->incremental_mode_; }
1666*fae548d3Szrj 
1667*fae548d3Szrj   // The disposition given by the --incremental-changed,
1668*fae548d3Szrj   // --incremental-unchanged or --incremental-unknown option.  The
1669*fae548d3Szrj   // value may change as we proceed parsing the command line flags.
1670*fae548d3Szrj   Incremental_disposition
incremental_disposition()1671*fae548d3Szrj   incremental_disposition() const
1672*fae548d3Szrj   { return this->incremental_disposition_; }
1673*fae548d3Szrj 
1674*fae548d3Szrj   void
set_incremental_disposition(Incremental_disposition disp)1675*fae548d3Szrj   set_incremental_disposition(Incremental_disposition disp)
1676*fae548d3Szrj   { this->incremental_disposition_ = disp; }
1677*fae548d3Szrj 
1678*fae548d3Szrj   // The disposition to use for startup files (those that precede the
1679*fae548d3Szrj   // first --incremental-changed, etc. option).
1680*fae548d3Szrj   Incremental_disposition
incremental_startup_disposition()1681*fae548d3Szrj   incremental_startup_disposition() const
1682*fae548d3Szrj   { return this->incremental_startup_disposition_; }
1683*fae548d3Szrj 
1684*fae548d3Szrj   // Return true if S is the name of a library excluded from automatic
1685*fae548d3Szrj   // symbol export.
1686*fae548d3Szrj   bool
1687*fae548d3Szrj   check_excluded_libs(const std::string &s) const;
1688*fae548d3Szrj 
1689*fae548d3Szrj   // If an explicit start address was given for section SECNAME with
1690*fae548d3Szrj   // the --section-start option, return true and set *PADDR to the
1691*fae548d3Szrj   // address.  Otherwise return false.
1692*fae548d3Szrj   bool
1693*fae548d3Szrj   section_start(const char* secname, uint64_t* paddr) const;
1694*fae548d3Szrj 
1695*fae548d3Szrj   // Return whether any --section-start option was used.
1696*fae548d3Szrj   bool
any_section_start()1697*fae548d3Szrj   any_section_start() const
1698*fae548d3Szrj   { return !this->section_starts_.empty(); }
1699*fae548d3Szrj 
1700*fae548d3Szrj   enum Fix_v4bx
1701*fae548d3Szrj   {
1702*fae548d3Szrj     // Leave original instruction.
1703*fae548d3Szrj     FIX_V4BX_NONE,
1704*fae548d3Szrj     // Replace instruction.
1705*fae548d3Szrj     FIX_V4BX_REPLACE,
1706*fae548d3Szrj     // Generate an interworking veneer.
1707*fae548d3Szrj     FIX_V4BX_INTERWORKING
1708*fae548d3Szrj   };
1709*fae548d3Szrj 
1710*fae548d3Szrj   Fix_v4bx
fix_v4bx()1711*fae548d3Szrj   fix_v4bx() const
1712*fae548d3Szrj   { return (this->fix_v4bx_); }
1713*fae548d3Szrj 
1714*fae548d3Szrj   enum Endianness
1715*fae548d3Szrj   {
1716*fae548d3Szrj     ENDIANNESS_NOT_SET,
1717*fae548d3Szrj     ENDIANNESS_BIG,
1718*fae548d3Szrj     ENDIANNESS_LITTLE
1719*fae548d3Szrj   };
1720*fae548d3Szrj 
1721*fae548d3Szrj   Endianness
endianness()1722*fae548d3Szrj   endianness() const
1723*fae548d3Szrj   { return this->endianness_; }
1724*fae548d3Szrj 
1725*fae548d3Szrj   bool
discard_all()1726*fae548d3Szrj   discard_all() const
1727*fae548d3Szrj   { return this->discard_locals_ == DISCARD_ALL; }
1728*fae548d3Szrj 
1729*fae548d3Szrj   bool
discard_locals()1730*fae548d3Szrj   discard_locals() const
1731*fae548d3Szrj   { return this->discard_locals_ == DISCARD_LOCALS; }
1732*fae548d3Szrj 
1733*fae548d3Szrj   bool
discard_sec_merge()1734*fae548d3Szrj   discard_sec_merge() const
1735*fae548d3Szrj   { return this->discard_locals_ == DISCARD_SEC_MERGE; }
1736*fae548d3Szrj 
1737*fae548d3Szrj   enum Orphan_handling
1738*fae548d3Szrj   {
1739*fae548d3Szrj     // Place orphan sections normally (default).
1740*fae548d3Szrj     ORPHAN_PLACE,
1741*fae548d3Szrj     // Discard all orphan sections.
1742*fae548d3Szrj     ORPHAN_DISCARD,
1743*fae548d3Szrj     // Warn when placing orphan sections.
1744*fae548d3Szrj     ORPHAN_WARN,
1745*fae548d3Szrj     // Issue error for orphan sections.
1746*fae548d3Szrj     ORPHAN_ERROR
1747*fae548d3Szrj   };
1748*fae548d3Szrj 
1749*fae548d3Szrj   Orphan_handling
orphan_handling_enum()1750*fae548d3Szrj   orphan_handling_enum() const
1751*fae548d3Szrj   { return this->orphan_handling_enum_; }
1752*fae548d3Szrj 
1753*fae548d3Szrj  private:
1754*fae548d3Szrj   // Don't copy this structure.
1755*fae548d3Szrj   General_options(const General_options&);
1756*fae548d3Szrj   General_options& operator=(const General_options&);
1757*fae548d3Szrj 
1758*fae548d3Szrj   // What local symbols to discard.
1759*fae548d3Szrj   enum Discard_locals
1760*fae548d3Szrj   {
1761*fae548d3Szrj     // Locals in merge sections (default).
1762*fae548d3Szrj     DISCARD_SEC_MERGE,
1763*fae548d3Szrj     // None (--discard-none).
1764*fae548d3Szrj     DISCARD_NONE,
1765*fae548d3Szrj     // Temporary locals (--discard-locals/-X).
1766*fae548d3Szrj     DISCARD_LOCALS,
1767*fae548d3Szrj     // All locals (--discard-all/-x).
1768*fae548d3Szrj     DISCARD_ALL
1769*fae548d3Szrj   };
1770*fae548d3Szrj 
1771*fae548d3Szrj   // Whether to mark the stack as executable.
1772*fae548d3Szrj   enum Execstack
1773*fae548d3Szrj   {
1774*fae548d3Szrj     // Not set on command line.
1775*fae548d3Szrj     EXECSTACK_FROM_INPUT,
1776*fae548d3Szrj     // Mark the stack as executable (-z execstack).
1777*fae548d3Szrj     EXECSTACK_YES,
1778*fae548d3Szrj     // Mark the stack as not executable (-z noexecstack).
1779*fae548d3Szrj     EXECSTACK_NO
1780*fae548d3Szrj   };
1781*fae548d3Szrj 
1782*fae548d3Szrj   enum Icf_status
1783*fae548d3Szrj   {
1784*fae548d3Szrj     // Do not fold any functions (Default or --icf=none).
1785*fae548d3Szrj     ICF_NONE,
1786*fae548d3Szrj     // All functions are candidates for folding. (--icf=all).
1787*fae548d3Szrj     ICF_ALL,
1788*fae548d3Szrj     // Only ctors and dtors are candidates for folding. (--icf=safe).
1789*fae548d3Szrj     ICF_SAFE
1790*fae548d3Szrj   };
1791*fae548d3Szrj 
1792*fae548d3Szrj   void
set_icf_status(Icf_status value)1793*fae548d3Szrj   set_icf_status(Icf_status value)
1794*fae548d3Szrj   { this->icf_status_ = value; }
1795*fae548d3Szrj 
1796*fae548d3Szrj   void
set_execstack_status(Execstack value)1797*fae548d3Szrj   set_execstack_status(Execstack value)
1798*fae548d3Szrj   { this->execstack_status_ = value; }
1799*fae548d3Szrj 
1800*fae548d3Szrj   void
set_do_demangle(bool value)1801*fae548d3Szrj   set_do_demangle(bool value)
1802*fae548d3Szrj   { this->do_demangle_ = value; }
1803*fae548d3Szrj 
1804*fae548d3Szrj   void
set_static(bool value)1805*fae548d3Szrj   set_static(bool value)
1806*fae548d3Szrj   { static_ = value; }
1807*fae548d3Szrj 
1808*fae548d3Szrj   void
set_orphan_handling_enum(Orphan_handling value)1809*fae548d3Szrj   set_orphan_handling_enum(Orphan_handling value)
1810*fae548d3Szrj   { this->orphan_handling_enum_ = value; }
1811*fae548d3Szrj 
1812*fae548d3Szrj   // These are called by finalize() to set up the search-path correctly.
1813*fae548d3Szrj   void
add_to_library_path_with_sysroot(const std::string & arg)1814*fae548d3Szrj   add_to_library_path_with_sysroot(const std::string& arg)
1815*fae548d3Szrj   { this->add_search_directory_to_library_path(Search_directory(arg, true)); }
1816*fae548d3Szrj 
1817*fae548d3Szrj   // Apply any sysroot to the directory lists.
1818*fae548d3Szrj   void
1819*fae548d3Szrj   add_sysroot();
1820*fae548d3Szrj 
1821*fae548d3Szrj   // Add a plugin and its arguments to the list of plugins.
1822*fae548d3Szrj   void
1823*fae548d3Szrj   add_plugin(const char* filename);
1824*fae548d3Szrj 
1825*fae548d3Szrj   // Add a plugin option.
1826*fae548d3Szrj   void
1827*fae548d3Szrj   add_plugin_option(const char* opt);
1828*fae548d3Szrj 
1829*fae548d3Szrj   void
1830*fae548d3Szrj   copy_from_posdep_options(const Position_dependent_options&);
1831*fae548d3Szrj 
1832*fae548d3Szrj   // Whether we printed version information.
1833*fae548d3Szrj   bool printed_version_;
1834*fae548d3Szrj   // Whether to mark the stack as executable.
1835*fae548d3Szrj   Execstack execstack_status_;
1836*fae548d3Szrj   // Whether to do code folding.
1837*fae548d3Szrj   Icf_status icf_status_;
1838*fae548d3Szrj   // Whether to do a static link.
1839*fae548d3Szrj   bool static_;
1840*fae548d3Szrj   // Whether to do demangling.
1841*fae548d3Szrj   bool do_demangle_;
1842*fae548d3Szrj   // List of plugin libraries.
1843*fae548d3Szrj   Plugin_manager* plugins_;
1844*fae548d3Szrj   // The parsed output of --dynamic-list files.  For convenience in
1845*fae548d3Szrj   // script.cc, we store this as a Script_options object, even though
1846*fae548d3Szrj   // we only use a single Version_tree from it.
1847*fae548d3Szrj   Script_options dynamic_list_;
1848*fae548d3Szrj   // Whether a --dynamic-list file was provided.
1849*fae548d3Szrj   bool have_dynamic_list_;
1850*fae548d3Szrj   // The incremental linking mode.
1851*fae548d3Szrj   Incremental_mode incremental_mode_;
1852*fae548d3Szrj   // The disposition given by the --incremental-changed,
1853*fae548d3Szrj   // --incremental-unchanged or --incremental-unknown option.  The
1854*fae548d3Szrj   // value may change as we proceed parsing the command line flags.
1855*fae548d3Szrj   Incremental_disposition incremental_disposition_;
1856*fae548d3Szrj   // The disposition to use for startup files (those marked
1857*fae548d3Szrj   // INCREMENTAL_STARTUP).
1858*fae548d3Szrj   Incremental_disposition incremental_startup_disposition_;
1859*fae548d3Szrj   // Whether we have seen one of the options that require incremental
1860*fae548d3Szrj   // build (--incremental-changed, --incremental-unchanged,
1861*fae548d3Szrj   // --incremental-unknown, or --incremental-startup-unchanged).
1862*fae548d3Szrj   bool implicit_incremental_;
1863*fae548d3Szrj   // Libraries excluded from automatic export, via --exclude-libs.
1864*fae548d3Szrj   Unordered_set<std::string> excluded_libs_;
1865*fae548d3Szrj   // List of symbol-names to keep, via -retain-symbol-info.
1866*fae548d3Szrj   Unordered_set<std::string> symbols_to_retain_;
1867*fae548d3Szrj   // Map from section name to address from --section-start.
1868*fae548d3Szrj   std::map<std::string, uint64_t> section_starts_;
1869*fae548d3Szrj   // Whether to process armv4 bx instruction relocation.
1870*fae548d3Szrj   Fix_v4bx fix_v4bx_;
1871*fae548d3Szrj   // Endianness.
1872*fae548d3Szrj   Endianness endianness_;
1873*fae548d3Szrj   // What local symbols to discard.
1874*fae548d3Szrj   Discard_locals discard_locals_;
1875*fae548d3Szrj   // Stack of saved options for --push-state/--pop-state.
1876*fae548d3Szrj   std::vector<Position_dependent_options*> options_stack_;
1877*fae548d3Szrj   // Orphan handling option, decoded to an enum value.
1878*fae548d3Szrj   Orphan_handling orphan_handling_enum_;
1879*fae548d3Szrj };
1880*fae548d3Szrj 
1881*fae548d3Szrj // The position-dependent options.  We use this to store the state of
1882*fae548d3Szrj // the commandline at a particular point in parsing for later
1883*fae548d3Szrj // reference.  For instance, if we see "ld --whole-archive foo.a
1884*fae548d3Szrj // --no-whole-archive," we want to store the whole-archive option with
1885*fae548d3Szrj // foo.a, so when the time comes to parse foo.a we know we should do
1886*fae548d3Szrj // it in whole-archive mode.  We could store all of General_options,
1887*fae548d3Szrj // but that's big, so we just pick the subset of flags that actually
1888*fae548d3Szrj // change in a position-dependent way.
1889*fae548d3Szrj 
1890*fae548d3Szrj #define DEFINE_posdep(varname__, type__)        \
1891*fae548d3Szrj  public:                                        \
1892*fae548d3Szrj   type__                                        \
1893*fae548d3Szrj   varname__() const                             \
1894*fae548d3Szrj   { return this->varname__##_; }                \
1895*fae548d3Szrj 						\
1896*fae548d3Szrj   void                                          \
1897*fae548d3Szrj   set_##varname__(type__ value)                 \
1898*fae548d3Szrj   { this->varname__##_ = value; }               \
1899*fae548d3Szrj  private:                                       \
1900*fae548d3Szrj   type__ varname__##_
1901*fae548d3Szrj 
1902*fae548d3Szrj class Position_dependent_options
1903*fae548d3Szrj {
1904*fae548d3Szrj  public:
1905*fae548d3Szrj   Position_dependent_options(const General_options& options
1906*fae548d3Szrj 			     = Position_dependent_options::default_options_)
1907*fae548d3Szrj   { copy_from_options(options); }
1908*fae548d3Szrj 
1909*fae548d3Szrj   void
copy_from_options(const General_options & options)1910*fae548d3Szrj   copy_from_options(const General_options& options)
1911*fae548d3Szrj   {
1912*fae548d3Szrj     this->set_as_needed(options.as_needed());
1913*fae548d3Szrj     this->set_Bdynamic(options.Bdynamic());
1914*fae548d3Szrj     this->set_format_enum(options.format_enum());
1915*fae548d3Szrj     this->set_whole_archive(options.whole_archive());
1916*fae548d3Szrj     this->set_incremental_disposition(options.incremental_disposition());
1917*fae548d3Szrj   }
1918*fae548d3Szrj 
1919*fae548d3Szrj   DEFINE_posdep(as_needed, bool);
1920*fae548d3Szrj   DEFINE_posdep(Bdynamic, bool);
1921*fae548d3Szrj   DEFINE_posdep(format_enum, General_options::Object_format);
1922*fae548d3Szrj   DEFINE_posdep(whole_archive, bool);
1923*fae548d3Szrj   DEFINE_posdep(incremental_disposition, Incremental_disposition);
1924*fae548d3Szrj 
1925*fae548d3Szrj  private:
1926*fae548d3Szrj   // This is a General_options with everything set to its default
1927*fae548d3Szrj   // value.  A Position_dependent_options created with no argument
1928*fae548d3Szrj   // will take its values from here.
1929*fae548d3Szrj   static General_options default_options_;
1930*fae548d3Szrj };
1931*fae548d3Szrj 
1932*fae548d3Szrj 
1933*fae548d3Szrj // A single file or library argument from the command line.
1934*fae548d3Szrj 
1935*fae548d3Szrj class Input_file_argument
1936*fae548d3Szrj {
1937*fae548d3Szrj  public:
1938*fae548d3Szrj   enum Input_file_type
1939*fae548d3Szrj   {
1940*fae548d3Szrj     // A regular file, name used as-is, not searched.
1941*fae548d3Szrj     INPUT_FILE_TYPE_FILE,
1942*fae548d3Szrj     // A library name.  When used, "lib" will be prepended and ".so" or
1943*fae548d3Szrj     // ".a" appended to make a filename, and that filename will be searched
1944*fae548d3Szrj     // for using the -L paths.
1945*fae548d3Szrj     INPUT_FILE_TYPE_LIBRARY,
1946*fae548d3Szrj     // A regular file, name used as-is, but searched using the -L paths.
1947*fae548d3Szrj     INPUT_FILE_TYPE_SEARCHED_FILE
1948*fae548d3Szrj   };
1949*fae548d3Szrj 
1950*fae548d3Szrj   // name: file name or library name
1951*fae548d3Szrj   // type: the type of this input file.
1952*fae548d3Szrj   // extra_search_path: an extra directory to look for the file, prior
1953*fae548d3Szrj   //         to checking the normal library search path.  If this is "",
1954*fae548d3Szrj   //         then no extra directory is added.
1955*fae548d3Szrj   // just_symbols: whether this file only defines symbols.
1956*fae548d3Szrj   // options: The position dependent options at this point in the
1957*fae548d3Szrj   //         command line, such as --whole-archive.
Input_file_argument()1958*fae548d3Szrj   Input_file_argument()
1959*fae548d3Szrj     : name_(), type_(INPUT_FILE_TYPE_FILE), extra_search_path_(""),
1960*fae548d3Szrj       just_symbols_(false), options_(), arg_serial_(0)
1961*fae548d3Szrj   { }
1962*fae548d3Szrj 
Input_file_argument(const char * name,Input_file_type type,const char * extra_search_path,bool just_symbols,const Position_dependent_options & options)1963*fae548d3Szrj   Input_file_argument(const char* name, Input_file_type type,
1964*fae548d3Szrj 		      const char* extra_search_path,
1965*fae548d3Szrj 		      bool just_symbols,
1966*fae548d3Szrj 		      const Position_dependent_options& options)
1967*fae548d3Szrj     : name_(name), type_(type), extra_search_path_(extra_search_path),
1968*fae548d3Szrj       just_symbols_(just_symbols), options_(options), arg_serial_(0)
1969*fae548d3Szrj   { }
1970*fae548d3Szrj 
1971*fae548d3Szrj   // You can also pass in a General_options instance instead of a
1972*fae548d3Szrj   // Position_dependent_options.  In that case, we extract the
1973*fae548d3Szrj   // position-independent vars from the General_options and only store
1974*fae548d3Szrj   // those.
Input_file_argument(const char * name,Input_file_type type,const char * extra_search_path,bool just_symbols,const General_options & options)1975*fae548d3Szrj   Input_file_argument(const char* name, Input_file_type type,
1976*fae548d3Szrj 		      const char* extra_search_path,
1977*fae548d3Szrj 		      bool just_symbols,
1978*fae548d3Szrj 		      const General_options& options)
1979*fae548d3Szrj     : name_(name), type_(type), extra_search_path_(extra_search_path),
1980*fae548d3Szrj       just_symbols_(just_symbols), options_(options), arg_serial_(0)
1981*fae548d3Szrj   { }
1982*fae548d3Szrj 
1983*fae548d3Szrj   const char*
name()1984*fae548d3Szrj   name() const
1985*fae548d3Szrj   { return this->name_.c_str(); }
1986*fae548d3Szrj 
1987*fae548d3Szrj   const Position_dependent_options&
options()1988*fae548d3Szrj   options() const
1989*fae548d3Szrj   { return this->options_; }
1990*fae548d3Szrj 
1991*fae548d3Szrj   bool
is_lib()1992*fae548d3Szrj   is_lib() const
1993*fae548d3Szrj   { return type_ == INPUT_FILE_TYPE_LIBRARY; }
1994*fae548d3Szrj 
1995*fae548d3Szrj   bool
is_searched_file()1996*fae548d3Szrj   is_searched_file() const
1997*fae548d3Szrj   { return type_ == INPUT_FILE_TYPE_SEARCHED_FILE; }
1998*fae548d3Szrj 
1999*fae548d3Szrj   const char*
extra_search_path()2000*fae548d3Szrj   extra_search_path() const
2001*fae548d3Szrj   {
2002*fae548d3Szrj     return (this->extra_search_path_.empty()
2003*fae548d3Szrj 	    ? NULL
2004*fae548d3Szrj 	    : this->extra_search_path_.c_str());
2005*fae548d3Szrj   }
2006*fae548d3Szrj 
2007*fae548d3Szrj   // Return whether we should only read symbols from this file.
2008*fae548d3Szrj   bool
just_symbols()2009*fae548d3Szrj   just_symbols() const
2010*fae548d3Szrj   { return this->just_symbols_; }
2011*fae548d3Szrj 
2012*fae548d3Szrj   // Return whether this file may require a search using the -L
2013*fae548d3Szrj   // options.
2014*fae548d3Szrj   bool
may_need_search()2015*fae548d3Szrj   may_need_search() const
2016*fae548d3Szrj   {
2017*fae548d3Szrj     return (this->is_lib()
2018*fae548d3Szrj 	    || this->is_searched_file()
2019*fae548d3Szrj 	    || !this->extra_search_path_.empty());
2020*fae548d3Szrj   }
2021*fae548d3Szrj 
2022*fae548d3Szrj   // Set the serial number for this argument.
2023*fae548d3Szrj   void
set_arg_serial(unsigned int arg_serial)2024*fae548d3Szrj   set_arg_serial(unsigned int arg_serial)
2025*fae548d3Szrj   { this->arg_serial_ = arg_serial; }
2026*fae548d3Szrj 
2027*fae548d3Szrj   // Get the serial number.
2028*fae548d3Szrj   unsigned int
arg_serial()2029*fae548d3Szrj   arg_serial() const
2030*fae548d3Szrj   { return this->arg_serial_; }
2031*fae548d3Szrj 
2032*fae548d3Szrj  private:
2033*fae548d3Szrj   // We use std::string, not const char*, here for convenience when
2034*fae548d3Szrj   // using script files, so that we do not have to preserve the string
2035*fae548d3Szrj   // in that case.
2036*fae548d3Szrj   std::string name_;
2037*fae548d3Szrj   Input_file_type type_;
2038*fae548d3Szrj   std::string extra_search_path_;
2039*fae548d3Szrj   bool just_symbols_;
2040*fae548d3Szrj   Position_dependent_options options_;
2041*fae548d3Szrj   // A unique index for this file argument in the argument list.
2042*fae548d3Szrj   unsigned int arg_serial_;
2043*fae548d3Szrj };
2044*fae548d3Szrj 
2045*fae548d3Szrj // A file or library, or a group, from the command line.
2046*fae548d3Szrj 
2047*fae548d3Szrj class Input_argument
2048*fae548d3Szrj {
2049*fae548d3Szrj  public:
2050*fae548d3Szrj   // Create a file or library argument.
Input_argument(Input_file_argument file)2051*fae548d3Szrj   explicit Input_argument(Input_file_argument file)
2052*fae548d3Szrj     : is_file_(true), file_(file), group_(NULL), lib_(NULL), script_info_(NULL)
2053*fae548d3Szrj   { }
2054*fae548d3Szrj 
2055*fae548d3Szrj   // Create a group argument.
Input_argument(Input_file_group * group)2056*fae548d3Szrj   explicit Input_argument(Input_file_group* group)
2057*fae548d3Szrj     : is_file_(false), group_(group), lib_(NULL), script_info_(NULL)
2058*fae548d3Szrj   { }
2059*fae548d3Szrj 
2060*fae548d3Szrj   // Create a lib argument.
Input_argument(Input_file_lib * lib)2061*fae548d3Szrj   explicit Input_argument(Input_file_lib* lib)
2062*fae548d3Szrj     : is_file_(false), group_(NULL), lib_(lib), script_info_(NULL)
2063*fae548d3Szrj   { }
2064*fae548d3Szrj 
2065*fae548d3Szrj   // Return whether this is a file.
2066*fae548d3Szrj   bool
is_file()2067*fae548d3Szrj   is_file() const
2068*fae548d3Szrj   { return this->is_file_; }
2069*fae548d3Szrj 
2070*fae548d3Szrj   // Return whether this is a group.
2071*fae548d3Szrj   bool
is_group()2072*fae548d3Szrj   is_group() const
2073*fae548d3Szrj   { return !this->is_file_ && this->lib_ == NULL; }
2074*fae548d3Szrj 
2075*fae548d3Szrj   // Return whether this is a lib.
2076*fae548d3Szrj   bool
is_lib()2077*fae548d3Szrj   is_lib() const
2078*fae548d3Szrj   { return this->lib_ != NULL; }
2079*fae548d3Szrj 
2080*fae548d3Szrj   // Return the information about the file.
2081*fae548d3Szrj   const Input_file_argument&
file()2082*fae548d3Szrj   file() const
2083*fae548d3Szrj   {
2084*fae548d3Szrj     gold_assert(this->is_file_);
2085*fae548d3Szrj     return this->file_;
2086*fae548d3Szrj   }
2087*fae548d3Szrj 
2088*fae548d3Szrj   // Return the information about the group.
2089*fae548d3Szrj   const Input_file_group*
group()2090*fae548d3Szrj   group() const
2091*fae548d3Szrj   {
2092*fae548d3Szrj     gold_assert(!this->is_file_);
2093*fae548d3Szrj     return this->group_;
2094*fae548d3Szrj   }
2095*fae548d3Szrj 
2096*fae548d3Szrj   Input_file_group*
group()2097*fae548d3Szrj   group()
2098*fae548d3Szrj   {
2099*fae548d3Szrj     gold_assert(!this->is_file_);
2100*fae548d3Szrj     return this->group_;
2101*fae548d3Szrj   }
2102*fae548d3Szrj 
2103*fae548d3Szrj   // Return the information about the lib.
2104*fae548d3Szrj   const Input_file_lib*
lib()2105*fae548d3Szrj   lib() const
2106*fae548d3Szrj   {
2107*fae548d3Szrj     gold_assert(!this->is_file_);
2108*fae548d3Szrj     gold_assert(this->lib_);
2109*fae548d3Szrj     return this->lib_;
2110*fae548d3Szrj   }
2111*fae548d3Szrj 
2112*fae548d3Szrj   Input_file_lib*
lib()2113*fae548d3Szrj   lib()
2114*fae548d3Szrj   {
2115*fae548d3Szrj     gold_assert(!this->is_file_);
2116*fae548d3Szrj     gold_assert(this->lib_);
2117*fae548d3Szrj     return this->lib_;
2118*fae548d3Szrj   }
2119*fae548d3Szrj 
2120*fae548d3Szrj   // If a script generated this argument, store a pointer to the script info.
2121*fae548d3Szrj   // Currently used only for recording incremental link information.
2122*fae548d3Szrj   void
set_script_info(Script_info * info)2123*fae548d3Szrj   set_script_info(Script_info* info)
2124*fae548d3Szrj   { this->script_info_ = info; }
2125*fae548d3Szrj 
2126*fae548d3Szrj   Script_info*
script_info()2127*fae548d3Szrj   script_info() const
2128*fae548d3Szrj   { return this->script_info_; }
2129*fae548d3Szrj 
2130*fae548d3Szrj  private:
2131*fae548d3Szrj   bool is_file_;
2132*fae548d3Szrj   Input_file_argument file_;
2133*fae548d3Szrj   Input_file_group* group_;
2134*fae548d3Szrj   Input_file_lib* lib_;
2135*fae548d3Szrj   Script_info* script_info_;
2136*fae548d3Szrj };
2137*fae548d3Szrj 
2138*fae548d3Szrj typedef std::vector<Input_argument> Input_argument_list;
2139*fae548d3Szrj 
2140*fae548d3Szrj // A group from the command line.  This is a set of arguments within
2141*fae548d3Szrj // --start-group ... --end-group.
2142*fae548d3Szrj 
2143*fae548d3Szrj class Input_file_group
2144*fae548d3Szrj {
2145*fae548d3Szrj  public:
2146*fae548d3Szrj   typedef Input_argument_list::const_iterator const_iterator;
2147*fae548d3Szrj 
Input_file_group()2148*fae548d3Szrj   Input_file_group()
2149*fae548d3Szrj     : files_()
2150*fae548d3Szrj   { }
2151*fae548d3Szrj 
2152*fae548d3Szrj   // Add a file to the end of the group.
2153*fae548d3Szrj   Input_argument&
add_file(const Input_file_argument & arg)2154*fae548d3Szrj   add_file(const Input_file_argument& arg)
2155*fae548d3Szrj   {
2156*fae548d3Szrj     this->files_.push_back(Input_argument(arg));
2157*fae548d3Szrj     return this->files_.back();
2158*fae548d3Szrj   }
2159*fae548d3Szrj 
2160*fae548d3Szrj   // Iterators to iterate over the group contents.
2161*fae548d3Szrj 
2162*fae548d3Szrj   const_iterator
begin()2163*fae548d3Szrj   begin() const
2164*fae548d3Szrj   { return this->files_.begin(); }
2165*fae548d3Szrj 
2166*fae548d3Szrj   const_iterator
end()2167*fae548d3Szrj   end() const
2168*fae548d3Szrj   { return this->files_.end(); }
2169*fae548d3Szrj 
2170*fae548d3Szrj  private:
2171*fae548d3Szrj   Input_argument_list files_;
2172*fae548d3Szrj };
2173*fae548d3Szrj 
2174*fae548d3Szrj // A lib from the command line.  This is a set of arguments within
2175*fae548d3Szrj // --start-lib ... --end-lib.
2176*fae548d3Szrj 
2177*fae548d3Szrj class Input_file_lib
2178*fae548d3Szrj {
2179*fae548d3Szrj  public:
2180*fae548d3Szrj   typedef Input_argument_list::const_iterator const_iterator;
2181*fae548d3Szrj 
Input_file_lib(const Position_dependent_options & options)2182*fae548d3Szrj   Input_file_lib(const Position_dependent_options& options)
2183*fae548d3Szrj     : files_(), options_(options)
2184*fae548d3Szrj   { }
2185*fae548d3Szrj 
2186*fae548d3Szrj   // Add a file to the end of the lib.
2187*fae548d3Szrj   Input_argument&
add_file(const Input_file_argument & arg)2188*fae548d3Szrj   add_file(const Input_file_argument& arg)
2189*fae548d3Szrj   {
2190*fae548d3Szrj     this->files_.push_back(Input_argument(arg));
2191*fae548d3Szrj     return this->files_.back();
2192*fae548d3Szrj   }
2193*fae548d3Szrj 
2194*fae548d3Szrj   const Position_dependent_options&
options()2195*fae548d3Szrj   options() const
2196*fae548d3Szrj   { return this->options_; }
2197*fae548d3Szrj 
2198*fae548d3Szrj   // Iterators to iterate over the lib contents.
2199*fae548d3Szrj 
2200*fae548d3Szrj   const_iterator
begin()2201*fae548d3Szrj   begin() const
2202*fae548d3Szrj   { return this->files_.begin(); }
2203*fae548d3Szrj 
2204*fae548d3Szrj   const_iterator
end()2205*fae548d3Szrj   end() const
2206*fae548d3Szrj   { return this->files_.end(); }
2207*fae548d3Szrj 
2208*fae548d3Szrj   size_t
size()2209*fae548d3Szrj   size() const
2210*fae548d3Szrj   { return this->files_.size(); }
2211*fae548d3Szrj 
2212*fae548d3Szrj  private:
2213*fae548d3Szrj   Input_argument_list files_;
2214*fae548d3Szrj   Position_dependent_options options_;
2215*fae548d3Szrj };
2216*fae548d3Szrj 
2217*fae548d3Szrj // A list of files from the command line or a script.
2218*fae548d3Szrj 
2219*fae548d3Szrj class Input_arguments
2220*fae548d3Szrj {
2221*fae548d3Szrj  public:
2222*fae548d3Szrj   typedef Input_argument_list::const_iterator const_iterator;
2223*fae548d3Szrj 
Input_arguments()2224*fae548d3Szrj   Input_arguments()
2225*fae548d3Szrj     : input_argument_list_(), in_group_(false), in_lib_(false), file_count_(0)
2226*fae548d3Szrj   { }
2227*fae548d3Szrj 
2228*fae548d3Szrj   // Add a file.
2229*fae548d3Szrj   Input_argument&
2230*fae548d3Szrj   add_file(Input_file_argument& arg);
2231*fae548d3Szrj 
2232*fae548d3Szrj   // Start a group (the --start-group option).
2233*fae548d3Szrj   void
2234*fae548d3Szrj   start_group();
2235*fae548d3Szrj 
2236*fae548d3Szrj   // End a group (the --end-group option).
2237*fae548d3Szrj   void
2238*fae548d3Szrj   end_group();
2239*fae548d3Szrj 
2240*fae548d3Szrj   // Start a lib (the --start-lib option).
2241*fae548d3Szrj   void
2242*fae548d3Szrj   start_lib(const Position_dependent_options&);
2243*fae548d3Szrj 
2244*fae548d3Szrj   // End a lib (the --end-lib option).
2245*fae548d3Szrj   void
2246*fae548d3Szrj   end_lib();
2247*fae548d3Szrj 
2248*fae548d3Szrj   // Return whether we are currently in a group.
2249*fae548d3Szrj   bool
in_group()2250*fae548d3Szrj   in_group() const
2251*fae548d3Szrj   { return this->in_group_; }
2252*fae548d3Szrj 
2253*fae548d3Szrj   // Return whether we are currently in a lib.
2254*fae548d3Szrj   bool
in_lib()2255*fae548d3Szrj   in_lib() const
2256*fae548d3Szrj   { return this->in_lib_; }
2257*fae548d3Szrj 
2258*fae548d3Szrj   // The number of entries in the list.
2259*fae548d3Szrj   int
size()2260*fae548d3Szrj   size() const
2261*fae548d3Szrj   { return this->input_argument_list_.size(); }
2262*fae548d3Szrj 
2263*fae548d3Szrj   // Iterators to iterate over the list of input files.
2264*fae548d3Szrj 
2265*fae548d3Szrj   const_iterator
begin()2266*fae548d3Szrj   begin() const
2267*fae548d3Szrj   { return this->input_argument_list_.begin(); }
2268*fae548d3Szrj 
2269*fae548d3Szrj   const_iterator
end()2270*fae548d3Szrj   end() const
2271*fae548d3Szrj   { return this->input_argument_list_.end(); }
2272*fae548d3Szrj 
2273*fae548d3Szrj   // Return whether the list is empty.
2274*fae548d3Szrj   bool
empty()2275*fae548d3Szrj   empty() const
2276*fae548d3Szrj   { return this->input_argument_list_.empty(); }
2277*fae548d3Szrj 
2278*fae548d3Szrj   // Return the number of input files.  This may be larger than
2279*fae548d3Szrj   // input_argument_list_.size(), because of files that are part
2280*fae548d3Szrj   // of groups or libs.
2281*fae548d3Szrj   int
number_of_input_files()2282*fae548d3Szrj   number_of_input_files() const
2283*fae548d3Szrj   { return this->file_count_; }
2284*fae548d3Szrj 
2285*fae548d3Szrj  private:
2286*fae548d3Szrj   Input_argument_list input_argument_list_;
2287*fae548d3Szrj   bool in_group_;
2288*fae548d3Szrj   bool in_lib_;
2289*fae548d3Szrj   unsigned int file_count_;
2290*fae548d3Szrj };
2291*fae548d3Szrj 
2292*fae548d3Szrj 
2293*fae548d3Szrj // All the information read from the command line.  These are held in
2294*fae548d3Szrj // three separate structs: one to hold the options (--foo), one to
2295*fae548d3Szrj // hold the filenames listed on the commandline, and one to hold
2296*fae548d3Szrj // linker script information.  This third is not a subset of the other
2297*fae548d3Szrj // two because linker scripts can be specified either as options (via
2298*fae548d3Szrj // -T) or as a file.
2299*fae548d3Szrj 
2300*fae548d3Szrj class Command_line
2301*fae548d3Szrj {
2302*fae548d3Szrj  public:
2303*fae548d3Szrj   typedef Input_arguments::const_iterator const_iterator;
2304*fae548d3Szrj 
2305*fae548d3Szrj   Command_line();
2306*fae548d3Szrj 
2307*fae548d3Szrj   // Process the command line options.  This will exit with an
2308*fae548d3Szrj   // appropriate error message if an unrecognized option is seen.
2309*fae548d3Szrj   void
2310*fae548d3Szrj   process(int argc, const char** argv);
2311*fae548d3Szrj 
2312*fae548d3Szrj   // Process one command-line option.  This takes the index of argv to
2313*fae548d3Szrj   // process, and returns the index for the next option.  no_more_options
2314*fae548d3Szrj   // is set to true if argv[i] is "--".
2315*fae548d3Szrj   int
2316*fae548d3Szrj   process_one_option(int argc, const char** argv, int i,
2317*fae548d3Szrj 		     bool* no_more_options);
2318*fae548d3Szrj 
2319*fae548d3Szrj   // Get the general options.
2320*fae548d3Szrj   const General_options&
options()2321*fae548d3Szrj   options() const
2322*fae548d3Szrj   { return this->options_; }
2323*fae548d3Szrj 
2324*fae548d3Szrj   // Get the position dependent options.
2325*fae548d3Szrj   const Position_dependent_options&
position_dependent_options()2326*fae548d3Szrj   position_dependent_options() const
2327*fae548d3Szrj   { return this->position_options_; }
2328*fae548d3Szrj 
2329*fae548d3Szrj   // Get the linker-script options.
2330*fae548d3Szrj   Script_options&
script_options()2331*fae548d3Szrj   script_options()
2332*fae548d3Szrj   { return this->script_options_; }
2333*fae548d3Szrj 
2334*fae548d3Szrj   // Finalize the version-script options and return them.
2335*fae548d3Szrj   const Version_script_info&
2336*fae548d3Szrj   version_script();
2337*fae548d3Szrj 
2338*fae548d3Szrj   // Get the input files.
2339*fae548d3Szrj   Input_arguments&
inputs()2340*fae548d3Szrj   inputs()
2341*fae548d3Szrj   { return this->inputs_; }
2342*fae548d3Szrj 
2343*fae548d3Szrj   // The number of input files.
2344*fae548d3Szrj   int
number_of_input_files()2345*fae548d3Szrj   number_of_input_files() const
2346*fae548d3Szrj   { return this->inputs_.number_of_input_files(); }
2347*fae548d3Szrj 
2348*fae548d3Szrj   // Iterators to iterate over the list of input files.
2349*fae548d3Szrj 
2350*fae548d3Szrj   const_iterator
begin()2351*fae548d3Szrj   begin() const
2352*fae548d3Szrj   { return this->inputs_.begin(); }
2353*fae548d3Szrj 
2354*fae548d3Szrj   const_iterator
end()2355*fae548d3Szrj   end() const
2356*fae548d3Szrj   { return this->inputs_.end(); }
2357*fae548d3Szrj 
2358*fae548d3Szrj  private:
2359*fae548d3Szrj   Command_line(const Command_line&);
2360*fae548d3Szrj   Command_line& operator=(const Command_line&);
2361*fae548d3Szrj 
2362*fae548d3Szrj   // This is a dummy class to provide a constructor that runs before
2363*fae548d3Szrj   // the constructor for the General_options.  The Pre_options constructor
2364*fae548d3Szrj   // is used as a hook to set the flag enabling the options to register
2365*fae548d3Szrj   // themselves.
2366*fae548d3Szrj   struct Pre_options {
2367*fae548d3Szrj     Pre_options();
2368*fae548d3Szrj   };
2369*fae548d3Szrj 
2370*fae548d3Szrj   // This must come before options_!
2371*fae548d3Szrj   Pre_options pre_options_;
2372*fae548d3Szrj   General_options options_;
2373*fae548d3Szrj   Position_dependent_options position_options_;
2374*fae548d3Szrj   Script_options script_options_;
2375*fae548d3Szrj   Input_arguments inputs_;
2376*fae548d3Szrj };
2377*fae548d3Szrj 
2378*fae548d3Szrj } // End namespace gold.
2379*fae548d3Szrj 
2380*fae548d3Szrj #endif // !defined(GOLD_OPTIONS_H)
2381