* x86_64.cc (Target_x86_64::saw_tls_block_reloc_): Remove member.
[binutils-gdb.git] / gold / target-select.h
index b0b1d92e0c1efafc0a9ba6a9afb06a613e766a2e..4e2ea92268434fef69d65ac760258540cae1639d 100644 (file)
@@ -1,6 +1,6 @@
 // target-select.h -- select a target for an object file  -*- C++ -*-
 
-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
 
 #include <vector>
 
+#include "gold-threads.h"
+
 namespace gold
 {
 
 class Target;
+class Target_selector;
+
+// Used to set the target only once.
+
+class Set_target_once : public Once
+{
+ public:
+  Set_target_once(Target_selector* target_selector)
+    : target_selector_(target_selector)
+  { }
+
+ protected:
+  void
+  do_run_once(void*);
+
+ private:
+  Target_selector* target_selector_;
+};
 
 // We want to avoid a master list of targets, which implies using a
 // global constructor.  And we also want the program to start up as
@@ -136,14 +156,15 @@ class Target_selector
 
   // Instantiate the target and return it.
   Target*
-  instantiate_target()
-  {
-    if (this->instantiated_target_ == NULL)
-      this->instantiated_target_ = this->do_instantiate_target();
-    return this->instantiated_target_;
-  }
+  instantiate_target();
 
  private:
+  // Set the target.
+  void
+  set_target();
+
+  friend class Set_target_once;
+
   // ELF machine code.
   const int machine_;
   // Target size--32 or 64.
@@ -157,6 +178,8 @@ class Target_selector
   // The singleton Target structure--this points to an instance of the
   // real implementation.
   Target* instantiated_target_;
+  // Used to set the target only once.
+  Set_target_once set_target_once_;
 };
 
 // Select the target for an ELF file.