From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id BF8BF385840A for ; Mon, 14 Feb 2022 02:59:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BF8BF385840A Received: by mail-pj1-x1034.google.com with SMTP id q11-20020a17090a304b00b001b94d25eaecso9906591pjl.4 for ; Sun, 13 Feb 2022 18:59:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QjYFNjRiKQT/BHvGyreouaX2s6bLelRrLEdSXJYYHTk=; b=W9lpQHuzehNI3zfiJWTPX4rSugPZzOq9Xc7d3qldUeWCAaYv8nPDKiY38kUgT1f3E/ VLem/cVIs6+2EgwvTgV11t9qDCgKzteXp5aTNuwxHIQXmhM4s+xbEEBV4EbuwaRLFNXH OLgNzAq+k6ZJfg3Bfs09nu5vOs65LZBgWWhn0R9IoB+SGMwmI0YTBaOQ+/xTeHwLnhK8 b4kOdnOGkVDwpJmaosVZN2gVJtCGt8wSpPPHlytg8NwZvp2WrcvxGCkGeyYU2onTVDGz LTXAGHcZBFKBT/Y0ZL4LegbFIfyI/v3+eI7wpMDGATqbop/zWdGD+tM/EXcprQG9dHRM EgEQ== X-Gm-Message-State: AOAM5312kLlxF5RxbAUSJF63jTVYpQh9JEH1ngh0+nFQsS00a1hfU0in Nl8EGE5TEy2ehZ8cGgtV3xrKDF2voVS4dz1dQTFeH5sZaoM= X-Google-Smtp-Source: ABdhPJwWvSmJ9Nuvwk7rHfCs14TCywMFQ4sUwV81l7IN7MAjud0mpU7t/zh3mmzGTrxmvashxC8Vr25ZjlOMaKZjibo= X-Received: by 2002:a17:903:2351:: with SMTP id c17mr12384590plh.4.1644807564899; Sun, 13 Feb 2022 18:59:24 -0800 (PST) MIME-Version: 1.0 References: <20220211231927.2021394-1-hjl.tools@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Sun, 13 Feb 2022 18:58:48 -0800 Message-ID: Subject: Re: [PATCH] ld: Keep indirect symbol from IR if referenced from shared object To: Alan Modra Cc: Binutils , Nick Clifton Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3027.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Feb 2022 02:59:27 -0000 On Sun, Feb 13, 2022 at 6:47 PM Alan Modra wrote: > > On Sun, Feb 13, 2022 at 04:16:35PM -0800, H.J. Lu wrote: > > On Fri, Feb 11, 2022 at 3:19 PM H.J. Lu wrote: > > > > > > Don't change indirect symbol defined in IR to undefined if it is > > > referenced from shared object. > > The description above > > > > diff --git a/bfd/elflink.c b/bfd/elflink.c > > > index 6fa18d92007..f8521426cad 100644 > > > --- a/bfd/elflink.c > > > +++ b/bfd/elflink.c > > > @@ -1294,9 +1294,8 @@ _bfd_elf_merge_symbol (bfd *abfd, > > > h->root.non_ir_ref_dynamic = true; > > > hi->root.non_ir_ref_dynamic = true; > > > } > > > - > > > - if ((oldbfd->flags & BFD_PLUGIN) != 0 > > > - && hi->root.type == bfd_link_hash_indirect) > > > + else if ((oldbfd->flags & BFD_PLUGIN) != 0 > > > + && hi->root.type == bfd_link_hash_indirect) > > > { > > > /* Change indirect symbol from IR to undefined. */ > > > hi->root.type = bfd_link_hash_undefined; > > and the patch do not exactly match. The code logic is old sym > indirect in IR, new sym not IR, both in shared library *or both not*. > Is that correct? > The existing code is if (newdyn != olddyn) { /* Handle a case where plugin_notice won't be called and thus won't set the non_ir_ref flags on the first pass over symbols. */ h->root.non_ir_ref_dynamic = true; hi->root.non_ir_ref_dynamic = true; } If an indirect symbol defined in IR is marked with non_ir_ref_dynamic, we can't change it to undefined. That is why I added "else" so that we don't get the error of undefined reference from shared object. if ((oldbfd->flags & BFD_PLUGIN) != 0 && hi->root.type == bfd_link_hash_indirect) { /* Change indirect symbol from IR to undefined. */ hi->root.type = bfd_link_hash_undefined; hi->root.u.undef.abfd = oldbfd; } -- H.J.