* object.h (class Object): Remove target_ field, and target,
[deliverable/binutils-gdb.git] / gold / parameters.cc
index 0164265bf04eb7f88dd42dbe059d3107d765ac2a..2a53998bebc356009c999c55a59849a194907f90 100644 (file)
@@ -59,7 +59,7 @@ Parameters::set_doing_static_link(bool doing_static_link)
 }
 
 void
-Parameters::set_target(const Target* target)
+Parameters::set_target(Target* target)
 {
   if (!this->target_valid())
     this->target_ = target;
@@ -67,37 +67,6 @@ Parameters::set_target(const Target* target)
     gold_assert(target == this->target_);
 }
 
-// The x86_64 kernel build converts a binary file to an object file
-// using -r --format binary --oformat elf32-i386 foo.o.  In order to
-// support that for gold we support determining the default target
-// choice from the output format.  We recognize names that the GNU
-// linker uses.
-
-const Target&
-Parameters::default_target() const
-{
-  gold_assert(this->options_valid());
-  if (this->options().user_set_oformat())
-    {
-      const Target* target
-          = select_target_by_name(this->options().oformat());
-      if (target != NULL)
-       return *target;
-
-      gold_error(_("unrecognized output format %s"),
-                 this->options().oformat());
-    }
-
-  // The GOLD_DEFAULT_xx macros are defined by the configure script.
-  const Target* target = select_target(elfcpp::GOLD_DEFAULT_MACHINE,
-                                       GOLD_DEFAULT_SIZE,
-                                       GOLD_DEFAULT_BIG_ENDIAN,
-                                      elfcpp::GOLD_DEFAULT_OSABI,
-                                      0);
-  gold_assert(target != NULL);
-  return *target;
-}
-
 // Return whether TARGET is compatible with the target we are using.
 
 bool
@@ -171,11 +140,55 @@ set_parameters_options(const General_options* options)
 { static_parameters.set_options(options); }
 
 void
-set_parameters_target(const Target* target)
+set_parameters_target(Target* target)
 { static_parameters.set_target(target); }
 
 void
 set_parameters_doing_static_link(bool doing_static_link)
 { static_parameters.set_doing_static_link(doing_static_link); }
 
+// Force the target to be valid by using the default.  Use the
+// --oformat option is set; this supports the x86_64 kernel build,
+// which converts a binary file to an object file using -r --format
+// binary --oformat elf32-i386 foo.o.  Otherwise use the configured
+// default.
+
+void
+parameters_force_valid_target()
+{
+  if (parameters->target_valid())
+    return;
+
+  gold_assert(parameters->options_valid());
+  if (parameters->options().user_set_oformat())
+    {
+      Target* target = select_target_by_name(parameters->options().oformat());
+      if (target != NULL)
+       {
+         set_parameters_target(target);
+         return;
+       }
+
+      gold_error(_("unrecognized output format %s"),
+                 parameters->options().oformat());
+    }
+
+  // The GOLD_DEFAULT_xx macros are defined by the configure script.
+  Target* target = select_target(elfcpp::GOLD_DEFAULT_MACHINE,
+                                GOLD_DEFAULT_SIZE,
+                                GOLD_DEFAULT_BIG_ENDIAN,
+                                elfcpp::GOLD_DEFAULT_OSABI,
+                                0);
+  gold_assert(target != NULL);
+  set_parameters_target(target);
+}
+
+// Clear the current target, for testing.
+
+void
+parameters_clear_target()
+{
+  static_parameters.clear_target();
+}
+
 } // End namespace gold.
This page took 0.025705 seconds and 4 git commands to generate.