Ignore version scripts for relocatable links.
authorIan Lance Taylor <iant@google.com>
Thu, 7 Feb 2008 05:45:07 +0000 (05:45 +0000)
committerIan Lance Taylor <iant@google.com>
Thu, 7 Feb 2008 05:45:07 +0000 (05:45 +0000)
gold/main.cc
gold/script.cc
gold/script.h

index 2f68e06ec5e0cc7d04f80fe380ce3a3e37df7dfa..6e356581701d89230750487d6dc086622517c20b 100644 (file)
@@ -166,6 +166,16 @@ main(int argc, char** argv)
   write_debug_script(command_line.options().output_file_name(),
                      program_name, args.c_str());
 
+  // The GNU linker ignores version scripts when generating
+  // relocatable output.  If we are not compatible, then we break the
+  // Linux kernel build, which uses a linker script with -r which must
+  // not force symbols to be local.  It would actually be useful to
+  // permit symbols to be forced local with -r, though, as it would
+  // permit some linker optimizations.  Perhaps we need yet another
+  // option to control this.  FIXME.
+  if (parameters->output_is_object())
+    command_line.script_options()->version_script_info()->clear();
+
   // The work queue.
   Workqueue workqueue(command_line.options());
 
index 7cf3c7e6e104dcc121c9003f8079e310931bd756..fc510a5817fd3fd39b8a7065698a8b3cf8ee8fce 100644 (file)
@@ -1738,13 +1738,22 @@ struct Version_tree {
 };
 
 Version_script_info::~Version_script_info()
+{
+  this->clear();
+}
+
+void
+Version_script_info::clear()
 {
   for (size_t k = 0; k < dependency_lists_.size(); ++k)
     delete dependency_lists_[k];
+  this->dependency_lists_.clear();
   for (size_t k = 0; k < version_trees_.size(); ++k)
     delete version_trees_[k];
+  this->version_trees_.clear();
   for (size_t k = 0; k < expression_lists_.size(); ++k)
     delete expression_lists_[k];
+  this->expression_lists_.clear();
 }
 
 std::vector<std::string>
index 09f104f66c2805cb5c81dc2485025078448fc7df..81e7ab8d36cda1f3ff29759a41af32779ca7ddc4 100644 (file)
@@ -118,6 +118,10 @@ class Version_script_info
  public:
   ~Version_script_info();
 
+  // Clear everything.
+  void
+  clear();
+
   // Return whether any version were defined in the version script.
   bool
   empty() const