From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30425 invoked by alias); 20 Feb 2011 21:17:47 -0000 Received: (qmail 30415 invoked by uid 22791); 20 Feb 2011 21:17:47 -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-mail01.mozilla.org (HELO dm-mail01.mozilla.org) (63.245.208.150) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 20 Feb 2011 21:17:42 +0000 Received: from desktop.lan (v74-nslb.mozilla.org [10.2.74.4]) (Authenticated sender: respindola@mozilla.com) by dm-mail01.mozilla.org (Postfix) with ESMTP id DF6C46A9367; Sun, 20 Feb 2011 13:17:38 -0800 (PST) Message-ID: <4D6184ED.9020609@mozilla.com> Date: Sun, 20 Feb 2011 21:17:00 -0000 From: =?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7 MIME-Version: 1.0 To: binutils@sourceware.org CC: iant@google.com, ccoutant@google.com Subject: Re: [patch] Fix some plugin API issues in BFD References: <4D52072E.20908@mozilla.com> <4D61718E.20003@mozilla.com> In-Reply-To: <4D61718E.20003@mozilla.com> Content-Type: multipart/mixed; boundary="------------010105020201000203060806" 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/msg00249.txt.bz2 This is a multi-part message in MIME format. --------------010105020201000203060806 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Content-length: 190 On 2011-02-20 14:54, Rafael Ávila de Espíndola wrote: > An updated patch is attached that also avoids calling onload multiple times. Sorry, the correct one is now attached. Cheers, Rafael --------------010105020201000203060806 Content-Type: text/x-patch; name="bfd.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bfd.patch" Content-length: 1224 diff --git a/bfd/plugin.c b/bfd/plugin.c index 30a4923..bba9548 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -232,11 +232,16 @@ 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; - - if (!t) + static int have_loaded = 0; + static int have_plugin = 0; + if (!have_loaded) + { + have_loaded = 1; + have_plugin = load_plugin (); + } + if (!have_plugin) return NULL; file.name = abfd->filename; @@ -251,7 +256,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 +264,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; --------------010105020201000203060806--