public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] Re: PR26978, Inconsistency for strong foo@v1 and weak foo@@v1
Date: Mon,  8 Apr 2024 02:01:57 +0000 (GMT)	[thread overview]
Message-ID: <20240408020158.0A1263858404@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=248b6326a49ed49e2f627d3bddbac514a074bac0

commit 248b6326a49ed49e2f627d3bddbac514a074bac0
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Apr 8 08:16:20 2024 +0930

    Re: PR26978, Inconsistency for strong foo@v1 and weak foo@@v1
    
    Commit 726d7d1ecf opened a hole that allowed a u.i.link loop to be
    created, resulting in _bfd_generic_link_add_one_symbol never
    returning.  Fix that.  Note that the MIND case handles two types of
    redefinition.  For a new indirect symbol we'll have string non-NULL.
    For a new def, string will be NULL.  So moving the string comparison
    earlier would work.  However, we've already looked up inh in the first
    case so can dispense with name comparisons.  Either way, for a new def
    we'll get to the defweak test and possibly cycle.  Which is what we
    want here.
    
            PR 31615
            PR 26978
            * linker.c (_bfd_generic_link_add_one_symbol <MIND>): Test for
            exactly matching indirect symbols before cycling on a defweak.

Diff:
---
 bfd/linker.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/linker.c b/bfd/linker.c
index eb42a78b622..111deecf55d 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1678,6 +1678,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
 	case MIND:
 	  /* Multiple indirect symbols.  This is OK if they both point
 	     to the same symbol.  */
+	  if (h->u.i.link == inh)
+	    break;
 	  if (h->u.i.link->type == bfd_link_hash_defweak)
 	    {
 	      /* It is also OK to redefine a symbol that indirects to
@@ -1689,8 +1691,6 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
 	      cycle = true;
 	      break;
 	    }
-	  if (string != NULL && strcmp (h->u.i.link->root.string, string) == 0)
-	    break;
 	  /* Fall through.  */
 	case MDEF:
 	  /* Handle a multiple definition.  */

                 reply	other threads:[~2024-04-08  2:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240408020158.0A1263858404@sourceware.org \
    --to=amodra@sourceware.org \
    --cc=binutils-cvs@sourceware.org \
    /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).