* plugin.cc (Plugin::load): Move LDPT_MESSAGE to front of transfer

vector.
	(Plugin_manager::claim_file): Create plugin object even if
	plugin did not call the add_symbols callback.
	(Plugin_obj::get_symbol_resolution_info): Guard against plugin
	asking for more symbols than were added.
	* testsuite/Makefile.am (plugin_test_1): Add test case with
	no global symbols.
	(empty.syms): New target.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/plugin_test.c (claim_file_hook): Add new debug
	message. Don't call add_symbols if no globals.
	(all_symbols_read_hook): Don't provide replacement for empty
	claimed file.
This commit is contained in:
Cary Coutant
2008-12-16 19:19:16 +00:00
parent bb5ef15eff
commit abc8dcbad2
5 changed files with 50 additions and 20 deletions

View File

@@ -116,7 +116,13 @@ Plugin::load()
int tv_size = this->args_.size() + tv_fixed_size;
ld_plugin_tv *tv = new ld_plugin_tv[tv_size];
// Put LDPT_MESSAGE at the front of the list so the plugin can use it
// while processing subsequent entries.
int i = 0;
tv[i].tv_tag = LDPT_MESSAGE;
tv[i].tv_u.tv_message = message;
++i;
tv[i].tv_tag = LDPT_API_VERSION;
tv[i].tv_u.tv_val = LD_PLUGIN_API_VERSION;
@@ -164,10 +170,6 @@ Plugin::load()
tv[i].tv_tag = LDPT_ADD_INPUT_FILE;
tv[i].tv_u.tv_add_input_file = add_input_file;
++i;
tv[i].tv_tag = LDPT_MESSAGE;
tv[i].tv_u.tv_message = message;
++i;
tv[i].tv_tag = LDPT_NULL;
tv[i].tv_u.tv_val = 0;
@@ -265,14 +267,13 @@ Plugin_manager::claim_file(Input_file* input_file, off_t offset,
{
if ((*this->current_)->claim_file(&this->plugin_input_file_))
{
if (this->objects_.size() <= handle)
{
gold_error(_("%s: plugin claimed the file "
"but did not provide any symbols"),
this->plugin_input_file_.name);
return NULL;
}
return this->objects_[handle];
if (this->objects_.size() > handle)
return this->objects_[handle];
// If the plugin claimed the file but did not call the
// add_symbols callback, we need to create the Pluginobj now.
Pluginobj* obj = this->make_plugin_object(handle);
return obj;
}
}
@@ -369,7 +370,7 @@ Pluginobj::Pluginobj(const std::string& name, Input_file* input_file,
ld_plugin_status
Pluginobj::get_symbol_resolution_info(int nsyms, ld_plugin_symbol* syms) const
{
if (this->nsyms_ == 0)
if (nsyms > this->nsyms_)
return LDPS_NO_SYMS;
for (int i = 0; i < nsyms; i++)
{