This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR ld/12507: Can't build a program with -flto -nostdlib


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.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]