From 9c793f143cd36b86c60929319fc0551948dc238d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Wed, 23 Mar 2011 14:13:27 +0000 Subject: [PATCH] =?utf8?q?2010-03-23=20=20Rafael=20=C3=81vila=20de=20Esp?= =?utf8?q?=C3=ADndola=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * plugin.cc (get_view): New. (Plugin::load): Pass get_view to the plugin. (Plugin_manager::get_view): New. --- gold/ChangeLog | 6 ++++++ gold/plugin.cc | 47 ++++++++++++++++++++++++++++++++++++++++++++++- gold/plugin.h | 3 +++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index de3c345..666ae10 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,9 @@ +2010-03-23 Rafael Ávila de Espíndola + + * plugin.cc (get_view): New. + (Plugin::load): Pass get_view to the plugin. + (Plugin_manager::get_view): New. + 2011-03-21 Ian Lance Taylor * testsuite/final_layout.sh: Rewrite to not use dc. diff --git a/gold/plugin.cc b/gold/plugin.cc index 214eff3..7e259e0 100644 --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -69,6 +69,9 @@ static enum ld_plugin_status get_input_file(const void *handle, struct ld_plugin_input_file *file); static enum ld_plugin_status +get_view(const void *handle, const void **viewp); + +static enum ld_plugin_status release_input_file(const void *handle); static enum ld_plugin_status @@ -130,7 +133,7 @@ Plugin::load() sscanf(ver, "%d.%d", &major, &minor); // Allocate and populate a transfer vector. - const int tv_fixed_size = 16; + const int tv_fixed_size = 17; int tv_size = this->args_.size() + tv_fixed_size; ld_plugin_tv* tv = new ld_plugin_tv[tv_size]; @@ -189,6 +192,10 @@ Plugin::load() tv[i].tv_u.tv_get_input_file = get_input_file; ++i; + tv[i].tv_tag = LDPT_GET_VIEW; + tv[i].tv_u.tv_get_view = get_view; + + ++i; tv[i].tv_tag = LDPT_RELEASE_INPUT_FILE; tv[i].tv_u.tv_release_input_file = release_input_file; @@ -635,6 +642,35 @@ Plugin_manager::release_input_file(unsigned int handle) return LDPS_OK; } +ld_plugin_status +Plugin_manager::get_view(unsigned int handle, const void **viewp) +{ + off_t offset; + size_t filesize; + Input_file *input_file; + if (this->objects_.size() == handle) + { + // We are being called from the claim_file hook. + const struct ld_plugin_input_file &f = this->plugin_input_file_; + offset = f.offset; + filesize = f.filesize; + input_file = this->input_file_; + } + else + { + // An already claimed file. + Pluginobj* obj = this->object(handle); + if (obj == NULL) + return LDPS_BAD_HANDLE; + offset = obj->offset(); + filesize = obj->filesize(); + input_file = obj->input_file(); + } + *viewp = (void*) input_file->file().get_view(offset, 0, filesize, false, + false); + return LDPS_OK; +} + // Add a new library path. ld_plugin_status @@ -1247,6 +1283,15 @@ release_input_file(const void* handle) return parameters->options().plugins()->release_input_file(obj_index); } +static enum ld_plugin_status +get_view(const void *handle, const void **viewp) +{ + gold_assert(parameters->options().has_plugins()); + unsigned int obj_index = + static_cast(reinterpret_cast(handle)); + return parameters->options().plugins()->get_view(obj_index, viewp); +} + // Get the symbol resolution info for a plugin-claimed input file. static enum ld_plugin_status diff --git a/gold/plugin.h b/gold/plugin.h index c26414d..87747bf 100644 --- a/gold/plugin.h +++ b/gold/plugin.h @@ -245,6 +245,9 @@ class Plugin_manager ld_plugin_status get_input_file(unsigned int handle, struct ld_plugin_input_file* file); + ld_plugin_status + get_view(unsigned int handle, const void **viewp); + // Release an input file. ld_plugin_status release_input_file(unsigned int handle); -- 2.7.4