get_symbols() plugin API tweak to support --start-lib/--end-lib.
[deliverable/binutils-gdb.git] / gold / plugin.cc
index c01e4cd6c34f28e6417d2b98d568109ab737e406..4aeb3ea708c37c0303038fdaa9d64950ee32fc19 100644 (file)
@@ -111,6 +111,9 @@ get_symbols(const void *handle, int nsyms, struct ld_plugin_symbol *syms);
 static enum ld_plugin_status
 get_symbols_v2(const void *handle, int nsyms, struct ld_plugin_symbol *syms);
 
+static enum ld_plugin_status
+get_symbols_v3(const void *handle, int nsyms, struct ld_plugin_symbol *syms);
+
 static enum ld_plugin_status
 add_input_file(const char *pathname);
 
@@ -199,7 +202,7 @@ Plugin::load()
   sscanf(ver, "%d.%d", &major, &minor);
 
   // Allocate and populate a transfer vector.
-  const int tv_fixed_size = 26;
+  const int tv_fixed_size = 27;
 
   int tv_size = this->args_.size() + tv_fixed_size;
   ld_plugin_tv* tv = new ld_plugin_tv[tv_size];
@@ -276,6 +279,10 @@ Plugin::load()
   tv[i].tv_tag = LDPT_GET_SYMBOLS_V2;
   tv[i].tv_u.tv_get_symbols = get_symbols_v2;
 
+  ++i;
+  tv[i].tv_tag = LDPT_GET_SYMBOLS_V3;
+  tv[i].tv_u.tv_get_symbols = get_symbols_v3;
+
   ++i;
   tv[i].tv_tag = LDPT_ADD_INPUT_FILE;
   tv[i].tv_u.tv_add_input_file = add_input_file;
@@ -937,7 +944,7 @@ Pluginobj::get_symbol_resolution_info(Symbol_table* symtab,
       gold_assert(this->symbols_.size() == 0);
       for (int i = 0; i < nsyms; i++)
         syms[i].resolution = LDPR_PREEMPTED_REG;
-      return LDPS_OK;
+      return version > 2 ? LDPS_NO_SYMS : LDPS_OK;
     }
 
   for (int i = 0; i < nsyms; i++)
@@ -1545,6 +1552,26 @@ get_symbols_v2(const void* handle, int nsyms, ld_plugin_symbol* syms)
   return plugin_obj->get_symbol_resolution_info(symtab, nsyms, syms, 2);
 }
 
+// Version 3 of the above.  The only difference from v2 is that it
+// returns LDPS_NO_SYMS instead of LDPS_OK for the objects we never
+// decided to include.
+
+static enum ld_plugin_status
+get_symbols_v3(const void* handle, int nsyms, ld_plugin_symbol* syms)
+{
+  gold_assert(parameters->options().has_plugins());
+  Plugin_manager* plugins = parameters->options().plugins();
+  Object* obj = plugins->object(
+    static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle)));
+  if (obj == NULL)
+    return LDPS_ERR;
+  Pluginobj* plugin_obj = obj->pluginobj();
+  if (plugin_obj == NULL)
+    return LDPS_ERR;
+  Symbol_table* symtab = plugins->symtab();
+  return plugin_obj->get_symbol_resolution_info(symtab, nsyms, syms, 3);
+}
+
 // Add a new (real) input file generated by a plugin.
 
 static enum ld_plugin_status
This page took 0.025453 seconds and 4 git commands to generate.