summaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2013-03-30 01:03:23 +0000
committerSriraman Tallam <tmsriram@google.com>2013-03-30 01:03:23 +0000
commitda09b6d00e18aec306d8d44f707829d44ad77c39 (patch)
treeb6e57d388653a0c75ab3306c09738f2e9758e3b8 /gold
parent329d37ede3b22d4577bb30a71a9d8e536a63248a (diff)
downloadbinutils-redhat-da09b6d00e18aec306d8d44f707829d44ad77c39.tar.gz
2013-03-29 Sriraman Tallam <tmsriram@google.com>
* archive.cc (Archive::get_elf_object_for_member): Create the elf object before calling the plugin claim_file handler. Pass the elf object of the archive to the plugin. Delete the elf object if the plugin claims the file.
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog7
-rw-r--r--gold/archive.cc38
2 files changed, 32 insertions, 13 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 49ed9345a6..360599cfaf 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,10 @@
+2013-03-29 Sriraman Tallam <tmsriram@google.com>
+
+ * archive.cc (Archive::get_elf_object_for_member): Create the elf
+ object before calling the plugin claim_file handler. Pass the elf
+ object of the archive to the plugin. Delete the elf object if the
+ plugin claims the file.
+
2013-03-21 Alan Modra <amodra@gmail.com>
* layout.cc (Layout::set_segment_offsets): Accept writable .text
diff --git a/gold/archive.cc b/gold/archive.cc
index 4db813d6df..f2cd848ce3 100644
--- a/gold/archive.cc
+++ b/gold/archive.cc
@@ -654,33 +654,45 @@ Archive::get_elf_object_for_member(off_t off, bool* punconfigured)
&member_name))
return NULL;
+ const unsigned char* ehdr;
+ int read_size;
+ Object *obj = NULL;
+ bool is_elf_obj = false;
+
+ if (is_elf_object(input_file, memoff, &ehdr, &read_size))
+ {
+ obj = make_elf_object((std::string(this->input_file_->filename())
+ + "(" + member_name + ")"),
+ input_file, memoff, ehdr, read_size,
+ punconfigured);
+ is_elf_obj = true;
+ }
+
if (parameters->options().has_plugins())
{
- Object* obj = parameters->options().plugins()->claim_file(input_file,
- memoff,
- memsize,
- NULL);
- if (obj != NULL)
+ Object* plugin_obj
+ = parameters->options().plugins()->claim_file(input_file,
+ memoff,
+ memsize,
+ obj);
+ if (plugin_obj != NULL)
{
// The input file was claimed by a plugin, and its symbols
// have been provided by the plugin.
- return obj;
+ // Delete its elf object.
+ if (obj != NULL)
+ delete obj;
+ return plugin_obj;
}
}
- const unsigned char* ehdr;
- int read_size;
- if (!is_elf_object(input_file, memoff, &ehdr, &read_size))
+ if (!is_elf_obj)
{
gold_error(_("%s: member at %zu is not an ELF object"),
this->name().c_str(), static_cast<size_t>(off));
return NULL;
}
- Object* obj = make_elf_object((std::string(this->input_file_->filename())
- + "(" + member_name + ")"),
- input_file, memoff, ehdr, read_size,
- punconfigured);
if (obj == NULL)
return NULL;
obj->set_no_export(this->no_export());