]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Allow target to derive from Copy_relocs class.
authorCary Coutant <ccoutant@google.com>
Tue, 15 Apr 2014 18:19:18 +0000 (11:19 -0700)
committerCary Coutant <ccoutant@google.com>
Tue, 15 Apr 2014 18:56:18 +0000 (11:56 -0700)
2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Remove and
inline into ...
(Copy_relocs::emit): ... here.
* copy-relocs.h (Copy_reloc_entry): Change from class to struct.
(Copy_reloc_entry::make_copy_reloc): Change from private to protected.
(Copy_reloc_entry::entries_): Change from private to protected.

gold/ChangeLog
gold/copy-relocs.cc
gold/copy-relocs.h

index 4db6d85186613fbf7846453555783b237c3990de..4ddef9a37d7eef7093810e924134b932935a9f4a 100644 (file)
@@ -1,3 +1,12 @@
+2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>
+
+       * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Remove and
+       inline into ...
+       (Copy_relocs::emit): ... here.
+       * copy-relocs.h (Copy_reloc_entry): Change from class to struct.
+       (Copy_reloc_entry::make_copy_reloc): Change from private to protected.
+       (Copy_reloc_entry::entries_): Change from private to protected.
+
 2014-04-02  Sriraman Tallam  <tmsriram@google.com>
 
        * icf.cc (get_section_contents): Replace copies of reloc
index 651bd1f0ef21b806c51a627e722c12c4548e8164..41b65631aad8f9f69c592c3519a9aa5c5c06d915 100644 (file)
 namespace gold
 {
 
-// Copy_relocs::Copy_reloc_entry methods.
-
-// Emit the reloc if appropriate.
-
-template<int sh_type, int size, bool big_endian>
-void
-Copy_relocs<sh_type, size, big_endian>::Copy_reloc_entry::emit(
-    Output_data_reloc<sh_type, true, size, big_endian>* reloc_section)
-{
-  // If the symbol is no longer defined in a dynamic object, then we
-  // emitted a COPY relocation, and we do not want to emit this
-  // dynamic relocation.
-  if (this->sym_->is_from_dynobj())
-    reloc_section->add_global_generic(this->sym_, this->reloc_type_,
-                                     this->output_section_, this->relobj_,
-                                     this->shndx_, this->address_,
-                                     this->addend_);
-}
-
 // Copy_relocs methods.
 
 // Handle a relocation against a symbol which may force us to generate
@@ -215,7 +196,18 @@ Copy_relocs<sh_type, size, big_endian>::emit(
   for (typename Copy_reloc_entries::iterator p = this->entries_.begin();
        p != this->entries_.end();
        ++p)
-    p->emit(reloc_section);
+    {
+      Copy_reloc_entry& entry = *p;
+
+      // If the symbol is no longer defined in a dynamic object, then we
+      // emitted a COPY relocation, and we do not want to emit this
+      // dynamic relocation.
+      if (entry.sym_->is_from_dynobj())
+        reloc_section->add_global_generic(entry.sym_, entry.reloc_type_,
+                                          entry.output_section_, entry.relobj_,
+                                          entry.shndx_, entry.address_,
+                                          entry.addend_);
+    }
 
   // We no longer need the saved information.
   this->entries_.clear();
index 2ec7a143ca641ceb4c1edbf7e7d125a4b1ff9306..800c0e7eddfe586643fa515deba94bf15c7d2f9f 100644 (file)
@@ -54,7 +54,7 @@ class Copy_relocs
 
  public:
   Copy_relocs(unsigned int copy_reloc_type)
-    : copy_reloc_type_(copy_reloc_type), dynbss_(NULL), entries_()
+    : entries_(), copy_reloc_type_(copy_reloc_type), dynbss_(NULL)
   { }
 
   // This is called while scanning relocs if we see a relocation
@@ -87,16 +87,15 @@ class Copy_relocs
                  Output_data*, off_t,
                  Output_data_reloc<sh_type, true, size, big_endian>*);
 
- private:
+ protected:
   typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
   typedef typename elfcpp::Elf_types<size>::Elf_Addr Addend;
 
   // This POD class holds the relocations we are saving.  We will emit
   // these relocations if it turns out that the symbol does not
   // require a COPY relocation.
-  class Copy_reloc_entry
+  struct Copy_reloc_entry
   {
-   public:
     Copy_reloc_entry(Symbol* sym, unsigned int reloc_type,
                     Sized_relobj_file<size, big_endian>* relobj,
                      unsigned int shndx,
@@ -107,13 +106,6 @@ class Copy_relocs
        address_(address), addend_(addend)
     { }
 
-    // Emit this reloc if appropriate.  This is called after we have
-    // scanned all the relocations, so we know whether we emitted a
-    // COPY relocation for SYM_.
-    void
-    emit(Output_data_reloc<sh_type, true, size, big_endian>*);
-
-   private:
     Symbol* sym_;
     unsigned int reloc_type_;
     Sized_relobj_file<size, big_endian>* relobj_;
@@ -123,20 +115,24 @@ class Copy_relocs
     Addend addend_;
   };
 
+  // Make a new COPY reloc and emit it.
+  void
+  make_copy_reloc(Symbol_table*, Layout*, Sized_symbol<size>*,
+                 Output_data_reloc<sh_type, true, size, big_endian>*);
+
   // A list of relocs to be saved.
   typedef std::vector<Copy_reloc_entry> Copy_reloc_entries;
 
+  // The list of relocs we are saving.
+  Copy_reloc_entries entries_;
+
+ private:
   // Return whether we need a COPY reloc.
   bool
   need_copy_reloc(Sized_symbol<size>* gsym,
                   Sized_relobj_file<size, big_endian>* object,
                  unsigned int shndx) const;
 
-  // Make a new COPY reloc and emit it.
-  void
-  make_copy_reloc(Symbol_table*, Layout*, Sized_symbol<size>*,
-                 Output_data_reloc<sh_type, true, size, big_endian>*);
-
   // Save a reloc against SYM for possible emission later.
   void
   save(Symbol*, Sized_relobj_file<size, big_endian>*, unsigned int shndx,
@@ -147,8 +143,6 @@ class Copy_relocs
   // The dynamic BSS data which goes into the .bss section.  This is
   // where variables which require COPY relocations are placed.
   Output_data_space* dynbss_;
-  // The list of relocs we are saving.
-  Copy_reloc_entries entries_;
 };
 
 } // End namespace gold.