Allow target to set dynsym indexes.
authorCary Coutant <ccoutant@google.com>
Mon, 10 Mar 2014 20:33:20 +0000 (13:33 -0700)
committerCary Coutant <ccoutant@google.com>
Mon, 10 Mar 2014 20:33:20 +0000 (13:33 -0700)
2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* symtab.cc (Symbol_table::set_dynsym_indexes): Allow a target to set
dynsym indexes.
* target.h (Target::has_custom_set_dynsym_indexes): New function.
(Target::do_has_custom_set_dynsym_indexes): New function.
(Target::set_dynsym_indexes): New function.
(Target::do_set_dynsym_indexes): New function.

gold/ChangeLog
gold/symtab.cc
gold/target.h

index ddf18d67f8615c1f67a836f7c50ce2af271a06a9..2727bacc9262eb06ec1ec9d777a7c66904c7a9a6 100644 (file)
@@ -1,3 +1,12 @@
+2014-03-10  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>
+
+       * symtab.cc (Symbol_table::set_dynsym_indexes): Allow a target to set
+       dynsym indexes.
+       * target.h (Target::has_custom_set_dynsym_indexes): New function.
+       (Target::do_has_custom_set_dynsym_indexes): New function.
+       (Target::set_dynsym_indexes): New function.
+       (Target::do_set_dynsym_indexes): New function.
+
 2014-03-07  Alan Modra  <amodra@gmail.com>
 
        * powerpc.cc (Powerpc_relocate_functions::Overflow_check): Add
index 363653e5078260bb7096e815367bec7c953c3c39..87173b2ea6e98e44a35fabd1772da3a626bbd3d3 100644 (file)
@@ -2371,6 +2371,25 @@ Symbol_table::set_dynsym_indexes(unsigned int index,
 {
   std::vector<Symbol*> as_needed_sym;
 
+  // Allow a target to set dynsym indexes.
+  if (parameters->target().has_custom_set_dynsym_indexes())
+    {
+      std::vector<Symbol*> dyn_symbols;
+      for (Symbol_table_type::iterator p = this->table_.begin();
+           p != this->table_.end();
+           ++p)
+        {
+          Symbol* sym = p->second;
+          if (!sym->should_add_dynsym_entry(this))
+            sym->set_dynsym_index(-1U);
+          else
+            dyn_symbols.push_back(sym);
+        }
+
+      return parameters->target().set_dynsym_indexes(&dyn_symbols, index, syms,
+                                                     dynpool, versions, this);
+    }
+
   for (Symbol_table_type::iterator p = this->table_.begin();
        p != this->table_.end();
        ++p)
index 8dabc281ef58abc9b0c4a3ce33e4fc8fe60b8829..1be300af916461244616f3abc677c8616ba766b9 100644 (file)
@@ -36,6 +36,7 @@
 #include "elfcpp.h"
 #include "options.h"
 #include "parameters.h"
+#include "stringpool.h"
 #include "debug.h"
 
 namespace gold
@@ -61,6 +62,7 @@ class Output_section;
 class Input_objects;
 class Task;
 struct Symbol_location;
+class Versions;
 
 // The abstract class for target specific handling.
 
@@ -453,6 +455,21 @@ class Target
   entry_symbol_name() const
   { return this->pti_->entry_symbol_name; }
 
+  // Whether the target has a custom set_dynsym_indexes method.
+  bool
+  has_custom_set_dynsym_indexes() const
+  { return this->do_has_custom_set_dynsym_indexes(); }
+
+  // Custom set_dynsym_indexes method for a target.
+  unsigned int
+  set_dynsym_indexes(std::vector<Symbol*>* dyn_symbols, unsigned int index,
+                     std::vector<Symbol*>* syms, Stringpool* dynpool,
+                     Versions* versions, Symbol_table* symtab) const
+  {
+    return this->do_set_dynsym_indexes(dyn_symbols, index, syms, dynpool,
+                                       versions, symtab);
+  }
+
  protected:
   // This struct holds the constant information for a child class.  We
   // use a struct to avoid the overhead of virtual function calls for
@@ -724,6 +741,18 @@ class Target
   do_gc_mark_symbol(Symbol_table*, Symbol*) const
   { }
 
+  // This may be overridden by the child class.
+  virtual bool
+  do_has_custom_set_dynsym_indexes() const
+  { return false; }
+
+  // This may be overridden by the child class.
+  virtual unsigned int
+  do_set_dynsym_indexes(std::vector<Symbol*>*, unsigned int,
+                        std::vector<Symbol*>*, Stringpool*, Versions*,
+                        Symbol_table*) const
+  { gold_unreachable(); }
+
  private:
   // The implementations of the four do_make_elf_object virtual functions are
   // almost identical except for their sizes and endianness.  We use a template.
This page took 0.034867 seconds and 4 git commands to generate.