*** empty log message ***
[deliverable/binutils-gdb.git] / gold / options.cc
index 8e0465f2af919cc7eb16a70492e91c7ab1796876..b8339e8a625390ba35f89b31bcc9fd8104876d2d 100644 (file)
@@ -89,6 +89,24 @@ library(int argc, char** argv, char* arg, gold::Command_line* cmdline)
   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
@@ -209,9 +227,18 @@ options::Command_line_options::options[] =
   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),
@@ -221,6 +248,12 @@ options::Command_line_options::options[] =
                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)
 };
@@ -231,7 +264,8 @@ const int options::Command_line_options::options_size =
 // 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),
@@ -246,9 +280,47 @@ Position_dependent_options::Position_dependent_options()
 {
 }
 
-// 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_()
 {
 }
 
@@ -266,8 +338,7 @@ Command_line::process(int argc, char** argv)
     {
       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;
        }
@@ -385,6 +456,12 @@ Command_line::process(int argc, char** argv)
        }
     }
 
+  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");
@@ -416,6 +493,15 @@ Command_line::apply_option(const options::One_option& opt,
     }
 }
 
+// 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
@@ -436,12 +522,31 @@ Command_line::process_l_option(int argc, char** argv, char* arg)
   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
This page took 0.044882 seconds and 4 git commands to generate.