From 80549d04a2090e1c1a6a693485f577f9e45dcacc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Sat, 26 Feb 2011 00:03:09 +0000 Subject: [PATCH] =?utf8?q?2011-02-25=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.c (bfd_plugin_object_p): Correctly set the filesize and handle claim_file seeking. Only try to load the plugin once. --- bfd/ChangeLog | 5 +++++ bfd/plugin.c | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a8907a0..9187691 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2011-02-25 Rafael Ávila de Espíndola + + * plugin.c (bfd_plugin_object_p): Correctly set the filesize + and handle claim_file seeking. Only try to load the plugin once. + 2011-02-22 Andreas Schwab * elf32-m68k.c (elf_m68k_finish_dynamic_symbol): For a TLS_GD diff --git a/bfd/plugin.c b/bfd/plugin.c index 30a4923..dde61c8 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; -- 2.7.4