From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29239 invoked by alias); 9 Feb 2011 03:17:16 -0000 Received: (qmail 29230 invoked by uid 22791); 9 Feb 2011 03:17:16 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from dm-mail02.mozilla.org (HELO dm-mail02.mozilla.org) (63.245.208.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Feb 2011 03:17:11 +0000 Received: from desktop.lan (v74-nslb.mozilla.org [10.2.74.4]) (Authenticated sender: respindola@mozilla.com) by dm-mail02.mozilla.org (Postfix) with ESMTP id C63FA824158; Tue, 8 Feb 2011 19:17:08 -0800 (PST) Message-ID: <4D52072E.20908@mozilla.com> Date: Wed, 09 Feb 2011 03:17:00 -0000 From: =?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?= User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: binutils@sourceware.org CC: iant@google.com Subject: [patch] Fix some plugin API issues in BFD Content-Type: multipart/mixed; boundary="------------060609000208060809060300" X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00078.txt.bz2 This is a multi-part message in MIME format. --------------060609000208060809060300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Content-length: 552 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 * plugin.c (bfd_plugin_object_p): Correctly set the filesize and handle claim_file seeking. Cheers, Rafael --------------060609000208060809060300 Content-Type: text/x-patch; name="bfd.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bfd.patch" Content-length: 799 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; --------------060609000208060809060300--