aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgenii Stepanov <eugenis@google.com>2016-03-03 11:36:36 -0800
committerCary Coutant <ccoutant@gmail.com>2016-03-03 11:42:13 -0800
commit95ecdfbfcbf508919652a0254ee2b8c6572a949e (patch)
tree826f8608795c4781115a6c508a498d61795cd03d /gold/plugin.cc
parentgdb.base/skip.exp: Use with_test_prefix. (diff)
downloadbinutils-gdb-95ecdfbfcbf508919652a0254ee2b8c6572a949e.tar.gz
binutils-gdb-95ecdfbfcbf508919652a0254ee2b8c6572a949e.tar.bz2
binutils-gdb-95ecdfbfcbf508919652a0254ee2b8c6572a949e.zip
get_symbols() plugin API tweak to support --start-lib/--end-lib.
Let the plugin know that a file is not being included in the link by returning LDPS_NO_SYMS from get_symbols(). include/ * plugin-api.h (enum ld_plugin_tag): Add LDPT_GET_SYMBOLS_V3. gold/ * plugin.h (Pluginobj::get_symbol_resolution_info): Add version parameter. * plugin.cc (get_symbols_v3): New function. (Plugin::load): Add LDPT_GET_SYMBOLS_V3. (Pluginobj::get_symbol_resolution_info): Return LDPS_NO_SYMS when using new version.
Diffstat (limited to 'gold/plugin.cc')
-rw-r--r--gold/plugin.cc31
1 files changed, 29 insertions, 2 deletions
diff --git a/gold/plugin.cc b/gold/plugin.cc
index c01e4cd6c34..4aeb3ea708c 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -112,6 +112,9 @@ 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);
static enum ld_plugin_status
@@ -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];
@@ -277,6 +280,10 @@ Plugin::load()
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