* gold/incremental.cc (Sized_relobj_incr::Sized_relobj_incr):
authorCary Coutant <ccoutant@google.com>
Mon, 10 Oct 2011 17:38:07 +0000 (17:38 +0000)
committerCary Coutant <ccoutant@google.com>
Mon, 10 Oct 2011 17:38:07 +0000 (17:38 +0000)
Initialize defined_count_.
(Sized_relobj_incr::do_add_symbols): Count defined symbols.
(Sized_relobj_incr::do_get_global_symbol_counts): Rewrite.
(Sized_incr_dynobj::Sized_incr_dynobj): Initialize defined_count_.
(Sized_incr_dynobj::do_add_symbols): Count defined symbols.
(Sized_incr_dynobj::do_get_global_symbol_counts): Rewrite.
* gold/incremental.h (Sized_relobj_incr::defined_count_): New data
member.
(Sized_incr_dynobj::defined_count_): New data member.
* gold/plugin.cc (Sized_pluginobj::do_get_global_symbol_counts):
Return zeroes instead of internal error.

gold/ChangeLog
gold/incremental.cc
gold/incremental.h
gold/plugin.cc

index 318e5156d28f054ef870fc6a133a978b27f28fb7..1d128a6e5395ee622d8d27421724d852433e844b 100644 (file)
@@ -1,3 +1,18 @@
+2011-10-10  Cary Coutant  <ccoutant@google.com>
+
+       * gold/incremental.cc (Sized_relobj_incr::Sized_relobj_incr):
+       Initialize defined_count_.
+       (Sized_relobj_incr::do_add_symbols): Count defined symbols.
+       (Sized_relobj_incr::do_get_global_symbol_counts): Rewrite.
+       (Sized_incr_dynobj::Sized_incr_dynobj): Initialize defined_count_.
+       (Sized_incr_dynobj::do_add_symbols): Count defined symbols.
+       (Sized_incr_dynobj::do_get_global_symbol_counts): Rewrite.
+       * gold/incremental.h (Sized_relobj_incr::defined_count_): New data
+       member.
+       (Sized_incr_dynobj::defined_count_): New data member.
+       * gold/plugin.cc (Sized_pluginobj::do_get_global_symbol_counts):
+       Return zeroes instead of internal error.
+
 2011-10-10  Cary Coutant  <ccoutant@google.com>
 
        PR gold/13249
index cbf6fbaae285dcb174decbf7f22a05f88ece040f..75e44c5707f996cd44719459165fd6bfe5a4c3e3 100644 (file)
@@ -1966,8 +1966,9 @@ Sized_relobj_incr<size, big_endian>::Sized_relobj_incr(
     input_reader_(ibase->inputs_reader().input_file(input_file_index)),
     local_symbol_count_(0), output_local_dynsym_count_(0),
     local_symbol_index_(0), local_symbol_offset_(0), local_dynsym_offset_(0),
-    symbols_(), incr_reloc_offset_(-1U), incr_reloc_count_(0),
-    incr_reloc_output_index_(0), incr_relocs_(NULL), local_symbols_()
+    symbols_(), defined_count_(0), incr_reloc_offset_(-1U),
+    incr_reloc_count_(0), incr_reloc_output_index_(0), incr_relocs_(NULL),
+    local_symbols_()
 {
   if (this->input_reader_.is_in_system_directory())
     this->set_is_in_system_directory();
@@ -2120,6 +2121,9 @@ Sized_relobj_incr<size, big_endian>::do_add_symbols(
 
       Symbol* res = symtab->add_from_incrobj(this, name, NULL, &sym);
 
+      if (shndx != elfcpp::SHN_UNDEF)
+        ++this->defined_count_;
+
       // If this is a linker-defined symbol that hasn't yet been defined,
       // define it now.
       if (input_shndx == -1U && !res->is_defined())
@@ -2283,9 +2287,21 @@ Sized_relobj_incr<size, big_endian>::do_initialize_xindex()
 template<int size, bool big_endian>
 void
 Sized_relobj_incr<size, big_endian>::do_get_global_symbol_counts(
-    const Symbol_table*, size_t*, size_t*) const
-{
-  gold_unreachable();
+    const Symbol_table*,
+    size_t* defined,
+    size_t* used) const
+{
+  *defined = this->defined_count_;
+  size_t count = 0;
+  for (typename Symbols::const_iterator p = this->symbols_.begin();
+       p != this->symbols_.end();
+       ++p)
+    if (*p != NULL
+       && (*p)->source() == Symbol::FROM_OBJECT
+       && (*p)->object() == this
+       && (*p)->is_defined())
+      ++count;
+  *used = count;
 }
 
 // Read the relocs.
@@ -2579,7 +2595,7 @@ Sized_incr_dynobj<size, big_endian>::Sized_incr_dynobj(
   : Dynobj(name, NULL), ibase_(ibase),
     input_file_index_(input_file_index),
     input_reader_(ibase->inputs_reader().input_file(input_file_index)),
-    symbols_()
+    symbols_(), defined_count_(0)
 {
   if (this->input_reader_.is_in_system_directory())
     this->set_is_in_system_directory();
@@ -2677,6 +2693,7 @@ Sized_incr_dynobj<size, big_endian>::do_add_symbols(
          // is meaningless, as long as it's not SHN_UNDEF.
          shndx = 1;
          v = gsym.get_st_value();
+         ++this->defined_count_;
        }
 
       osym.put_st_name(0);
@@ -2845,9 +2862,22 @@ Sized_incr_dynobj<size, big_endian>::do_initialize_xindex()
 template<int size, bool big_endian>
 void
 Sized_incr_dynobj<size, big_endian>::do_get_global_symbol_counts(
-    const Symbol_table*, size_t*, size_t*) const
-{
-  gold_unreachable();
+    const Symbol_table*,
+    size_t* defined,
+    size_t* used) const
+{
+  *defined = this->defined_count_;
+  size_t count = 0;
+  for (typename Symbols::const_iterator p = this->symbols_.begin();
+       p != this->symbols_.end();
+       ++p)
+    if (*p != NULL
+       && (*p)->source() == Symbol::FROM_OBJECT
+       && (*p)->object() == this
+       && (*p)->is_defined()
+       && (*p)->dynsym_index() != -1U)
+      ++count;
+  *used = count;
 }
 
 // Allocate an incremental object of the appropriate size and endianness.
index e6732df5ac9bad7c97c76fa72c28379a2ba2cfe0..56fc52b7533fd20dabf85dd4bfa20e521267f68a 100644 (file)
@@ -1996,6 +1996,8 @@ class Sized_relobj_incr : public Sized_relobj<size, big_endian>
   unsigned int local_dynsym_offset_;
   // The entries in the symbol table for the external symbols.
   Symbols symbols_;
+  // Number of symbols defined in object file itself.
+  size_t defined_count_;
   // The offset of the first incremental relocation for this object.
   unsigned int incr_reloc_offset_;
   // The number of incremental relocations for this object.
@@ -2127,6 +2129,8 @@ class Sized_incr_dynobj : public Dynobj
   Input_entry_reader input_reader_;
   // The entries in the symbol table for the external symbols.
   Symbols symbols_;
+  // Number of symbols defined in object file itself.
+  size_t defined_count_;
 };
 
 // Allocate an incremental object of the appropriate size and endianness.
index b5880a102c1f4ef1995d68ac4a13cfe2c90ebc61..ebda0aff152466f9f483c86ce71a9805a597cd7d 100644 (file)
@@ -1244,14 +1244,18 @@ Sized_pluginobj<size, big_endian>::do_initialize_xindex()
   return NULL;
 }
 
-// Get symbol counts.  Not used for plugin objects.
+// Get symbol counts.  Don't count plugin objects; the replacement
+// files will provide the counts.
 
 template<int size, bool big_endian>
 void
-Sized_pluginobj<size, big_endian>::do_get_global_symbol_counts(const Symbol_table*,
-                                                   size_t*, size_t*) const
+Sized_pluginobj<size, big_endian>::do_get_global_symbol_counts(
+    const Symbol_table*,
+    size_t* defined,
+    size_t* used) const
 {
-  gold_unreachable();
+  *defined = 0;
+  *used = 0;
 }
 
 // Get symbols.  Not used for plugin objects.
This page took 0.032674 seconds and 4 git commands to generate.