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
24 class Command_line_options
;
27 } // End namespace gold::options.
29 // The position independent options which apply to the whole link.
30 // There are a lot of them.
37 // -L: Library search path.
38 typedef std::list
<const char*> Dir_list
;
42 { return this->search_path_
; }
44 // -r: Whether we are doing a relocatable link.
46 is_relocatable() const
47 { return this->is_relocatable_
; }
49 // --static: Whether doing a static link.
52 { return this->is_static_
; }
55 friend class Command_line
;
56 friend class options::Command_line_options
;
59 add_to_search_path(const char* arg
)
60 { this->search_path_
.push_back(arg
); }
64 { this->is_relocatable_
= true; }
68 { this->is_static_
= true; }
70 Dir_list search_path_
;
74 // Don't copy this structure.
75 General_options(const General_options
&);
76 General_options
& operator=(const General_options
&);
79 // The current state of the position dependent options.
81 class Position_dependent_options
84 Position_dependent_options();
86 // -Bstatic: Whether we are searching for a static archive rather
87 // -than a shared object.
90 { return this->do_static_search_
; }
93 friend class Command_line
;
94 friend class options::Command_line_options
;
98 { this->do_static_search_
= true; }
102 { this->do_static_search_
= false; }
104 bool do_static_search_
;
107 // A single file or library argument from the command line.
112 Input_argument(const char* name
, const Position_dependent_options
& options
)
113 : name_(name
), options_(options
)
118 { return this->name_
; }
120 const Position_dependent_options
&
122 { return this->options_
; }
126 { return this->name_
[0] == '-' && this->name_
[1] == 'l'; }
130 { return this->name_
+ 2; }
134 Position_dependent_options options_
;
137 // All the information read from the command line.
144 // Process the command line options. This will exit with an
145 // appropriate error message if an unrecognized option is seen.
147 process(int argc
, char** argv
);
149 const General_options
&
151 { return this->options_
; }
153 typedef std::list
<Input_argument
> Input_argument_list
;
155 const Input_argument_list
&
157 { return this->inputs_
; }
160 void usage() ATTRIBUTE_NORETURN
;
161 void usage(const char* msg
, const char* opt
) ATTRIBUTE_NORETURN
;
162 void usage(const char* msg
, char opt
) ATTRIBUTE_NORETURN
;
163 void apply_option(const gold::options::One_option
&, const char*);
165 General_options options_
;
166 Position_dependent_options position_options_
;
167 Input_argument_list inputs_
;
170 } // End namespace gold.
172 #endif // !defined(GOLD_OPTIONS_H)