summaryrefslogtreecommitdiff
path: root/bfd/plugin.c
diff options
context:
space:
mode:
authorespindola <espindola>2011-02-26 00:03:08 +0000
committerespindola <espindola>2011-02-26 00:03:08 +0000
commit6618aa1f40fe16cb52030c9018943133dca06551 (patch)
treeb554b5c2b61632d1edca92a22ed3abc7525fca91 /bfd/plugin.c
parente4414336c9b4ef52dfa379b671fadc07a1002afb (diff)
downloadbinutils-redhat-6618aa1f40fe16cb52030c9018943133dca06551.tar.gz
2011-02-25 Rafael Ávila de Espíndola <respindola@mozilla.com>
* plugin.c (bfd_plugin_object_p): Correctly set the filesize and handle claim_file seeking. Only try to load the plugin once.
Diffstat (limited to 'bfd/plugin.c')
-rw-r--r--bfd/plugin.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 30a492369d..dde61c8830 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -232,11 +232,17 @@ static const bfd_target *
bfd_plugin_object_p (bfd *abfd)
{
int claimed = 0;
- int t = load_plugin ();
struct ld_plugin_input_file file;
bfd *iobfd;
+ static int have_loaded = 0;
+ static int have_plugin = 0;
- if (!t)
+ if (!have_loaded)
+ {
+ have_loaded = 1;
+ have_plugin = load_plugin ();
+ }
+ if (!have_plugin)
return NULL;
file.name = abfd->filename;
@@ -251,7 +257,7 @@ bfd_plugin_object_p (bfd *abfd)
{
iobfd = abfd;
file.offset = 0;
- file.filesize = 0; /*FIXME*/
+ file.filesize = 0;
}
if (!iobfd->iostream && !bfd_open_file (iobfd))
@@ -259,8 +265,18 @@ bfd_plugin_object_p (bfd *abfd)
file.fd = fileno ((FILE *) iobfd->iostream);
+ if (!abfd->my_archive)
+ {
+ struct stat stat_buf;
+ if (fstat (file.fd, &stat_buf))
+ return NULL;
+ file.filesize = stat_buf.st_size;
+ }
+
file.handle = abfd;
+ off_t cur_offset = lseek(file.fd, 0, SEEK_CUR);
claim_file (&file, &claimed);
+ lseek(file.fd, cur_offset, SEEK_SET);
if (!claimed)
return NULL;