From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by sourceware.org (Postfix) with ESMTPS id 3A1503860C37 for ; Thu, 3 Sep 2020 01:31:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3A1503860C37 Received: by mail-pj1-x1044.google.com with SMTP id mw10so649597pjb.2 for ; Wed, 02 Sep 2020 18:31:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=0IHtbwq9OsD3BhcdF0W8Kk3US7W74kzZ0g2ENQDUko0=; b=pmMrX3fHu96OFmO+fXSctiNIKSoziqava9YH1aiGva6Q2rJObENdflOF5tzSR8IUHi bHUb8to4uQdaGD7oN6ZyPeyyo4SbRV0XiqKAiaF19h8LimjaFsJIrYXv5PKgb76FFjXQ e0luPa9XjE5JWloUTchKv0MtcjXEHbgONSpyuzGfGt8r6lvEWxvEHyJ0bmXNKIQbDqk9 BV8fA7dXOTys4UITd8vWLDzQp9yit9AM+x9K8u6TzOAigsPeC46wAFACmsZOw1ZtbJQ7 1Hmc7ftQJCLI83mZUUBkKeXW8OwLpcFuqBSHHNx3bnPGPdHIKwL8hUMJXS1BHM5fTwxK yOrw== X-Gm-Message-State: AOAM530jeW/V22EgDAvTELf2/4R2S9O7mr/C/1cOUG2+u/vH77RjiuBC 3f3/iqBemU9LWA3OgmgUZ3y3ne2M+YU= X-Google-Smtp-Source: ABdhPJxrMPm6JhdWIquYlTWTD0CfAt4EzJ9WIz4ZUFOE2Z4P6jU3niNkEdeGLXnFQRK0txjJ0WECPA== X-Received: by 2002:a17:90a:e64e:: with SMTP id ep14mr159786pjb.173.1599096702390; Wed, 02 Sep 2020 18:31:42 -0700 (PDT) Received: from bubble.grove.modra.org ([2406:3400:51d:8cc0:d197:c5ae:484a:3c93]) by smtp.gmail.com with ESMTPSA id mp1sm617458pjb.27.2020.09.02.18.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 18:31:41 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 0D07187AC1; Thu, 3 Sep 2020 11:01:38 +0930 (ACST) Date: Thu, 3 Sep 2020 11:01:37 +0930 From: Alan Modra To: "H.J. Lu" Cc: Martin =?utf-8?B?TGnFoWth?= , Binutils Subject: Re: [PATCH] elf: Don't load archive element after dynamic definition Message-ID: <20200903013137.GM15695@bubble.grove.modra.org> References: <20200828144914.GP15695@bubble.grove.modra.org> <20200902081225.GH15695@bubble.grove.modra.org> <20200902130522.GI15695@bubble.grove.modra.org> <20200902142930.GJ15695@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Thu, 03 Sep 2020 01:31:44 -0000 On Wed, Sep 02, 2020 at 07:35:58AM -0700, H.J. Lu wrote: > On Wed, Sep 2, 2020 at 7:29 AM Alan Modra wrote: > > > > On Wed, Sep 02, 2020 at 06:22:08AM -0700, H.J. Lu wrote: > > > > It's reasonably obvious that we need to load archive elements when > > > > they define IR referenced symbols, because the archive element might > > > > be an LTO object. What's not so obvious is whether loading of shared > > > > libraries should follow the same rule. I think they should, in order > > > > for LTO to get symbol resolution correct in corner cases. Basically > > > > LTO needs to know what shared libraries are loaded before > > > > recompilation. See commit a896df97b952 log comments. > > > > > > There is dynamic_def for this purpose. > > > > Your patch doesn't make changes to ld/plugin.c to inform LTO of the > > availability of these symbols. And if you did, then how does the > > linker work out whether or not the LTO recompilation depended on those > > symbols? If it did change LTO recompilation then you had better > > ensure the library really is loaded. By the time you work all of that > > out, if it is even possible, your patch will likely be very > > complicated indeed. > > A testcase? What don't you understand from my emails in this thread? I suggest you look at what happened with the testcase in PR26314, in regard to my comment The lto recompilation didn't see symbol references from libbfd.so and variables like _xexit_cleanup are made local in the recompiled objects. Oops, two copies of them. That's critical in understanding why LTO needs to know about symbols from shared libraries before LTO recompilation. -- Alan Modra Australia Development Lab, IBM