This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR ld/12507: Can't build a program with -flto -nostdlib
- From: Dave Korn <dave dot korn dot cygwin at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Fri, 25 Feb 2011 22:45:25 +0000
- Subject: Re: PATCH: PR ld/12507: Can't build a program with -flto -nostdlib
- References: <20110224225913.GA3169@intel.com>
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
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. */