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
25 class Command_line_options
;
28 } // End namespace gold::options.
30 // The position independent options which apply to the whole link.
31 // There are a lot of them.
38 // -L: Library search path.
39 typedef std::list
<const char*> Dir_list
;
43 { return this->search_path_
; }
45 // -o: Output file name.
47 output_file_name() const
48 { return this->output_file_name_
; }
50 // -r: Whether we are doing a relocatable link.
52 is_relocatable() const
53 { return this->is_relocatable_
; }
55 // --static: Whether doing a static link.
58 { return this->is_static_
; }
61 friend class Command_line
;
62 friend class options::Command_line_options
;
65 add_to_search_path(const char* arg
)
66 { this->search_path_
.push_back(arg
); }
69 set_output_file_name(const char* arg
)
70 { this->output_file_name_
= arg
; }
74 { this->is_relocatable_
= true; }
78 { this->is_static_
= true; }
80 Dir_list search_path_
;
81 const char* output_file_name_
;
85 // Don't copy this structure.
86 General_options(const General_options
&);
87 General_options
& operator=(const General_options
&);
90 // The current state of the position dependent options.
92 class Position_dependent_options
95 Position_dependent_options();
97 // -Bstatic: Whether we are searching for a static archive rather
98 // -than a shared object.
101 { return this->do_static_search_
; }
104 friend class Command_line
;
105 friend class options::Command_line_options
;
109 { this->do_static_search_
= true; }
113 { this->do_static_search_
= false; }
115 bool do_static_search_
;
118 // A single file or library argument from the command line.
123 Input_argument(const char* name
, bool is_lib
,
124 const Position_dependent_options
& options
)
125 : name_(name
), is_lib_(is_lib
), options_(options
)
130 { return this->name_
; }
132 const Position_dependent_options
&
134 { return this->options_
; }
138 { return this->is_lib_
; }
143 Position_dependent_options options_
;
146 // All the information read from the command line.
153 // Process the command line options. This will exit with an
154 // appropriate error message if an unrecognized option is seen.
156 process(int argc
, char** argv
);
158 // Handle a -l option.
160 process_l_option(int, char**, char*);
162 // Get the general options.
163 const General_options
&
165 { return this->options_
; }
167 typedef std::list
<Input_argument
> Input_argument_list
;
169 // Get the list of input files.
170 const Input_argument_list
&
172 { return this->inputs_
; }
175 void usage() ATTRIBUTE_NORETURN
;
176 void usage(const char* msg
, const char* opt
) ATTRIBUTE_NORETURN
;
177 void usage(const char* msg
, char opt
) ATTRIBUTE_NORETURN
;
178 void apply_option(const gold::options::One_option
&, const char*);
180 General_options options_
;
181 Position_dependent_options position_options_
;
182 Input_argument_list inputs_
;
185 } // End namespace gold.
187 #endif // !defined(GOLD_OPTIONS_H)