2010-03-08 Hui Zhu <teawater@gmail.com>
[binutils-gdb.git] / gold / merge.h
index c385a44e6674d12595c0a65d03df132bf950c26a..345b1154ebe17e6b95e847867222675b6ee46e0f 100644 (file)
@@ -1,6 +1,6 @@
 // merge.h -- handle section merging for gold  -*- C++ -*-
 
-// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -38,7 +38,7 @@ class Merge_map;
 // For each object with merge sections, we store an Object_merge_map.
 // This is used to map locations in input sections to a merged output
 // section.  The output section itself is not recorded here--it can be
-// found in the map_to_output_ field of the Object.
+// found in the output_sections_ field of the Object.
 
 class Object_merge_map
 {
@@ -219,6 +219,17 @@ class Output_merge_base : public Output_section_data
     : Output_section_data(addralign), merge_map_(), entsize_(entsize)
   { }
 
+  // Return the entry size.
+  uint64_t
+  entsize() const
+  { return this->entsize_; }
+
+  // Whether this is a merge string section.  This is only true of
+  // Output_merge_string.
+  bool
+  is_string()
+  { return this->do_is_string(); }
+
  protected:
   // Return the output offset for an input offset.
   bool
@@ -230,11 +241,6 @@ class Output_merge_base : public Output_section_data
   bool
   do_is_merge_section_for(const Relobj*, unsigned int shndx) const;
 
-  // Return the entry size.
-  uint64_t
-  entsize() const
-  { return this->entsize_; }
-
   // Add a mapping from an OFFSET in input section SHNDX in object
   // OBJECT to an OUTPUT_OFFSET in the output section.  OUTPUT_OFFSET
   // is the offset from the start of the merged data in the output
@@ -246,6 +252,11 @@ class Output_merge_base : public Output_section_data
     this->merge_map_.add_mapping(object, shndx, offset, length, output_offset);
   }
 
+  // This may be overriden by the child class.
+  virtual bool
+  do_is_string()
+  { return false; }
+
  private:
   // A mapping from input object/section/offset to offset in output
   // section.
@@ -283,6 +294,11 @@ class Output_merge_data : public Output_merge_base
   void
   do_write_to_buffer(unsigned char*);
 
+  // Write to a map file.
+  void
+  do_print_to_mapfile(Mapfile* mapfile) const
+  { mapfile->print_output_data(this, _("** merge constants")); }
+
   // Print merge stats to stderr.
   void
   do_print_merge_stats(const char* section_name);
@@ -400,6 +416,11 @@ class Output_merge_string : public Output_merge_base
   void
   do_write_to_buffer(unsigned char*);
 
+  // Write to a map file.
+  void
+  do_print_to_mapfile(Mapfile* mapfile) const
+  { mapfile->print_output_data(this, _("** merge strings")); }
+
   // Print merge stats to stderr.
   void
   do_print_merge_stats(const char* section_name);
@@ -414,6 +435,11 @@ class Output_merge_string : public Output_merge_base
   clear_stringpool()
   { this->stringpool_.clear(); }
 
+  // Whether this is a merge string section.
+  virtual bool
+  do_is_string()
+  { return true; }
+
  private:
   // The name of the string type, for stats.
   const char*