2010-03-19 Doug Kwan <dougkwan@google.com>
authorDoug Kwan <dougkwan@google.com>
Fri, 19 Mar 2010 19:11:21 +0000 (19:11 +0000)
committerDoug Kwan <dougkwan@google.com>
Fri, 19 Mar 2010 19:11:21 +0000 (19:11 +0000)
* arm.cc (Stub_table::Stub_table): Initialize new data members
Stub_table::reloc_stubs_size_ and Stub_table::reloc_stubs_addralign_.
(Stub_table::add_reloc_stub): Assign stub offset and update
Stub_table::reloc_stubs_size_ and Stub_table::reloc_stubs_addralign_.
(Stub_table::reloc_stubs_size_, Stub_table::reloc_stubs_addralign_):
New data members.
  (Stub_table::update_data_size_and_addralign): Use
Stub_table::reloc_stubs_size_ and Stub_table::reloc_stubs_addralign_
instead of going over all reloc stubs.
  (Stub_table::finalize_stubs): Do not assign reloc stub offsets.
* stringpool.cc (Stringpool_template::Stringpool_template): Initialize
Stringpool_template::offset_ to size of Stringpool_char.
  (Stringpool_template::new_key_offset): Remove code to initialize
Stringpool_template::offset_.
* stringpool.h (Stringpool_template::set_no_zero_null): Set
Stringpool_template::offset_ to zero.

gold/ChangeLog
gold/arm.cc
gold/stringpool.cc
gold/stringpool.h

index 8a92513d46837555e32f8ae0e45d70007a64b674..aa933e547a7dbb6b112680dcd20ef7a513b369cd 100644 (file)
@@ -1,3 +1,22 @@
+2010-03-19  Doug Kwan  <dougkwan@google.com>
+
+       * arm.cc (Stub_table::Stub_table): Initialize new data members
+       Stub_table::reloc_stubs_size_ and Stub_table::reloc_stubs_addralign_.
+       (Stub_table::add_reloc_stub): Assign stub offset and update
+       Stub_table::reloc_stubs_size_ and Stub_table::reloc_stubs_addralign_.
+       (Stub_table::reloc_stubs_size_, Stub_table::reloc_stubs_addralign_):
+       New data members.
+       (Stub_table::update_data_size_and_addralign): Use
+       Stub_table::reloc_stubs_size_ and Stub_table::reloc_stubs_addralign_
+       instead of going over all reloc stubs.
+       (Stub_table::finalize_stubs): Do not assign reloc stub offsets.
+       * stringpool.cc (Stringpool_template::Stringpool_template): Initialize
+       Stringpool_template::offset_ to size of Stringpool_char.
+       (Stringpool_template::new_key_offset): Remove code to initialize
+       Stringpool_template::offset_.
+       * stringpool.h (Stringpool_template::set_no_zero_null): Set
+       Stringpool_template::offset_ to zero.
+
 2010-03-15  Doug Kwan  <dougkwan@google.com>
 
        * stringpool.cc (Stringpool_template::Stringpool_template): Initialize
index e331fd3462a18d31a62f9be69c985a660abfe148..016b2cce3b580f674649ae5071884749289c2b22 100644 (file)
@@ -868,8 +868,9 @@ class Stub_table : public Output_data
 {
  public:
   Stub_table(Arm_input_section<big_endian>* owner)
-    : Output_data(), owner_(owner), reloc_stubs_(), cortex_a8_stubs_(),
-      arm_v4bx_stubs_(0xf), prev_data_size_(0), prev_addralign_(1)
+    : Output_data(), owner_(owner), reloc_stubs_(), reloc_stubs_size_(0),
+      reloc_stubs_addralign_(1), cortex_a8_stubs_(), arm_v4bx_stubs_(0xf),
+      prev_data_size_(0), prev_addralign_(1)
   { }
 
   ~Stub_table()
@@ -902,6 +903,15 @@ class Stub_table : public Output_data
     const Stub_template* stub_template = stub->stub_template();
     gold_assert(stub_template->type() == key.stub_type());
     this->reloc_stubs_[key] = stub;
+
+    // Assign stub offset early.  We can do this because we never remove
+    // reloc stubs and they are in the beginning of the stub table.
+    uint64_t align = stub_template->alignment();
+    this->reloc_stubs_size_ = align_address(this->reloc_stubs_size_, align);
+    stub->set_offset(this->reloc_stubs_size_);
+    this->reloc_stubs_size_ += stub_template->size();
+    this->reloc_stubs_addralign_ =
+      std::max(this->reloc_stubs_addralign_, align);
   }
 
   // Add a Cortex-A8 STUB that fixes up a THUMB branch at ADDRESS.
@@ -1010,6 +1020,10 @@ class Stub_table : public Output_data
   Arm_input_section<big_endian>* owner_;
   // The relocation stubs.
   Reloc_stub_map reloc_stubs_;
+  // Size of reloc stubs.
+  off_t reloc_stubs_size_;
+  // Maximum address alignment of reloc stubs.
+  uint64_t reloc_stubs_addralign_;
   // The cortex_a8_stubs.
   Cortex_a8_stub_list cortex_a8_stubs_;
   // The Arm V4BX relocation stubs.
@@ -4720,20 +4734,9 @@ template<bool big_endian>
 bool
 Stub_table<big_endian>::update_data_size_and_addralign()
 {
-  off_t size = 0;
-  unsigned addralign = 1;
-
   // Go over all stubs in table to compute data size and address alignment.
-  
-  for (typename Reloc_stub_map::const_iterator p = this->reloc_stubs_.begin();
-      p != this->reloc_stubs_.end();
-      ++p)
-    {
-      const Stub_template* stub_template = p->second->stub_template();
-      addralign = std::max(addralign, stub_template->alignment());
-      size = (align_address(size, stub_template->alignment())
-             + stub_template->size());
-    }
+  off_t size = this->reloc_stubs_size_;
+  unsigned addralign = this->reloc_stubs_addralign_;
 
   for (Cortex_a8_stub_list::const_iterator p = this->cortex_a8_stubs_.begin();
        p != this->cortex_a8_stubs_.end();
@@ -4778,19 +4781,7 @@ template<bool big_endian>
 void
 Stub_table<big_endian>::finalize_stubs()
 {
-  off_t off = 0;
-  for (typename Reloc_stub_map::const_iterator p = this->reloc_stubs_.begin();
-      p != this->reloc_stubs_.end();
-      ++p)
-    {
-      Reloc_stub* stub = p->second;
-      const Stub_template* stub_template = stub->stub_template();
-      uint64_t stub_addralign = stub_template->alignment();
-      off = align_address(off, stub_addralign);
-      stub->set_offset(off);
-      off += stub_template->size();
-    }
-
+  off_t off = this->reloc_stubs_size_;
   for (Cortex_a8_stub_list::const_iterator p = this->cortex_a8_stubs_.begin();
        p != this->cortex_a8_stubs_.end();
        ++p)
index bbbe975989366e5da2befcf62b7ccd4f045741ff..10d6d274e399d82c1cce24914f0bf81d695ae479 100644 (file)
@@ -36,7 +36,7 @@ namespace gold
 template<typename Stringpool_char>
 Stringpool_template<Stringpool_char>::Stringpool_template()
   : string_set_(), key_to_offset_(), strings_(), strtab_size_(0),
-    zero_null_(true), optimize_(false), offset_(0)
+    zero_null_(true), optimize_(false), offset_(sizeof(Stringpool_char))
 {
   if (parameters->options_valid() && parameters->options().optimize() >= 2)
     this->optimize_ = true;
@@ -238,9 +238,6 @@ template<typename Stringpool_char>
 void
 Stringpool_template<Stringpool_char>::new_key_offset(size_t length)
 {
-  if (this->key_to_offset_.size() == 0)
-    this->offset_ = this->zero_null_ ? sizeof(Stringpool_char) : 0;
-    
   section_offset_type offset;
   if (this->zero_null_ && length == 0)
     offset = 0;
index df3826d9eb02c25f5ba23239f03870780989740f..f353c9d9a2f87e0ddfe0b37f3a67f9f49125a711 100644 (file)
@@ -178,8 +178,10 @@ class Stringpool_template
   void
   set_no_zero_null()
   {
-    gold_assert(this->string_set_.empty());
+    gold_assert(this->string_set_.empty()
+               && this->offset_ == sizeof(Stringpool_char));
     this->zero_null_ = false;
+    this->offset_ = 0;
   }
 
   // Indicate that this string pool should be optimized, even if not