From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 786EC385840A for ; Mon, 14 Feb 2022 04:13:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 786EC385840A Received: by mail-pj1-x102a.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso17624737pjt.4 for ; Sun, 13 Feb 2022 20:13:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1CSrqKeIJo+wsHeoXT5chTPRyKil1olNJxEqgFLcDHQ=; b=M7/QL1bk0O+Vd7YR+n0uLFs0qoNeHmQxUrPT5SpIAqL7eS+Hww9jjK7mrTwRQ1vdGe pvae0M3fCLpSQn7bjsPN+G+TeKc4Lo2xtC8NVB5Q9A6yjRxENyD2UWzF0hkhgRqDqaU1 F3Wv6t40AIgph3pnMGx/7RxJi5X4ucEP3YVsF8VbcmFuSobbw12Sm/0U2MM4DdE3DjE7 SKhQeVIbcNR0oAv8CCMBaTKLkpLhxUjFeczHRfD/Pvpl8tzO9YB/Xc5QSJ2bnRnRY6/g yaAKrTqp9Mmh+mT79JaT6PnFCX4uqjD9RN2FKz5mbqlRz+KvmgR1bWHknUbEriGSj61C 98vg== X-Gm-Message-State: AOAM5306p+n6v6gJcGStcIKRe3l1T6Jwc1Re5IONS0+LApYtbydbPN1k +OC5AFmbo1+ZVk5djpqRJsM= X-Google-Smtp-Source: ABdhPJwd1Df1/TOh9oIxmg+wfWJPgVvELA7PoHWD+6F2rxD1xz0krjz9UHRojR9IUr7UlvGSrRopRA== X-Received: by 2002:a17:90b:350e:: with SMTP id ls14mr12660774pjb.51.1644812026625; Sun, 13 Feb 2022 20:13:46 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:4cd3:5a51:b00e:3076]) by smtp.gmail.com with ESMTPSA id b20sm15678309pfv.31.2022.02.13.20.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Feb 2022 20:13:45 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id C52241140133; Mon, 14 Feb 2022 14:43:42 +1030 (ACDT) Date: Mon, 14 Feb 2022 14:43:42 +1030 From: Alan Modra To: "H.J. Lu" Cc: Binutils , Nick Clifton Subject: Re: [PATCH] ld: Keep indirect symbol from IR if referenced from shared object Message-ID: References: <20220211231927.2021394-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3037.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 04:13:48 -0000 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. > 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