From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12194 invoked by alias); 4 Mar 2011 01:22:15 -0000 Received: (qmail 12175 invoked by uid 22791); 4 Mar 2011 01:22:13 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_CP X-Spam-Check-By: sourceware.org Received: from mail-gy0-f169.google.com (HELO mail-gy0-f169.google.com) (209.85.160.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 Mar 2011 01:22:09 +0000 Received: by gyb13 with SMTP id 13so798389gyb.0 for ; Thu, 03 Mar 2011 17:22:07 -0800 (PST) Received: by 10.101.92.12 with SMTP id u12mr869957anl.225.1299201727383; Thu, 03 Mar 2011 17:22:07 -0800 (PST) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id w4sm1031393anw.16.2011.03.03.17.22.04 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Mar 2011 17:22:06 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 0B4AC170C1FA; Fri, 4 Mar 2011 11:51:59 +1030 (CST) Date: Fri, 04 Mar 2011 01:22:00 -0000 From: Alan Modra To: Michael Snyder Cc: binutils@sourceware.org, gdb-patches@sourceware.org Subject: Re: [RFA] archive.c, bsd_write_armap, fail if stat fails Message-ID: <20110304012159.GV13094@bubble.grove.modra.org> Mail-Followup-To: Michael Snyder , binutils@sourceware.org, gdb-patches@sourceware.org References: <4D6FE1F1.1010501@vmware.com> <20110303222506.GO13094@bubble.grove.modra.org> <4D7026A6.4090905@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D7026A6.4090905@vmware.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00243.txt.bz2 On Thu, Mar 03, 2011 at 03:39:18PM -0800, Michael Snyder wrote: > Alan Modra wrote: > >On Thu, Mar 03, 2011 at 10:46:09AM -0800, Michael Snyder wrote: > >> * archive.c (bsd_write_armap): Fail if stat fails. > > > >I think it would be better to just set the timestamp to zero if stat > >fails. There is precedent for this, eg. opncls.c:_maybe_make_executable. > > > Err, can I leave that to you? * archive.c (bsd_write_armap): Don't call stat in deterministic mode, and don't use st_mtime if stat returns error. Index: bfd/archive.c =================================================================== RCS file: /cvs/src/src/bfd/archive.c,v retrieving revision 1.72 diff -u -p -r1.72 archive.c --- bfd/archive.c 28 Feb 2011 18:30:16 -0000 1.72 +++ bfd/archive.c 4 Mar 2011 00:52:22 -0000 @@ -2299,31 +2299,28 @@ bsd_write_armap (bfd *arch, bfd_byte temp[4]; unsigned int count; struct ar_hdr hdr; - struct stat statbuf; long uid, gid; firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG; - stat (arch->filename, &statbuf); + /* If deterministic, we use 0 as the timestamp in the map. + Some linkers may require that the archive filesystem modification + time is less than (or near to) the archive map timestamp. Those + linkers should not be used with deterministic mode. (GNU ld and + Gold do not have this restriction.) */ + bfd_ardata (arch)->armap_timestamp = 0; + uid = 0; + gid = 0; if ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0) { - /* Remember the timestamp, to keep it holy. But fudge it a little. */ - bfd_ardata (arch)->armap_timestamp = (statbuf.st_mtime - + ARMAP_TIME_OFFSET); + struct stat statbuf; + + if (stat (arch->filename, &statbuf) == 0) + bfd_ardata (arch)->armap_timestamp = (statbuf.st_mtime + + ARMAP_TIME_OFFSET); uid = getuid(); gid = getgid(); } - else - { - /* If deterministic, we use 0 as the timestamp in the map. - Some linkers may require that the archive filesystem modification - time is less than (or near to) the archive map timestamp. Those - linkers should not be used with deterministic mode. (GNU ld and - Gold do not have this restriction.) */ - bfd_ardata (arch)->armap_timestamp = 0; - uid = 0; - gid = 0; - } memset (&hdr, ' ', sizeof (struct ar_hdr)); memcpy (hdr.ar_name, RANLIBMAG, strlen (RANLIBMAG)); -- Alan Modra Australia Development Lab, IBM