diff options
author | Cary Coutant <ccoutant@google.com> | 2008-12-16 19:19:16 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2008-12-16 19:19:16 +0000 |
commit | abc8dcbad2b489919dfb608e82d75f204b14b594 (patch) | |
tree | 1a4f81ab8dbe68df1497f5c4d4425784a25fc060 /gold/plugin.cc | |
parent | bb5ef15eff1baa44a382c9be60383e66cc26badd (diff) | |
download | gdb-abc8dcbad2b489919dfb608e82d75f204b14b594.zip gdb-abc8dcbad2b489919dfb608e82d75f204b14b594.tar.gz gdb-abc8dcbad2b489919dfb608e82d75f204b14b594.tar.bz2 |
* 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.
Diffstat (limited to 'gold/plugin.cc')
-rw-r--r-- | gold/plugin.cc | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/gold/plugin.cc b/gold/plugin.cc index 9056a3b..c4e46b5 100644 --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -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; @@ -165,10 +171,6 @@ Plugin::load() 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++) { |