public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] Fix some plugin API issues in BFD
@ 2011-02-09  3:17 Rafael Ávila de Espíndola
  2011-02-11 20:18 ` Rafael Avila de Espindola
  2011-02-20 19:55 ` Rafael Ávila de Espíndola
  0 siblings, 2 replies; 6+ messages in thread
From: Rafael Ávila de Espíndola @ 2011-02-09  3:17 UTC (permalink / raw)
  To: binutils; +Cc: iant

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

I recently updated a plugin to use the file descriptor directly. This 
worked fine in gold, but had two issues using bfd (nm and ar):

*) The filesize was not being set.
*) The code expected the claim_file callback to not seek.

That is not my understanding from reading the api documentation in 
http://gcc.gnu.org/wiki/whopr/driver, so the attached patch fixes both 
issues.

2010-02-08  Rafael Ávila de Espíndola <respindola@mozilla.com>

	* plugin.c (bfd_plugin_object_p): Correctly set the filesize
	and handle claim_file seeking.

Cheers,
Rafael

[-- Attachment #2: bfd.patch --]
[-- Type: text/x-patch, Size: 799 bytes --]

diff --git a/bfd/plugin.c b/bfd/plugin.c
index 30a4923..319ef50 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -251,7 +251,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 +259,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;
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-02-25 20:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-09  3:17 [patch] Fix some plugin API issues in BFD Rafael Ávila de Espíndola
2011-02-11 20:18 ` Rafael Avila de Espindola
2011-02-20 19:55 ` Rafael Ávila de Espíndola
2011-02-20 21:17   ` Rafael Ávila de Espíndola
2011-02-23 15:17     ` Dave Korn
2011-02-25 20:58     ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).