From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 838113858412 for ; Mon, 14 Feb 2022 15:29:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 838113858412 Received: by mail-pf1-x42a.google.com with SMTP id l19so23994009pfu.2 for ; Mon, 14 Feb 2022 07:29:32 -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=O7I/XIKTXjDtNMJesLHvDQSP+eTsoL3WYvc0FPcYFF4=; b=kCGn/AZB1BUXsm/AYE9t6QfJll0UUiwyY6hQ7l5n9m66yXEalxw4FLkRccfgFU0O69 RB96NTEQe+/SThzj1M+nJzFtG+2odSq5ypZWykWJtLcVUi0VU0v7GB3vxPHNibyoSrdq PlzfYRy2VofTbCOf/OKuVdEVOFwqRsGfyuH+/6YcFru7EP21X5pNFBav3Ccgrrk6i/WA +1G+kU/RmE6RJax70umu3AJCDcv1go9h+jn7c0O4ThTcFAe4Jr+3waW+82+fmxP98JEj FI3SYX12+Q5hxd7gXFoDrDTJhQ7gHyAeqJR1+hu5GVOaIOfOGeN75yRwmDfZ5bXMpg3t eAVQ== X-Gm-Message-State: AOAM530Z9soI/ca6pjhqarfqPEtRaosmPCUI9K///sWiyoVk+0xOlMn8 t8OMH4Mlmr2FwXfcbP26wgmerDqlB5lP61mcJc8= X-Google-Smtp-Source: ABdhPJyFcaIr3mBH42qEH/GmnlxoVSJ/HxLrMLqnFK6Gwv8VkGuFSNhjfN8OXkXvIBEP+eSwqFeUkaHhptrw92IKw10= X-Received: by 2002:a63:8542:: with SMTP id u63mr244559pgd.210.1644852571572; Mon, 14 Feb 2022 07:29:31 -0800 (PST) MIME-Version: 1.0 References: <20220211231927.2021394-1-hjl.tools@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Mon, 14 Feb 2022 07:28:55 -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=-3026.8 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 15:29:34 -0000 On Sun, Feb 13, 2022 at 8:13 PM Alan Modra wrote: > > On Sun, Feb 13, 2022 at 06:58:48PM -0800, H.J. Lu wrote: > > 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. > > The patch is OK, I wasn't thinking clearly. I checked it into master branch and will backport it to 2.38 branch later this week. > > 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. > > -- > Alan Modra > Australia Development Lab, IBM -- H.J.