public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Dave Korn <dave.korn.cygwin@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: PATCH: PR ld/12507: Can't build a program with -flto -nostdlib
Date: Fri, 25 Feb 2011 22:45:00 -0000	[thread overview]
Message-ID: <4D683105.70307@gmail.com> (raw)
In-Reply-To: <20110224225913.GA3169@intel.com>

[-- Attachment #1: Type: text/plain, Size: 1316 bytes --]

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


[-- Attachment #2: pr12507-part2.diff --]
[-- Type: text/x-c, Size: 726 bytes --]

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

  reply	other threads:[~2011-02-25 22:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-24 22:59 H.J. Lu
2011-02-25 22:45 ` Dave Korn [this message]
2011-02-25 23:08   ` H.J. Lu
2011-02-25 23:30 ` Alan Modra
2011-02-25 23:45   ` H.J. Lu
2011-02-25 23:59     ` Alan Modra
2011-02-26  0:09       ` Rafael Ávila de Espíndola
2011-02-26  4:34         ` H.J. Lu
2011-02-26  5:16           ` Rafael Ávila de Espíndola
2011-02-26  5:32             ` H.J. Lu
2011-02-26  4:33       ` H.J. Lu
2011-02-26  4:36         ` H.J. Lu
2011-02-26  9:04         ` Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D683105.70307@gmail.com \
    --to=dave.korn.cygwin@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).