From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by sourceware.org (Postfix) with ESMTPS id BEA103894C16 for ; Wed, 2 Sep 2020 13:22:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BEA103894C16 Received: by mail-io1-xd44.google.com with SMTP id b6so5204809iof.6 for ; Wed, 02 Sep 2020 06:22:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=D+eFJr/1zJlYAjhboV+cLptc4hciwLz5TcyjrIkdYp8=; b=oSI0kAX9rej3UhrZnfH4t68m6k9gJbRTma7rW4X2CypBsFF5ESS6zFqT/NSBDhyWlY 3f3glkoRsvlLipNDnavttZJgzMoHOrXPN/8djsFxIZR3vX0xOkpE5eWGT/uQSbyNGBhS CxbP4AdhcTGcyrpslg13hqQAm17xdluph29kkgqC6UjtW3dVn1oE7kbT2zf2dug92ILy I5IAItTE2BOX/89UxPmKXCG56HMb5HkDDCBvJxbXNQPAcmldI2SuX5G8P7EnIssBsgtI 2kby+ggR4tVJ+sIVyhh+frOgNPjT7mANekicRojnyN9dur/0T+zHNPn1vl/LuLc8E7I8 F82A== X-Gm-Message-State: AOAM531+STw6dPI/ZpSQ5uh7scF3aTGam0lMId8xIc765UtGO5th0Ijz 8zSPaoRPnV+EyjInvlPT5PuI1dhqRq5K+JP9k9M= X-Google-Smtp-Source: ABdhPJz6alg2x4kUASgRuUNoergjMjD1e4CSQsJiItwiymLrDYBLFHbOv06F2vLA267uUHFATcHy827D+ucnFpwLCfI= X-Received: by 2002:a5d:9ed3:: with SMTP id a19mr3510397ioe.28.1599052963799; Wed, 02 Sep 2020 06:22:43 -0700 (PDT) MIME-Version: 1.0 References: <20200825172842.1212936-1-hjl.tools@gmail.com> <20200827135311.GD15695@bubble.grove.modra.org> <20200828015847.GG15695@bubble.grove.modra.org> <20200828144914.GP15695@bubble.grove.modra.org> <20200902081225.GH15695@bubble.grove.modra.org> <20200902130522.GI15695@bubble.grove.modra.org> In-Reply-To: <20200902130522.GI15695@bubble.grove.modra.org> From: "H.J. Lu" Date: Wed, 2 Sep 2020 06:22:08 -0700 Message-ID: Subject: Re: [PATCH] elf: Don't load archive element after dynamic definition To: Alan Modra Cc: =?UTF-8?Q?Martin_Li=C5=A1ka?= , Binutils Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.3 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 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: Wed, 02 Sep 2020 13:22:47 -0000 On Wed, Sep 2, 2020 at 6:05 AM Alan Modra wrote: > > On Wed, Sep 02, 2020 at 04:56:48AM -0700, H.J. Lu wrote: > > On Wed, Sep 2, 2020 at 1:12 AM Alan Modra wrote: > > > > > > On Wed, Sep 02, 2020 at 08:52:06AM +0200, Martin Li=C5=A1ka wrote: > > > > On 8/28/20 4:50 PM, H.J. Lu via Binutils wrote: > > > > > PR ld/26530 test still failed. > > > > > > > > Hello. > > > > > > > > Is there any progress on this please? > > > > > > I think what we want is the following, and some tweaking of the > > > testsuite to remove FAIL: PR ld/15146 (1). That test relied on not > > > loading a shared lib due to an IR symbol reference, but the logic > > > added by git commit 3d5bef4c0871 has already been reverted. > > > > > > diff --git a/bfd/elflink.c b/bfd/elflink.c > > > index 5c085b14b7..346f534911 100644 > > > --- a/bfd/elflink.c > > > +++ b/bfd/elflink.c > > > @@ -4977,11 +4977,7 @@ elf_link_add_object_symbols (bfd *abfd, struct= bfd_link_info *info) > > > object and a shared object. */ > > > bfd_boolean dynsym =3D FALSE; > > > > > > - /* Plugin symbols aren't normal. Don't set def_regular or > > > - ref_regular for them, or make them dynamic. */ > > > - if ((abfd->flags & BFD_PLUGIN) !=3D 0) > > > - ; > > > - else if (! dynamic) > > > + if (! dynamic) > > > { > > > if (! definition) > > > { > > > @@ -5162,10 +5158,6 @@ elf_link_add_object_symbols (bfd *abfd, struct= bfd_link_info *info) > > > && !bfd_link_relocatable (info)) > > > dynsym =3D FALSE; > > > > > > - /* Nor should we make plugin symbols dynamic. */ > > > - if ((abfd->flags & BFD_PLUGIN) !=3D 0) > > > - dynsym =3D FALSE; > > > - > > > if (definition) > > > { > > > h->target_internal =3D isym->st_target_internal; > > > @@ -5192,7 +5184,7 @@ elf_link_add_object_symbols (bfd *abfd, struct = bfd_link_info *info) > > > } > > > } > > > > > > - if (dynsym && h->dynindx =3D=3D -1) > > > + if (dynsym && (abfd->flags & BFD_PLUGIN) =3D=3D 0 && h->dyn= indx =3D=3D -1) > > > { > > > if (! bfd_elf_link_record_dynamic_symbol (info, h)) > > > goto error_free_vers; > > > > Will it add a shared library to DT_NEEDED even if the IR symbol referen= ce is > > removed by LTO? > > Yes. That can't be helped. I know we worried about unnecessary > --as-needed shared libraries in the past when IR symbols disappear > after LTO, but I can't see a simple and reliable way for the linker to > be correct. My patch isn't very complicated. > 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. --=20 H.J.