]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* gold/incremental.cc (Sized_incremental_binary::do_process_got_plt):
authorCary Coutant <ccoutant@google.com>
Wed, 4 Jan 2012 00:18:23 +0000 (00:18 +0000)
committerCary Coutant <ccoutant@google.com>
Wed, 4 Jan 2012 00:18:23 +0000 (00:18 +0000)
Use abstract base class for GOT.
* gold/output.h (class Output_data_got_base): New abstract base class.
(class Output_data_got): Derive from new base class, adjust ctors.
(Output_data_got::reserve_slot): Make virtual; rename to
do_reserve_slot; Adjust callers.
* gold/target.h (Sized_target::init_got_plt_for_update): Return
pointer to abstract base class.
* gold/x86_64.cc (Target_x86_64::init_got_plt_for_update): Likewise.

gold/ChangeLog
gold/incremental.cc
gold/output.cc
gold/output.h
gold/target.h
gold/x86_64.cc

index 790d8d381df406280bfd861765ee7605fc7c2c92..4adbecfcdfc79e07b8a86d3632d072b5dbde2e0d 100644 (file)
@@ -1,3 +1,15 @@
+2012-01-03  Cary Coutant  <ccoutant@google.com>
+
+       * gold/incremental.cc (Sized_incremental_binary::do_process_got_plt):
+       Use abstract base class for GOT.
+       * gold/output.h (class Output_data_got_base): New abstract base class.
+       (class Output_data_got): Derive from new base class, adjust ctors.
+       (Output_data_got::reserve_slot): Make virtual; rename to
+       do_reserve_slot; Adjust callers.
+       * gold/target.h (Sized_target::init_got_plt_for_update): Return
+       pointer to abstract base class.
+       * gold/x86_64.cc (Target_x86_64::init_got_plt_for_update): Likewise.
+
 2011-12-18  Ian Lance Taylor  <iant@google.com>
 
        * object.h (Relobj::local_symbol_value): New function.
index 75e44c5707f996cd44719459165fd6bfe5a4c3e3..39bad37b5e64e5d7ea4ee7bed62198c0cf7eeb9e 100644 (file)
@@ -632,7 +632,7 @@ Sized_incremental_binary<size, big_endian>::do_process_got_plt(
   // Tell the target how big the GOT and PLT sections are.
   unsigned int got_count = got_plt_reader.get_got_entry_count();
   unsigned int plt_count = got_plt_reader.get_plt_entry_count();
-  Output_data_got<size, big_endian>* got =
+  Output_data_got_base* got =
       target->init_got_plt_for_update(symtab, layout, got_count, plt_count);
 
   // Read the GOT entries from the base file and build the outgoing GOT.
index 6e46fd5dca8ce9dd6df5b4badcdeef93365677ff..ca190392d14f4b88d6a41ac46620988031460261 100644 (file)
@@ -1582,7 +1582,7 @@ Output_data_got<size, big_endian>::reserve_local(
     unsigned int sym_index,
     unsigned int got_type)
 {
-  this->reserve_slot(i);
+  this->do_reserve_slot(i);
   object->set_local_got_offset(sym_index, got_type, this->got_offset(i));
 }
 
@@ -1595,7 +1595,7 @@ Output_data_got<size, big_endian>::reserve_global(
     Symbol* gsym,
     unsigned int got_type)
 {
-  this->reserve_slot(i);
+  this->do_reserve_slot(i);
   gsym->set_got_offset(got_type, this->got_offset(i));
 }
 
index db38236f3de999fdb9d5a8216e9a5a08b1041174..838ca3d4dd6c113bb27df26a6088cfeeda585f55 100644 (file)
@@ -2151,20 +2151,42 @@ class Output_data_group : public Output_section_data
 // needed.  The GOT_SIZE template parameter is the size in bits of a
 // GOT entry, typically 32 or 64.
 
+class Output_data_got_base : public Output_section_data_build
+{
+ public:
+  Output_data_got_base(uint64_t align)
+    : Output_section_data_build(align)
+  { }
+
+  Output_data_got_base(off_t data_size, uint64_t align)
+    : Output_section_data_build(data_size, align)
+  { }
+
+  // Reserve the slot at index I in the GOT.
+  void
+  reserve_slot(unsigned int i)
+  { this->do_reserve_slot(i); }
+
+ protected:
+  // Reserve the slot at index I in the GOT.
+  virtual void
+  do_reserve_slot(unsigned int i) = 0;
+};
+
 template<int got_size, bool big_endian>
-class Output_data_got : public Output_section_data_build
+class Output_data_got : public Output_data_got_base
 {
  public:
   typedef typename elfcpp::Elf_types<got_size>::Elf_Addr Valtype;
 
   Output_data_got()
-    : Output_section_data_build(Output_data::default_alignment_for_size(got_size)),
+    : Output_data_got_base(Output_data::default_alignment_for_size(got_size)),
       entries_(), free_list_()
   { }
 
   Output_data_got(off_t data_size)
-    : Output_section_data_build(data_size,
-                               Output_data::default_alignment_for_size(got_size)),
+    : Output_data_got_base(data_size,
+                          Output_data::default_alignment_for_size(got_size)),
       entries_(), free_list_()
   {
     // For an incremental update, we have an existing GOT section.
@@ -2231,11 +2253,6 @@ class Output_data_got : public Output_section_data_build
     return got_offset;
   }
 
-  // Reserve a slot in the GOT.
-  void
-  reserve_slot(unsigned int i)
-  { this->free_list_.remove(i * got_size / 8, (i + 1) * got_size / 8); }
-
   // Reserve a slot in the GOT for a local symbol.
   void
   reserve_local(unsigned int i, Relobj* object, unsigned int sym_index,
@@ -2255,6 +2272,11 @@ class Output_data_got : public Output_section_data_build
   do_print_to_mapfile(Mapfile* mapfile) const
   { mapfile->print_output_data(this, _("** GOT")); }
 
+  // Reserve the slot at index I in the GOT.
+  virtual void
+  do_reserve_slot(unsigned int i)
+  { this->free_list_.remove(i * got_size / 8, (i + 1) * got_size / 8); }
+
  private:
   // This POD class holds a single GOT entry.
   class Got_entry
index a378120325cbf4b468051a70eb19cfd9404ec42d..10354273d2965d145862bf52e9b89bb7afbf7e28 100644 (file)
@@ -56,8 +56,7 @@ template<int size>
 class Sized_symbol;
 class Symbol_table;
 class Output_data;
-template<int size, bool big_endian>
-class Output_data_got;
+class Output_data_got_base;
 class Output_section;
 class Input_objects;
 class Task;
@@ -845,7 +844,7 @@ class Sized_target : public Target
   // Create the GOT and PLT sections for an incremental update.
   // A target needs to implement this to support incremental linking.
 
-  virtual Output_data_got<size, big_endian>*
+  virtual Output_data_got_base*
   init_got_plt_for_update(Symbol_table*,
                          Layout*,
                          unsigned int /* got_count */,
index 552e9d10c96d77dfe1f9fa620a9e9216cb374d8a..eeb532beae2855cb925e12e4e3e0ce0ffac33f3c 100644 (file)
@@ -425,7 +425,7 @@ class Target_x86_64 : public Sized_target<64, false>
   plt_entry_size() const;
 
   // Create the GOT section for an incremental update.
-  Output_data_got<64, false>*
+  Output_data_got_base*
   init_got_plt_for_update(Symbol_table* symtab,
                          Layout* layout,
                          unsigned int got_count,
@@ -1463,7 +1463,7 @@ Target_x86_64::plt_entry_size() const
 
 // Create the GOT and PLT sections for an incremental update.
 
-Output_data_got<64, false>*
+Output_data_got_base*
 Target_x86_64::init_got_plt_for_update(Symbol_table* symtab,
                                       Layout* layout,
                                       unsigned int got_count,