From: "Rafael Ávila de Espíndola" <respindola@mozilla.com>
To: binutils@sourceware.org
Cc: iant@google.com
Subject: [patch] Fix some plugin API issues in BFD
Date: Wed, 09 Feb 2011 03:17:00 -0000 [thread overview]
Message-ID: <4D52072E.20908@mozilla.com> (raw)
[-- 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;
next reply other threads:[~2011-02-09 3:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-09 3:17 Rafael Ávila de Espíndola [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D52072E.20908@mozilla.com \
--to=respindola@mozilla.com \
--cc=binutils@sourceware.org \
--cc=iant@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).