1 // options.h -- handle command line options for gold -*- C++ -*-
4 // Holds everything we get from the command line.
5 // General_options (from Command_line::options())
6 // Options which are not position dependent.
7 // Input_argument (from Command_line::inputs())
8 // The list of input files, including -l options.
9 // Position_dependent_options (from Input_argument::options())
10 // Position dependent options which apply to this argument.
12 #ifndef GOLD_OPTIONS_H
13 #define GOLD_OPTIONS_H
26 class Command_line_options
;
29 } // End namespace gold::options.
31 // The position independent options which apply to the whole link.
32 // There are a lot of them.
39 // -L: Library search path.
40 typedef std::list
<const char*> Dir_list
;
44 { return this->search_path_
; }
46 // -r: Whether we are doing a relocatable link.
48 is_relocatable() const
49 { return this->is_relocatable_
; }
51 // --static: Whether doing a static link.
54 { return this->is_static_
; }
57 friend class Command_line
;
58 friend class options::Command_line_options
;
61 add_to_search_path(const char* arg
)
62 { this->search_path_
.push_back(arg
); }
66 { this->is_relocatable_
= true; }
70 { this->is_static_
= true; }
72 Dir_list search_path_
;
76 // Don't copy this structure.
77 General_options(const General_options
&);
78 General_options
& operator=(const General_options
&);
81 // The current state of the position dependent options.
83 class Position_dependent_options
86 Position_dependent_options();
88 // -Bstatic: Whether we are searching for a static archive rather
89 // -than a shared object.
92 { return this->do_static_search_
; }
95 friend class Command_line
;
96 friend class options::Command_line_options
;
100 { this->do_static_search_
= true; }
104 { this->do_static_search_
= false; }
106 bool do_static_search_
;
109 // A single file or library argument from the command line.
114 Input_argument(const char* name
, const Position_dependent_options
& options
)
115 : name_(name
), options_(options
)
120 { return this->name_
; }
122 const Position_dependent_options
&
124 { return this->options_
; }
128 { return this->name_
[0] == '-' && this->name_
[1] == 'l'; }
132 { return this->name_
+ 2; }
136 Position_dependent_options options_
;
139 // All the information read from the command line.
146 // Process the command line options. This will exit with an
147 // appropriate error message if an unrecognized option is seen.
149 process(int argc
, char** argv
);
151 const General_options
&
153 { return this->options_
; }
155 typedef std::list
<Input_argument
> Input_argument_list
;
157 const Input_argument_list
&
159 { return this->inputs_
; }
162 void usage() ATTRIBUTE_NORETURN
;
163 void usage(const char* msg
, const char* opt
) ATTRIBUTE_NORETURN
;
164 void usage(const char* msg
, char opt
) ATTRIBUTE_NORETURN
;
165 void apply_option(const gold::options::One_option
&, const char*);
167 General_options options_
;
168 Position_dependent_options position_options_
;
169 Input_argument_list inputs_
;
172 } // End namespace gold.
174 #endif // !defined(GOLD_OPTIONS_H)