This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] get_symbols() plugin API tweak to support --start-lib/--end-lib
- From: Evgenii Stepanov <eugeni dot stepanov at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Cc: Rafael Ãvila de EspÃndola <rafael dot espindola at gmail dot com>, Cary Coutant <ccoutant at gmail dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>
- Date: Fri, 26 Feb 2016 11:23:59 -0800
- Subject: [PATCH] get_symbols() plugin API tweak to support --start-lib/--end-lib
- Authentication-results: sourceware.org; auth=none
Let the plugin know that a file is not being included in the link with
by returning LDPS_NO_SYMS from get_symbols().
gold/Changelog:
* 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.
* plugin.h (Pluginobj::get_symbol_resolution_info): Add version
parameter.
include/Changelog:
* plugin-api.h (enum ld_plugin_tag): Add LDPT_GET_SYMBOLS_V3.
---
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 2d16bbc..a4f29e6 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,12 @@
+2015-02-26 Evgenii Stepanov <eugenis@google.com>
+
+ * 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.
+ * plugin.h (Pluginobj::get_symbol_resolution_info): Add version
+ parameter.
+
2013-10-14 Alan Modra <amodra@gmail.com>
* output.h (Output_data_got::add_constant): Tidy.
diff --git a/gold/plugin.cc b/gold/plugin.cc
index e932c1c..9df1c76 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;
@@ -931,7 +938,7 @@ Pluginobj::get_symbol_resolution_info(int nsyms,
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++)
@@ -1535,6 +1542,24 @@ get_symbols_v2(const void* handle, int nsyms,
ld_plugin_symbol* syms)
return plugin_obj->get_symbol_resolution_info(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());
+ Object* obj = parameters->options().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;
+ return plugin_obj->get_symbol_resolution_info(nsyms, syms, 3);
+}
+
// Add a new (real) input file generated by a plugin.
static enum ld_plugin_status
diff --git a/include/ChangeLog b/include/ChangeLog
index 7d4c0d3..f77a795 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-26 Evgenii Stepanov <eugenis@google.com>
+
+ * plugin-api.h (enum ld_plugin_tag): Add LDPT_GET_SYMBOLS_V3.
+
2013-10-29 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/58689
diff --git a/include/plugin-api.h b/include/plugin-api.h
index 5797d4d..2d68e53 100644
--- a/include/plugin-api.h
+++ b/include/plugin-api.h
@@ -384,7 +384,8 @@ enum ld_plugin_tag
LDPT_ALLOW_SECTION_ORDERING = 24,
LDPT_GET_SYMBOLS_V2 = 25,
LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS = 26,
- LDPT_UNIQUE_SEGMENT_FOR_SECTIONS = 27
+ LDPT_UNIQUE_SEGMENT_FOR_SECTIONS = 27,
+ LDPT_GET_SYMBOLS_V3 = 28
};
/* The plugin transfer vector. */