This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gold patch committed: Remove target from Object


With the new scheme of using Target to create an Object, it no longer
makes sense to have every Object point to Target.  It was harder than
I thought it would be to get rid of it, but this seems to do the job.
Committed to mainline.

Ian


2009-09-30  Ian Lance Taylor  <iant@google.com>

	* object.h (class Object): Remove target_ field, and target,
	sized_target, and set_target methods.
	(Object::sized_target): Remove.
	(class Sized_relobj): Update declarations.  Remove sized_target.
	* object.cc (Sized_relobj::setup): Remove target parameter.
	Change all callers.
	(Input_objects::add_object): Don't do anything with the target.
	(make_elf_sized_object): Add punconfigured parameter.  Change all
	callers.  Set or test parameter target.
	* dynobj.cc (Sized_dynobj::target): Remove target parameter.
	Change all callers.
	* parameters.cc (Parameters::set_target): Change parameter type to
	be non-const.
	(Parameters::default_target): Remove.
	(set_parameters_target): Change parameter type to be non-const.
	(parameters_force_valid_target): New function.
	(parameters_clear_target): New function.
	* parameters.h (class Parameters): Update declarations.  Remove
	default_target method.  Add sized_target and clear_target
	methods.  Change target_ to be non-const.
	(set_parameters_target): Update declaration.
	(parameters_force_valid_target): Declare.
	(parameters_clear_target): Declare.
	* readsyms.cc (Read_symbols::do_read_symbols): Pass punconfigured
	as NULL if we aren't searching.
	(Add_symbols::run): Don't check for compatible target.
	* fileread.cc (Input_file::open_binary): Call
	parameters_force_valid_target.
	* gold.cc (queue_middle_tasks): Likewise.
	* plugin.cc (make_sized_plugin_object): Likewise.  Don't call
	set_target on object.
	* dynobj.h (class Sized_dynobj): Update declarations.
	* archive.cc (Archive::get_elf_object_for_member): Return NULL if
	make_elf_object returns NULL.
	(Archive::include_member): Don't check whether object target is
	compatible.
	* output.cc (Output_section::add_input_section): Get target from
	parameters.
	(Output_section::relax_input_section): Likewise.
	* reloc.cc (Sized_relobj::do_gc_process_relocs): Get target from
	parameters.
	(Sized_relobj::do_scan_relocs): Likewise.
	(Sized_relobj::relocate_sections): Likewise.
	* resolve.cc (Symbol_table::resolve): Likewise.
	* symtab.cc (Symbol_table::wrap_symbol): Likewise.  Remove object
	parameter.  Change all callers.
	(Symbol_table::add_from_object): Get target from parameters.
	(Symbol_table::add_from_relobj): Don't check object target.
	(Symbol_table::add_from_dynobj): Likewise.
	(Symbol_table::define_special_symbol): Get target from
	parameters.
	* symtab.h (class Symbol_table): Update declaration.
	* testsuite/binary_unittest.cc (gold_testsuite): Remove target
	parameter.  Change all callers.  Clear parameter target.
	(Binary_test): Test target here.
	* testsuite/object_unittest.cc (gold_testsuite): Remove
	target_test_pointer parameter.  Change all callers.
	(Object_test): Test target here.


Index: archive.cc
===================================================================
RCS file: /cvs/src/src/gold/archive.cc,v
retrieving revision 1.44
diff -p -u -r1.44 archive.cc
--- archive.cc	19 May 2009 22:14:17 -0000	1.44
+++ archive.cc	30 Sep 2009 21:53:39 -0000
@@ -564,6 +564,8 @@ Archive::get_elf_object_for_member(off_t
 				 + "(" + member_name + ")"),
 				input_file, memoff, ehdr, read_size,
 				punconfigured);
+  if (obj == NULL)
+    return NULL;
   obj->set_no_export(this->no_export());
   return obj;
 }
@@ -807,11 +809,6 @@ Archive::include_member(Symbol_table* sy
     {
       Object *obj = p->second.obj_;
 
-      if (!this->included_member_
-	  && this->searched_for()
-	  && !parameters->is_compatible_target(obj->target()))
-	return false;
-
       Read_symbols_data *sd = p->second.sd_;
       if (mapfile != NULL)
         mapfile->report_include_archive_member(obj->name(), sym, why);
@@ -830,9 +827,8 @@ Archive::include_member(Symbol_table* sy
 
   if (!this->included_member_
       && this->searched_for()
-      && (obj == NULL
-	  ? unconfigured
-	  : !parameters->is_compatible_target(obj->target())))
+      && obj == NULL
+      && unconfigured)
     {
       if (obj != NULL)
 	delete obj;
Index: dynobj.cc
===================================================================
RCS file: /cvs/src/src/gold/dynobj.cc,v
retrieving revision 1.44
diff -p -u -r1.44 dynobj.cc
--- dynobj.cc	18 Aug 2009 23:49:29 -0000	1.44
+++ dynobj.cc	30 Sep 2009 21:53:39 -0000
@@ -83,9 +83,8 @@ Sized_dynobj<size, big_endian>::Sized_dy
 
 template<int size, bool big_endian>
 void
-Sized_dynobj<size, big_endian>::setup(Target *target)
+Sized_dynobj<size, big_endian>::setup()
 {
-  this->set_target(target);
   const unsigned int shnum = this->elf_file_.shnum();
   this->set_shnum(shnum);
 }
Index: dynobj.h
===================================================================
RCS file: /cvs/src/src/gold/dynobj.h,v
retrieving revision 1.32
diff -p -u -r1.32 dynobj.h
--- dynobj.h	18 Aug 2009 23:49:29 -0000	1.32
+++ dynobj.h	30 Sep 2009 21:53:39 -0000
@@ -163,7 +163,7 @@ class Sized_dynobj : public Dynobj
 
   // Set up the object file based on TARGET.
   void
-  setup(Target *target);
+  setup();
 
   // Read the symbols.
   void
Index: fileread.cc
===================================================================
RCS file: /cvs/src/src/gold/fileread.cc,v
retrieving revision 1.52
diff -p -u -r1.52 fileread.cc
--- fileread.cc	6 Jul 2009 23:11:21 -0000	1.52
+++ fileread.cc	30 Sep 2009 21:53:39 -0000
@@ -898,15 +898,12 @@ Input_file::open_binary(const Task* task
   // In order to open a binary file, we need machine code, size, and
   // endianness.  We may not have a valid target at this point, in
   // which case we use the default target.
-  const Target* target;
-  if (parameters->target_valid())
-    target = &parameters->target();
-  else
-    target = &parameters->default_target();
+  parameters_force_valid_target();
+  const Target& target(parameters->target());
 
-  Binary_to_elf binary_to_elf(target->machine_code(),
-			      target->get_size(),
-			      target->is_big_endian(),
+  Binary_to_elf binary_to_elf(target.machine_code(),
+			      target.get_size(),
+			      target.is_big_endian(),
 			      name);
   if (!binary_to_elf.convert(task))
     return false;
Index: gold.cc
===================================================================
RCS file: /cvs/src/src/gold/gold.cc,v
retrieving revision 1.67
diff -p -u -r1.67 gold.cc
--- gold.cc	1 Sep 2009 17:32:34 -0000	1.67
+++ gold.cc	30 Sep 2009 21:53:39 -0000
@@ -382,7 +382,7 @@ queue_middle_tasks(const General_options
   // pass an empty archive to the linker and get an empty object file
   // out.  In order to do this we need to use a default target.
   if (input_objects->number_of_input_objects() == 0)
-    set_parameters_target(&parameters->default_target());
+    parameters_force_valid_target();
 
   int thread_count = options.thread_count_middle();
   if (thread_count == 0)
Index: object.cc
===================================================================
RCS file: /cvs/src/src/gold/object.cc,v
retrieving revision 1.99
diff -p -u -r1.99 object.cc
--- object.cc	18 Sep 2009 20:02:21 -0000	1.99
+++ object.cc	30 Sep 2009 21:53:39 -0000
@@ -336,14 +336,12 @@ Sized_relobj<size, big_endian>::~Sized_r
 }
 
 // Set up an object file based on the file header.  This sets up the
-// target and reads the section information.
+//  section information.
 
 template<int size, bool big_endian>
 void
-Sized_relobj<size, big_endian>::setup(Target *target)
+Sized_relobj<size, big_endian>::setup()
 {
-  this->set_target(target);
-
   const unsigned int shnum = this->elf_file_.shnum();
   this->set_shnum(shnum);
 }
@@ -2067,16 +2065,6 @@ Sized_relobj<size, big_endian>::do_get_g
 bool
 Input_objects::add_object(Object* obj)
 {
-  // Set the global target from the first object file we recognize.
-  Target* target = obj->target();
-  if (!parameters->target_valid())
-    set_parameters_target(target);
-  else if (target != &parameters->target())
-    {
-      obj->error(_("incompatible target"));
-      return false;
-    }
-
   // Print the filename if the -t/--trace option is selected.
   if (parameters->options().trace())
     gold_info("%s", obj->name().c_str());
@@ -2227,7 +2215,8 @@ using namespace gold;
 template<int size, bool big_endian>
 Object*
 make_elf_sized_object(const std::string& name, Input_file* input_file,
-		      off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr)
+		      off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr,
+		      bool* punconfigured)
 {
   Target* target = select_target(ehdr.get_e_machine(), size, big_endian,
 				 ehdr.get_e_ident()[elfcpp::EI_OSABI],
@@ -2235,6 +2224,18 @@ make_elf_sized_object(const std::string&
   if (target == NULL)
     gold_fatal(_("%s: unsupported ELF machine number %d"),
 	       name.c_str(), ehdr.get_e_machine());
+
+  if (!parameters->target_valid())
+    set_parameters_target(target);
+  else if (target != &parameters->target())
+    {
+      if (punconfigured != NULL)
+	*punconfigured = true;
+      else
+	gold_error(_("%s: incompatible target"), name.c_str());
+      return NULL;
+    }
+
   return target->make_elf_object<size, big_endian>(name, input_file, offset,
 						   ehdr);
 }
@@ -2337,7 +2338,7 @@ make_elf_object(const std::string& name,
 #ifdef HAVE_TARGET_32_BIG
 	  elfcpp::Ehdr<32, true> ehdr(p);
 	  return make_elf_sized_object<32, true>(name, input_file,
-						 offset, ehdr);
+						 offset, ehdr, punconfigured);
 #else
 	  if (punconfigured != NULL)
 	    *punconfigured = true;
@@ -2353,7 +2354,7 @@ make_elf_object(const std::string& name,
 #ifdef HAVE_TARGET_32_LITTLE
 	  elfcpp::Ehdr<32, false> ehdr(p);
 	  return make_elf_sized_object<32, false>(name, input_file,
-						  offset, ehdr);
+						  offset, ehdr, punconfigured);
 #else
 	  if (punconfigured != NULL)
 	    *punconfigured = true;
@@ -2377,7 +2378,7 @@ make_elf_object(const std::string& name,
 #ifdef HAVE_TARGET_64_BIG
 	  elfcpp::Ehdr<64, true> ehdr(p);
 	  return make_elf_sized_object<64, true>(name, input_file,
-						 offset, ehdr);
+						 offset, ehdr, punconfigured);
 #else
 	  if (punconfigured != NULL)
 	    *punconfigured = true;
@@ -2393,7 +2394,7 @@ make_elf_object(const std::string& name,
 #ifdef HAVE_TARGET_64_LITTLE
 	  elfcpp::Ehdr<64, false> ehdr(p);
 	  return make_elf_sized_object<64, false>(name, input_file,
-						  offset, ehdr);
+						  offset, ehdr, punconfigured);
 #else
 	  if (punconfigured != NULL)
 	    *punconfigured = true;
Index: object.h
===================================================================
RCS file: /cvs/src/src/gold/object.h,v
retrieving revision 1.78
diff -p -u -r1.78 object.h
--- object.h	18 Aug 2009 23:49:29 -0000	1.78
+++ object.h	30 Sep 2009 21:53:39 -0000
@@ -195,7 +195,7 @@ class Object
   Object(const std::string& name, Input_file* input_file, bool is_dynamic,
 	 off_t offset = 0)
     : name_(name), input_file_(input_file), offset_(offset), shnum_(-1U),
-      is_dynamic_(is_dynamic), target_(NULL), xindex_(NULL), no_export_(false)
+      is_dynamic_(is_dynamic), xindex_(NULL), no_export_(false)
   { input_file->file().add_object(); }
 
   virtual ~Object()
@@ -222,11 +222,6 @@ class Object
   pluginobj()
   { return this->do_pluginobj(); }
 
-  // Return the target structure associated with this object.
-  Target*
-  target() const
-  { return this->target_; }
-
   // Get the file.  We pass on const-ness.
   Input_file*
   input_file()
@@ -266,13 +261,6 @@ class Object
   just_symbols() const
   { return this->input_file()->just_symbols(); }
 
-  // Return the sized target structure associated with this object.
-  // This is like the target method but it returns a pointer of
-  // appropriate checked type.
-  template<int size, bool big_endian>
-  Sized_target<size, big_endian>*
-  sized_target() const;
-
   // Get the number of sections.
   unsigned int
   shnum() const
@@ -453,11 +441,6 @@ class Object
 			   size_t* used) const
   { this->do_get_global_symbol_counts(symtab, defined, used); }
 
-  // Set the target.
-  void
-  set_target(Target* target)
-  { this->target_ = target; }
-
   // Return whether this object was found in a system directory.
   bool
   is_in_system_directory() const
@@ -589,8 +572,6 @@ class Object
   unsigned int shnum_;
   // Whether this is a dynamic object.
   bool is_dynamic_;
-  // Target functions--may be NULL if the target is not known.
-  Target* target_;
   // Many sections for objects with more than SHN_LORESERVE sections.
   Xindex* xindex_;
   // True if exclude this object from automatic symbol export.
@@ -598,18 +579,6 @@ class Object
   bool no_export_;
 };
 
-// Implement sized_target inline for efficiency.  This approach breaks
-// static type checking, but is made safe using asserts.
-
-template<int size, bool big_endian>
-inline Sized_target<size, big_endian>*
-Object::sized_target() const
-{
-  gold_assert(this->target_->get_size() == size);
-  gold_assert(this->target_->is_big_endian() ? big_endian : !big_endian);
-  return static_cast<Sized_target<size, big_endian>*>(this->target_);
-}
-
 // A regular object (ET_REL).  This is an abstract base class itself.
 // The implementation is the template class Sized_relobj.
 
@@ -1308,7 +1277,7 @@ class Sized_relobj : public Relobj
 
   // Set up the object file based on TARGET.
   void
-  setup(Target *target);
+  setup();
 
   // Return the number of symbols.  This is only valid after
   // Object::add_symbols has been called.
@@ -1373,11 +1342,6 @@ class Sized_relobj : public Relobj
     return this->local_values_[sym].input_shndx(is_ordinary);
   }
 
-  // Return the appropriate Sized_target structure.
-  Sized_target<size, big_endian>*
-  sized_target()
-  { return this->Object::sized_target<size, big_endian>(); }
-
   // Record that local symbol SYM needs a dynamic symbol entry.
   void
   set_needs_output_dynsym_entry(unsigned int sym)
Index: output.cc
===================================================================
RCS file: /cvs/src/src/gold/output.cc,v
retrieving revision 1.96
diff -p -u -r1.96 output.cc
--- output.cc	18 Sep 2009 01:10:38 -0000	1.96
+++ output.cc	30 Sep 2009 21:53:39 -0000
@@ -1895,7 +1895,7 @@ Output_section::add_input_section(Sized_
   if (aligned_offset_in_section > offset_in_section
       && !have_sections_script
       && (sh_flags & elfcpp::SHF_EXECINSTR) != 0
-      && object->target()->has_code_fill())
+      && parameters->target().has_code_fill())
     {
       // We need to add some fill data.  Using fill_list_ when
       // possible is an optimization, since we will often have fill
@@ -1907,7 +1907,7 @@ Output_section::add_input_section(Sized_
         {
           // FIXME: When relaxing, the size needs to adjust to
           // maintain a constant alignment.
-          std::string fill_data(object->target()->code_fill(fill_len));
+          std::string fill_data(parameters->target().code_fill(fill_len));
           Output_data_const* odc = new Output_data_const(fill_data, 1);
           this->input_sections_.push_back(Input_section(odc));
         }
@@ -1925,7 +1925,7 @@ Output_section::add_input_section(Sized_
       || this->may_sort_attached_input_sections()
       || this->must_sort_attached_input_sections()
       || parameters->options().user_set_Map()
-      || object->target()->may_relax())
+      || parameters->target().may_relax())
     this->input_sections_.push_back(Input_section(object, shndx,
 						  shdr.get_sh_size(),
 						  addralign));
@@ -2041,7 +2041,7 @@ Output_section::relax_input_section(Outp
   Relobj* relobj = psection->relobj();
   unsigned int shndx = psection->shndx();
 
-  gold_assert(relobj->target()->may_relax());
+  gold_assert(parameters->target().may_relax());
 
   // This is not very efficient if we a going to relax a number of sections
   // in an Output_section with lot of Input_sections.
Index: parameters.cc
===================================================================
RCS file: /cvs/src/src/gold/parameters.cc,v
retrieving revision 1.27
diff -p -u -r1.27 parameters.cc
--- parameters.cc	24 Mar 2009 00:31:29 -0000	1.27
+++ parameters.cc	30 Sep 2009 21:53:39 -0000
@@ -59,7 +59,7 @@ Parameters::set_doing_static_link(bool d
 }
 
 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* tar
     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_opt
 { 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.
Index: parameters.h
===================================================================
RCS file: /cvs/src/src/gold/parameters.h,v
retrieving revision 1.26
diff -p -u -r1.26 parameters.h
--- parameters.h	14 Mar 2009 05:56:46 -0000	1.26
+++ parameters.h	30 Sep 2009 21:53:39 -0000
@@ -29,6 +29,8 @@ namespace gold
 class General_options;
 class Errors;
 class Target;
+template<int size, bool big_endian>
+class Sized_target;
 
 // Here we define the Parameters class which simply holds simple
 // general parameters which apply to the entire link.  We use a global
@@ -61,7 +63,7 @@ class Parameters
   set_options(const General_options* options);
 
   void
-  set_target(const Target* target);
+  set_target(Target* target);
 
   void
   set_doing_static_link(bool doing_static_link);
@@ -98,10 +100,20 @@ class Parameters
     return *this->target_;
   }
 
-  // When we don't have an output file to associate a target, make a
-  // default one, with guesses about size and endianness.
-  const Target&
-  default_target() const;
+  // The Sized_target of the output file.  The caller must request the
+  // right size and endianness.
+  template<int size, bool big_endian>
+  Sized_target<size, big_endian>*
+  sized_target() const
+  {
+    gold_assert(this->target_valid());
+    return static_cast<Sized_target<size, big_endian>*>(this->target_);
+  }
+
+  // Clear the target, for testing.
+  void
+  clear_target()
+  { this->target_ = NULL; }
 
   // Return true if TARGET is compatible with the current target.
   bool
@@ -140,7 +152,7 @@ class Parameters
  private:
   Errors* errors_;
   const General_options* options_;
-  const Target* target_;
+  Target* target_;
   bool doing_static_link_valid_;
   bool doing_static_link_;
   int debug_;
@@ -159,11 +171,22 @@ extern void
 set_parameters_options(const General_options* options);
 
 extern void
-set_parameters_target(const Target* target);
+set_parameters_target(Target* target);
 
 extern void
 set_parameters_doing_static_link(bool doing_static_link);
-  
+
+// Ensure that the target to be valid by using the default target if
+// necessary.
+
+extern void
+parameters_force_valid_target();
+
+// Clear the current target, for testing.
+
+extern void
+parameters_clear_target();
+
 // Return whether we are doing a particular debugging type.  The
 // argument is one of the flags from debug.h.
 
Index: plugin.cc
===================================================================
RCS file: /cvs/src/src/gold/plugin.cc,v
retrieving revision 1.17
diff -p -u -r1.17 plugin.cc
--- plugin.cc	5 Aug 2009 20:51:56 -0000	1.17
+++ plugin.cc	30 Sep 2009 21:53:39 -0000
@@ -980,17 +980,14 @@ message(int level, const char * format, 
 static Pluginobj*
 make_sized_plugin_object(Input_file* input_file, off_t offset, off_t filesize)
 {
-  Target* target;
   Pluginobj* obj = NULL;
 
-  if (parameters->target_valid())
-    target = const_cast<Target*>(&parameters->target());
-  else
-    target = const_cast<Target*>(&parameters->default_target());
+  parameters_force_valid_target();
+  const Target& target(parameters->target());
 
-  if (target->get_size() == 32)
+  if (target.get_size() == 32)
     {
-      if (target->is_big_endian())
+      if (target.is_big_endian())
 #ifdef HAVE_TARGET_32_BIG
         obj = new Sized_pluginobj<32, true>(input_file->filename(),
                                             input_file, offset, filesize);
@@ -1009,9 +1006,9 @@ make_sized_plugin_object(Input_file* inp
 		   input_file->filename().c_str());
 #endif
     }
-  else if (target->get_size() == 64)
+  else if (target.get_size() == 64)
     {
-      if (target->is_big_endian())
+      if (target.is_big_endian())
 #ifdef HAVE_TARGET_64_BIG
         obj = new Sized_pluginobj<64, true>(input_file->filename(),
                                             input_file, offset, filesize);
@@ -1032,7 +1029,6 @@ make_sized_plugin_object(Input_file* inp
     }
 
   gold_assert(obj != NULL);
-  obj->set_target(target);
   return obj;
 }
 
Index: readsyms.cc
===================================================================
RCS file: /cvs/src/src/gold/readsyms.cc,v
retrieving revision 1.37
diff -p -u -r1.37 readsyms.cc
--- readsyms.cc	15 May 2009 17:01:04 -0000	1.37
+++ readsyms.cc	30 Sep 2009 21:53:39 -0000
@@ -266,13 +266,16 @@ Read_symbols::do_read_symbols(Workqueue*
     {
       // This is an ELF object.
 
-      bool unconfigured;
+      bool unconfigured = false;
+      bool* punconfigured = (input_file->will_search_for()
+			     ? &unconfigured
+			     : NULL);
       Object* obj = make_elf_object(input_file->filename(),
 				    input_file, 0, ehdr, read_size,
-				    &unconfigured);
+				    punconfigured);
       if (obj == NULL)
 	{
-	  if (unconfigured && input_file->will_search_for())
+	  if (unconfigured)
 	    {
 	      Read_symbols::incompatible_warning(this->input_argument_,
 						 input_file);
@@ -447,7 +450,7 @@ Add_symbols::locks(Task_locker* tl)
 // Add the symbols in the object to the symbol table.
 
 void
-Add_symbols::run(Workqueue* workqueue)
+Add_symbols::run(Workqueue*)
 {
   Pluginobj* pluginobj = this->object_->pluginobj();
   if (pluginobj != NULL)
@@ -456,21 +459,7 @@ Add_symbols::run(Workqueue* workqueue)
       return;
     }
 
-  // If this file has an incompatible format, try for another file
-  // with the same name.
-  if (this->object_->searched_for()
-      && !parameters->is_compatible_target(this->object_->target()))
-    {
-      Read_symbols::incompatible_warning(this->input_argument_,
-					 this->object_->input_file());
-      Read_symbols::requeue(workqueue, this->input_objects_, this->symtab_,
-			    this->layout_, this->dirpath_, this->dirindex_,
-			    this->mapfile_, this->input_argument_,
-			    this->input_group_, this->next_blocker_);
-      this->object_->release();
-      delete this->object_;
-    }
-  else if (!this->input_objects_->add_object(this->object_))
+  if (!this->input_objects_->add_object(this->object_))
     {
       this->object_->release();
       delete this->object_;
Index: reloc.cc
===================================================================
RCS file: /cvs/src/src/gold/reloc.cc,v
retrieving revision 1.44
diff -p -u -r1.44 reloc.cc
--- reloc.cc	5 Aug 2009 20:51:56 -0000	1.44
+++ reloc.cc	30 Sep 2009 21:53:39 -0000
@@ -363,7 +363,8 @@ Sized_relobj<size, big_endian>::do_gc_pr
 					       Layout* layout,
 					       Read_relocs_data* rd)
 {  
-  Sized_target<size, big_endian>* target = this->sized_target();
+  Sized_target<size, big_endian>* target =
+    parameters->sized_target<size, big_endian>();
 
   const unsigned char* local_symbols;
   if (rd->local_symbols == NULL)
@@ -403,7 +404,8 @@ Sized_relobj<size, big_endian>::do_scan_
 					       Layout* layout,
 					       Read_relocs_data* rd)
 {
-  Sized_target<size, big_endian>* target = this->sized_target();
+  Sized_target<size, big_endian>* target =
+    parameters->sized_target<size, big_endian>();
 
   const unsigned char* local_symbols;
   if (rd->local_symbols == NULL)
@@ -802,7 +804,8 @@ Sized_relobj<size, big_endian>::relocate
     Views* pviews)
 {
   unsigned int shnum = this->shnum();
-  Sized_target<size, big_endian>* target = this->sized_target();
+  Sized_target<size, big_endian>* target =
+    parameters->sized_target<size, big_endian>();
 
   const Output_sections& out_sections(this->output_sections());
   const std::vector<Address>& out_offsets(this->section_offsets_);
Index: resolve.cc
===================================================================
RCS file: /cvs/src/src/gold/resolve.cc,v
retrieving revision 1.42
diff -p -u -r1.42 resolve.cc
--- resolve.cc	19 Aug 2009 17:53:50 -0000	1.42
+++ resolve.cc	30 Sep 2009 21:53:39 -0000
@@ -244,10 +244,10 @@ Symbol_table::resolve(Sized_symbol<size>
 		      unsigned int orig_st_shndx,
 		      Object* object, const char* version)
 {
-  if (object->target()->has_resolve())
+  if (parameters->target().has_resolve())
     {
       Sized_target<size, big_endian>* sized_target;
-      sized_target = object->sized_target<size, big_endian>();
+      sized_target = parameters->sized_target<size, big_endian>();
       sized_target->resolve(to, sym, object, version);
       return;
     }
Index: symtab.cc
===================================================================
RCS file: /cvs/src/src/gold/symtab.cc,v
retrieving revision 1.122
diff -p -u -r1.122 symtab.cc
--- symtab.cc	18 Sep 2009 20:02:21 -0000	1.122
+++ symtab.cc	30 Sep 2009 21:53:39 -0000
@@ -688,13 +688,12 @@ Symbol_table::force_local(Symbol* sym)
 // option was used.
 
 const char*
-Symbol_table::wrap_symbol(Object* object, const char* name,
-			  Stringpool::Key* name_key)
+Symbol_table::wrap_symbol(const char* name, Stringpool::Key* name_key)
 {
   // For some targets, we need to ignore a specific character when
   // wrapping, and add it back later.
   char prefix = '\0';
-  if (name[0] == object->target()->wrap_char())
+  if (name[0] == parameters->target().wrap_char())
     {
       prefix = name[0];
       ++name;
@@ -864,7 +863,7 @@ Symbol_table::add_from_object(Object* ob
   if (orig_st_shndx == elfcpp::SHN_UNDEF
       && parameters->options().any_wrap())
     {
-      const char* wrap_name = this->wrap_symbol(object, name, &name_key);
+      const char* wrap_name = this->wrap_symbol(name, &name_key);
       if (wrap_name != name)
 	{
 	  // If we see a reference to malloc with version GLIBC_2.0,
@@ -945,7 +944,7 @@ Symbol_table::add_from_object(Object* ob
 	  was_common = false;
 
 	  Sized_target<size, big_endian>* target =
-	    object->sized_target<size, big_endian>();
+	    parameters->sized_target<size, big_endian>();
 	  if (!target->has_make_symbol())
 	    ret = new Sized_symbol<size>();
 	  else
@@ -1033,7 +1032,6 @@ Symbol_table::add_from_relobj(
 {
   *defined = 0;
 
-  gold_assert(size == relobj->target()->get_size());
   gold_assert(size == parameters->target().get_size());
 
   const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
@@ -1272,7 +1270,6 @@ Symbol_table::add_from_dynobj(
 {
   *defined = 0;
 
-  gold_assert(size == dynobj->target()->get_size());
   gold_assert(size == parameters->target().get_size());
 
   if (dynobj->just_symbols())
@@ -1661,11 +1658,8 @@ Symbol_table::define_special_symbol(cons
     sym = new Sized_symbol<size>();
   else
     {
-      gold_assert(target.get_size() == size);
-      gold_assert(target.is_big_endian() ? big_endian : !big_endian);
-      typedef Sized_target<size, big_endian> My_target;
-      const My_target* sized_target =
-          static_cast<const My_target*>(&target);
+      Sized_target<size, big_endian>* sized_target =
+	parameters->sized_target<size, big_endian>();
       sym = sized_target->make_symbol();
       if (sym == NULL)
         return NULL;
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gold/symtab.h,v
retrieving revision 1.90
diff -p -u -r1.90 symtab.h
--- symtab.h	5 Aug 2009 20:51:56 -0000	1.90
+++ symtab.h	30 Sep 2009 21:53:39 -0000
@@ -1450,7 +1450,7 @@ class Symbol_table
 
   // Adjust NAME and *NAME_KEY for wrapping.
   const char*
-  wrap_symbol(Object* object, const char*, Stringpool::Key* name_key);
+  wrap_symbol(const char* name, Stringpool::Key* name_key);
 
   // Whether we should override a symbol, based on flags in
   // resolve.cc.
Index: target.cc
===================================================================
RCS file: /cvs/src/src/gold/target.cc,v
retrieving revision 1.2
diff -p -u -r1.2 target.cc
--- target.cc	18 Aug 2009 23:49:29 -0000	1.2
+++ target.cc	30 Sep 2009 21:53:39 -0000
@@ -73,14 +73,14 @@ Target::do_make_elf_object_implementatio
     {
       Sized_relobj<size, big_endian>* obj =
 	new Sized_relobj<size, big_endian>(name, input_file, offset, ehdr);
-      obj->setup(this);
+      obj->setup();
       return obj;
     }
   else if (et == elfcpp::ET_DYN)
     {
       Sized_dynobj<size, big_endian>* obj =
 	new Sized_dynobj<size, big_endian>(name, input_file, offset, ehdr);
-      obj->setup(this);
+      obj->setup();
       return obj;
     }
   else
Index: testsuite/binary_unittest.cc
===================================================================
RCS file: /cvs/src/src/gold/testsuite/binary_unittest.cc,v
retrieving revision 1.6
diff -p -u -r1.6 binary_unittest.cc
--- testsuite/binary_unittest.cc	14 Mar 2009 05:56:46 -0000	1.6
+++ testsuite/binary_unittest.cc	30 Sep 2009 21:53:39 -0000
@@ -44,8 +44,9 @@ using namespace gold;
 
 template<int size, bool big_endian>
 bool
-Sized_binary_test(Target* target)
+Sized_binary_test()
 {
+  parameters_clear_target();
   // We need a pretend Task.
   const Task* task = reinterpret_cast<const Task*>(-1);
 
@@ -73,7 +74,6 @@ Sized_binary_test(Target* target)
     return false;
 
   CHECK(!object->is_dynamic());
-  CHECK(object->target() == target);
   CHECK(object->shnum() == 5);
   CHECK(object->section_name(1) == ".data");
   CHECK(object->section_flags(1) == (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE));
@@ -125,23 +125,27 @@ Binary_test(Test_report*)
   int fail = 0;
 
 #ifdef HAVE_TARGET_32_LITTLE
-  if (!Sized_binary_test<32, false>(target_test_pointer_32_little))
+  if (!Sized_binary_test<32, false>())
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_32_little);
 #endif
 
 #ifdef HAVE_TARGET_32_BIG
-  if (!Sized_binary_test<32, true>(target_test_pointer_32_big))
+  if (!Sized_binary_test<32, true>())
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_32_big);
 #endif
 
 #ifdef HAVE_TARGET_64_LITTLE
-  if (!Sized_binary_test<64, false>(target_test_pointer_64_little))
+  if (!Sized_binary_test<64, false>())
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_64_little);
 #endif
 
 #ifdef HAVE_TARGET_64_BIG
-  if (!Sized_binary_test<64, true>(target_test_pointer_64_big))
+  if (!Sized_binary_test<64, true>())
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_64_big);
 #endif
 
   return fail == 0;
Index: testsuite/object_unittest.cc
===================================================================
RCS file: /cvs/src/src/gold/testsuite/object_unittest.cc,v
retrieving revision 1.6
diff -p -u -r1.6 object_unittest.cc
--- testsuite/object_unittest.cc	14 Mar 2009 05:56:46 -0000	1.6
+++ testsuite/object_unittest.cc	30 Sep 2009 21:53:39 -0000
@@ -36,9 +36,9 @@ using namespace gold;
 
 template<int size, bool big_endian>
 bool
-Sized_object_test(const unsigned char* test_file, unsigned int test_file_size,
-		  Target* target_test_pointer)
+Sized_object_test(const unsigned char* test_file, unsigned int test_file_size)
 {
+  parameters_clear_target();
   // We need a pretend Task.
   const Task* task = reinterpret_cast<const Task*>(-1);
   Input_file input_file(task, "test.o", test_file, test_file_size);
@@ -46,7 +46,6 @@ Sized_object_test(const unsigned char* t
 				   test_file, test_file_size, NULL);
   CHECK(object->name() == "test.o");
   CHECK(!object->is_dynamic());
-  CHECK(object->target() == target_test_pointer);
   CHECK(object->is_locked());
   object->unlock(task);
   CHECK(!object->is_locked());
@@ -67,30 +66,30 @@ Object_test(Test_report*)
 
 #ifdef HAVE_TARGET_32_LITTLE
   if (!Sized_object_test<32, false>(test_file_1_32_little,
-				    test_file_1_size_32_little,
-				    target_test_pointer_32_little))
+				    test_file_1_size_32_little))
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_32_little);
 #endif
 
 #ifdef HAVE_TARGET_32_BIG
   if (!Sized_object_test<32, true>(test_file_1_32_big,
-				   test_file_1_size_32_big,
-				   target_test_pointer_32_big))
+				   test_file_1_size_32_big))
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_32_big);
 #endif
 
 #ifdef HAVE_TARGET_64_LITTLE
   if (!Sized_object_test<64, false>(test_file_1_64_little,
-				    test_file_1_size_64_little,
-				    target_test_pointer_64_little))
+				    test_file_1_size_64_little))
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_64_little);
 #endif
 
 #ifdef HAVE_TARGET_64_BIG
   if (!Sized_object_test<64, true>(test_file_1_64_big,
-				   test_file_1_size_64_big,
-				   target_test_pointer_64_big))
+				   test_file_1_size_64_big))
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_64_big);
 #endif
 
   return fail == 0;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]