* script.cc (Script_options::add_symbol_assignment): Always add a
authorIan Lance Taylor <ian@airs.com>
Fri, 16 Oct 2009 05:19:07 +0000 (05:19 +0000)
committerIan Lance Taylor <ian@airs.com>
Fri, 16 Oct 2009 05:19:07 +0000 (05:19 +0000)
dot assginment to script_sections_.
* script-sections.cc (Script_sections::add_dot_assignment):
Initialize if necessary.

gold/ChangeLog
gold/script-sections.cc
gold/script.cc

index ea864a75746371af4516690c5e6564c9ee00e3b2..cb3254933cd4dd2c776861af0c192dc9a3f2699f 100644 (file)
@@ -1,5 +1,10 @@
 2009-10-15  Ian Lance Taylor  <iant@google.com>
 
+       * script.cc (Script_options::add_symbol_assignment): Always add a
+       dot assginment to script_sections_.
+       * script-sections.cc (Script_sections::add_dot_assignment):
+       Initialize if necessary.
+
        * layout.cc (Layout::relaxation_loop_body): Don't crash if we see
        program headers with no load segment if there is a linker script.
 
index 7ecf1424dd401c7ef68ba3d11e3b1fafa632ba98..a541e9aa13ed3756ed11860990f70d80c9d965bd 100644 (file)
@@ -2540,6 +2540,15 @@ Script_sections::add_dot_assignment(Expression* val)
     this->output_section_->add_dot_assignment(val);
   else
     {
+      // The GNU linker permits assignments to . to appears outside of
+      // a SECTIONS clause, and treats it as appearing inside, so
+      // sections_elements_ may be NULL here.
+      if (this->sections_elements_ == NULL)
+       {
+         this->sections_elements_ = new Sections_elements;
+         this->saw_sections_clause_ = true;
+       }
+
       Sections_element* p = new Sections_element_dot_assignment(val);
       this->sections_elements_->push_back(p);
     }
index de6f4fcff16e3c193bafa0c2779011ee61cce2c6..d0ffe41a6158a479c6dbdb6d5cc835d4e95d487a 100644 (file)
@@ -1,6 +1,6 @@
 // script.cc -- handle linker scripts for gold.
 
-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -1070,10 +1070,11 @@ Script_options::add_symbol_assignment(const char* name, size_t length,
     {
       if (provide || hidden)
        gold_error(_("invalid use of PROVIDE for dot symbol"));
-      if (!this->script_sections_.in_sections_clause())
-       gold_error(_("invalid assignment to dot outside of SECTIONS"));
-      else
-       this->script_sections_.add_dot_assignment(value);
+
+      // The GNU linker permits assignments to dot outside of SECTIONS
+      // clauses and treats them as occurring inside, so we don't
+      // check in_sections_clause here.
+      this->script_sections_.add_dot_assignment(value);
     }
 }