New plugin interface to get list of symbols wrapped with --wrap option.
[deliverable/binutils-gdb.git] / gold / plugin.cc
index 566f1b7caef0fb6f17dab749fe9e4b69bee5e85d..442eda06621e0ed855510dc0c0098a9392d3ce7c 100644 (file)
@@ -170,6 +170,9 @@ get_input_section_size(const struct ld_plugin_section section,
 static enum ld_plugin_status
 register_new_input(ld_plugin_new_input_handler handler);
 
+static enum ld_plugin_status
+get_wrap_symbols(uint64_t *num_symbols, const char ***wrap_symbol_list);
+
 };
 
 #endif // ENABLE_PLUGINS
@@ -214,7 +217,7 @@ Plugin::load()
   sscanf(ver, "%d.%d", &major, &minor);
 
   // Allocate and populate a transfer vector.
-  const int tv_fixed_size = 30;
+  const int tv_fixed_size = 31;
 
   int tv_size = this->args_.size() + tv_fixed_size;
   ld_plugin_tv* tv = new ld_plugin_tv[tv_size];
@@ -352,6 +355,10 @@ Plugin::load()
   tv[i].tv_tag = LDPT_REGISTER_NEW_INPUT_HOOK;
   tv[i].tv_u.tv_register_new_input = register_new_input;
 
+  ++i;
+  tv[i].tv_tag = LDPT_GET_WRAP_SYMBOLS;
+  tv[i].tv_u.tv_get_wrap_symbols = get_wrap_symbols;
+
   ++i;
   tv[i].tv_tag = LDPT_NULL;
   tv[i].tv_u.tv_val = 0;
@@ -1833,6 +1840,25 @@ get_input_section_size(const struct ld_plugin_section section,
   return LDPS_OK;
 }
 
+static enum ld_plugin_status
+get_wrap_symbols(uint64_t *count, const char ***wrap_symbols)
+{
+  gold_assert(parameters->options().has_plugins());
+  *count = parameters->options().wrap_size();
+
+  if (*count == 0)
+    return LDPS_OK;
+
+  *wrap_symbols = new const char *[*count];
+  int i = 0;
+  for (options::String_set::const_iterator
+       it = parameters->options().wrap_begin();
+       it != parameters->options().wrap_end(); ++it, ++i) {
+    (*wrap_symbols)[i] = it->c_str();
+  }
+  return LDPS_OK;
+}
+
 
 // Specify the ordering of sections in the final layout. The sections are
 // specified as (handle,shndx) pairs in the two arrays in the order in
This page took 0.023354 seconds and 4 git commands to generate.