return cmdline->process_l_option(argc, argv, arg);
}
+// Handle the special --start-group option.
+
+int
+start_group(int, char**, char* arg, gold::Command_line* cmdline)
+{
+ cmdline->start_group(arg);
+ return 1;
+}
+
+// Handle the special --end-group option.
+
+int
+end_group(int, char**, char* arg, gold::Command_line* cmdline)
+{
+ cmdline->end_group(arg);
+ return 1;
+}
+
// Report usage information for ld --help, and exit.
int
SPECIAL('l', "library", N_("Search for library LIBNAME"),
N_("-lLIBNAME --library LIBNAME"), TWO_DASHES,
&library),
+ SPECIAL('(', "start-group", N_("Start a library search group"), NULL,
+ TWO_DASHES, &start_group),
+ SPECIAL(')', "end-group", N_("End a library search group"), NULL,
+ TWO_DASHES, &end_group),
+ GENERAL_ARG('I', "dynamic-linker", N_("Set dynamic linker path"),
+ N_("-I PROGRAM, --dynamic-linker PROGRAM"), TWO_DASHES,
+ &General_options::set_dynamic_linker),
GENERAL_ARG('L', "library-path", N_("Add directory to search path"),
N_("-L DIR, --library-path DIR"), TWO_DASHES,
&General_options::add_to_search_path),
+ GENERAL_ARG('m', NULL, N_("Ignored for compatibility"), NULL, ONE_DASH,
+ &General_options::ignore),
GENERAL_ARG('o', "output", N_("Set output file name"),
N_("-o FILE, --output FILE"), TWO_DASHES,
&General_options::set_output_file_name),
NULL, ONE_DASH, &General_options::set_shared),
GENERAL_NOARG('\0', "static", N_("Do not link against shared libraries"),
NULL, ONE_DASH, &General_options::set_static),
+ POSDEP_NOARG('\0', "as-needed",
+ N_("Only set DT_NEEDED for following dynamic libs if used"),
+ NULL, TWO_DASHES, &Position_dependent_options::set_as_needed),
+ POSDEP_NOARG('\0', "no-as-needed",
+ N_("Always DT_NEEDED for following dynamic libs (default)"),
+ NULL, TWO_DASHES, &Position_dependent_options::clear_as_needed),
SPECIAL('\0', "help", N_("Report usage information"), NULL,
TWO_DASHES, &help)
};
// The default values for the general options.
General_options::General_options()
- : search_path_(),
+ : dynamic_linker_(NULL),
+ search_path_(),
output_file_name_("a.out"),
is_relocatable_(false),
is_shared_(false),
{
}
-// Construct a Command_line.
+// Input_arguments methods.
+
+// Add a file to the list.
+
+void
+Input_arguments::add_file(const Input_file_argument& file)
+{
+ if (!this->in_group_)
+ this->input_argument_list_.push_back(Input_argument(file));
+ else
+ {
+ gold_assert(!this->input_argument_list_.empty());
+ gold_assert(this->input_argument_list_.back().is_group());
+ this->input_argument_list_.back().group()->add_file(file);
+ }
+}
+
+// Start a group.
+
+void
+Input_arguments::start_group()
+{
+ gold_assert(!this->in_group_);
+ Input_file_group* group = new Input_file_group();
+ this->input_argument_list_.push_back(Input_argument(group));
+ this->in_group_ = true;
+}
+
+// End a group.
+
+void
+Input_arguments::end_group()
+{
+ gold_assert(this->in_group_);
+ this->in_group_ = false;
+}
+
+// Command_line options.
Command_line::Command_line()
+ : options_(), position_options_(), inputs_()
{
}
{
if (argv[i][0] != '-' || no_more_options)
{
- this->inputs_.push_back(Input_argument(argv[i], false,
- this->position_options_));
+ this->add_file(argv[i], false);
++i;
continue;
}
}
}
+ if (this->inputs_.in_group())
+ {
+ fprintf(stderr, _("%s: missing group end"), program_name);
+ this->usage();
+ }
+
// FIXME: We should only do this when configured in native mode.
this->options_.add_to_search_path("/lib");
this->options_.add_to_search_path("/usr/lib");
}
}
+// Add an input file or library.
+
+void
+Command_line::add_file(const char* name, bool is_lib)
+{
+ Input_file_argument file(name, is_lib, this->position_options_);
+ this->inputs_.add_file(file);
+}
+
// Handle the -l option, which requires special treatment.
int
else
this->usage(_("missing argument"), arg);
- this->inputs_.push_back(Input_argument(libname, true,
- this->position_options_));
+ this->add_file(libname, true);
return ret;
}
+// Handle the --start-group option.
+
+void
+Command_line::start_group(const char* arg)
+{
+ if (this->inputs_.in_group())
+ this->usage(_("may not nest groups"), arg);
+ this->inputs_.start_group();
+}
+
+// Handle the --end-group option.
+
+void
+Command_line::end_group(const char* arg)
+{
+ if (!this->inputs_.in_group())
+ this->usage(_("group end without group start"), arg);
+ this->inputs_.end_group();
+}
+
// Report a usage error. */
void