2011-02-25 Rafael Ávila de Espíndola <respindola@mozilla.com>
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Sat, 26 Feb 2011 00:03:09 +0000 (00:03 +0000)
committerRafael Ávila de Espíndola <respindola@mozilla.com>
Sat, 26 Feb 2011 00:03:09 +0000 (00:03 +0000)
* plugin.c (bfd_plugin_object_p): Correctly set the filesize
and handle claim_file seeking. Only try to load the plugin once.

bfd/ChangeLog
bfd/plugin.c

index a8907a0b02beff8a3efc0a2e71897a2c24cf5747..918769190826eac1fdd99695152e89bc84dfbe52 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2011-02-22  Andreas Schwab  <schwab@redhat.com>
 
        * elf32-m68k.c (elf_m68k_finish_dynamic_symbol): For a TLS_GD
index 30a492369d74f9e3d3f0f396ead4ccbcacad9c39..dde61c883093cf43b8fda98994cdc0966c5b9dad 100644 (file)
@@ -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;
 
This page took 0.025903 seconds and 4 git commands to generate.