From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29268 invoked by alias); 25 Feb 2011 22:45:53 -0000 Received: (qmail 29260 invoked by uid 22791); 25 Feb 2011 22:45:52 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ww0-f43.google.com (HELO mail-ww0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Feb 2011 22:45:48 +0000 Received: by wwe15 with SMTP id 15so2037587wwe.12 for ; Fri, 25 Feb 2011 14:45:45 -0800 (PST) Received: by 10.216.1.149 with SMTP id 21mr7659218wed.10.1298673945547; Fri, 25 Feb 2011 14:45:45 -0800 (PST) Received: from [192.168.2.99] (cpc2-cmbg8-0-0-cust61.5-4.cable.virginmedia.com [82.6.108.62]) by mx.google.com with ESMTPS id n52sm501397wer.24.2011.02.25.14.45.43 (version=SSLv3 cipher=OTHER); Fri, 25 Feb 2011 14:45:44 -0800 (PST) Message-ID: <4D683105.70307@gmail.com> Date: Fri, 25 Feb 2011 22:45:00 -0000 From: Dave Korn User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: "H.J. Lu" CC: binutils@sourceware.org Subject: Re: PATCH: PR ld/12507: Can't build a program with -flto -nostdlib References: <20110224225913.GA3169@intel.com> In-Reply-To: <20110224225913.GA3169@intel.com> Content-Type: multipart/mixed; boundary="------------050205040909070705020700" 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/msg00320.txt.bz2 This is a multi-part message in MIME format. --------------050205040909070705020700 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 1316 On 24/02/2011 22:59, H.J. Lu wrote: > We should never mark entry symbol IR only. I checked in this patch as > an obvious fix. > --- a/ld/plugin.c > +++ b/ld/plugin.c > @@ -490,8 +490,10 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms) > even potentially-referenced, perhaps in a future final link if > this is a partial one, perhaps dynamically at load-time if the > symbol is externally visible. */ > - ironly = !is_visible_from_outside (&syms[n], owner_sec, blhe) > - && !bfd_hash_lookup (non_ironly_hash, syms[n].name, FALSE, FALSE); > + ironly = (!is_visible_from_outside (&syms[n], owner_sec, blhe) > + && !bfd_hash_lookup (non_ironly_hash, syms[n].name, > + FALSE, FALSE) > + && strcmp (syms[n].name, entry_symbol.name) != 0); This caused a bunch of regressions for me: > +FAIL: plugin claimfile resolve symbol > +FAIL: plugin claimfile replace file > +FAIL: plugin ignore lib > +FAIL: plugin claimfile replace lib It turns out that entry_symbol.name can be NULL, and strcmp doesn't have to handle null pointers gracefully; it segfaulted on cygwin. We need to guard the test, like the attached. ld/ChangeLog: 2011-02-25 Dave Korn <.... * plugin.c (get_symbols): Guard against NULL name of entry_symbol. OK? cheers, DaveK --------------050205040909070705020700 Content-Type: text/x-c; name="pr12507-part2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr12507-part2.diff" Content-length: 726 Index: ld/plugin.c =================================================================== RCS file: /cvs/src/src/ld/plugin.c,v retrieving revision 1.24 diff -p -u -r1.24 plugin.c --- ld/plugin.c 24 Feb 2011 22:58:05 -0000 1.24 +++ ld/plugin.c 25 Feb 2011 22:41:09 -0000 @@ -496,7 +496,8 @@ get_symbols (const void *handle, int nsy ironly = (!is_visible_from_outside (&syms[n], owner_sec, blhe) && !bfd_hash_lookup (non_ironly_hash, syms[n].name, FALSE, FALSE) - && strcmp (syms[n].name, entry_symbol.name) != 0); + && (entry_symbol.name == NULL + || strcmp (syms[n].name, entry_symbol.name) != 0)); /* If it was originally undefined or common, then it has been resolved; determine how. */ --------------050205040909070705020700--