Add icf_virtual_function_folding_test to check_PROGRAMS.
[binutils-gdb.git] / gold / plugin.cc
index 2831c2b19fdfe5a03fcb07d7a391825f55d056ec..2ee1301a537a735ddf0eab525210d4435c92c2e7 100644 (file)
@@ -438,6 +438,7 @@ Plugin_manager::add_input_file(char *pathname, bool is_lib)
                                                 this->mapfile_,
                                                 input_argument,
                                                 NULL,
+                                                NULL,
                                                 this->this_blocker_,
                                                 next_blocker));
   this->this_blocker_ = next_blocker;
@@ -475,6 +476,17 @@ Pluginobj::get_symbol_resolution_info(int nsyms, ld_plugin_symbol* syms) const
 {
   if (nsyms > this->nsyms_)
     return LDPS_NO_SYMS;
+
+  if (static_cast<size_t>(nsyms) > this->symbols_.size())
+    {
+      // We never decided to include this object. We mark all symbols as
+      // preempted.
+      gold_assert (this->symbols_.size() == 0);
+      for (int i = 0; i < nsyms; i++)
+        syms[i].resolution = LDPR_PREEMPTED_REG;
+      return LDPS_OK;
+    }
+
   for (int i = 0; i < nsyms; i++)
     {
       ld_plugin_symbol* isym = &syms[i];
@@ -491,6 +503,10 @@ Pluginobj::get_symbol_resolution_info(int nsyms, ld_plugin_symbol* syms) const
           // The original symbol was undefined or common.
           if (lsym->source() != Symbol::FROM_OBJECT)
             res = LDPR_RESOLVED_EXEC;
+          else if (lsym->object()->pluginobj() == this)
+            res = (is_visible_from_outside(lsym)
+                   ? LDPR_PREVAILING_DEF
+                   : LDPR_PREVAILING_DEF_IRONLY);
           else if (lsym->object()->pluginobj() != NULL)
             res = LDPR_RESOLVED_IR;
           else if (lsym->object()->is_dynamic())
@@ -662,6 +678,34 @@ Sized_pluginobj<size, big_endian>::do_add_symbols(Symbol_table* symtab,
     }
 }
 
+template<int size, bool big_endian>
+Archive::Should_include
+Sized_pluginobj<size, big_endian>::do_should_include_member(
+    Symbol_table* symtab, Read_symbols_data*, std::string* why)
+{
+  char* tmpbuf = NULL;
+  size_t tmpbuflen = 0;
+
+  for (int i = 0; i < this->nsyms_; ++i) {
+    const struct ld_plugin_symbol& sym = this->syms_[i];
+    const char* name = sym.name;
+    Symbol* symbol;
+    Archive::Should_include t = Archive::should_include_member(symtab, name,
+                                                               &symbol, why,
+                                                               &tmpbuf,
+                                                               &tmpbuflen);
+      if (t == Archive::SHOULD_INCLUDE_YES)
+       {
+         if (tmpbuf != NULL)
+           free(tmpbuf);
+         return t;
+       }
+  }
+  if (tmpbuf != NULL)
+    free(tmpbuf);
+  return Archive::SHOULD_INCLUDE_UNKNOWN;
+}
+
 // Get the size of a section.  Not used for plugin objects.
 
 template<int size, bool big_endian>