From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 6A58A3840C33 for ; Wed, 16 Dec 2020 18:40:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6A58A3840C33 Received: by mail-ot1-x330.google.com with SMTP id d8so24007170otq.6 for ; Wed, 16 Dec 2020 10:40:48 -0800 (PST) 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; bh=jHbVd11cSRcZwytFuGaBFx8dsybK4iKGLGzcMWhTekE=; b=h6URNzn21TQ5afzEbk76/TWBTVnDjuxmV/Y7UTktpYh97J9RyE1MJmcke9W5hG7B2b M1zoy3wLEWoMkCivWqbhJmDui6BVm8Yb57seltEboR7NE7pMfFgBiZxj2A50+n/KOMQj FkEJZVhmyEoSWjZLIU4owCPCsQsUNBXqJinumkNKy4qXB9+nER6r5ENhtJPB7Xohb8Xx QjujzjXUDl5wKMh1UmvNulVfgf7DtUGECsCnbZ6fCYce0522jaI424sbyfNnP2VoI2OW FQIhOQ/foPO20KQJyFBzQmHofmBmDy53vqUb1Vl8XgkxZazEWlCnhNXCWOkpz+UgyhW2 HXQQ== X-Gm-Message-State: AOAM530fiWQqECDuesaqaTNvtbv6JqMFIpTyY//oZ6nhahLMpUq6pX2h 0S/MGrFqRjNiIpTfBD8oH5C4x3AGX4sA0nz5fcU5uzsmN2Q= X-Google-Smtp-Source: ABdhPJyVB0sZG32EpisVXGcM1nhBzqh4pXRY9ulMOOSN+0LYGvAgIdhncuFE4lgQchSrl7pDdFaLguHjYtJgbwPRreo= X-Received: by 2002:a9d:eeb:: with SMTP id 98mr26864508otj.179.1608144047803; Wed, 16 Dec 2020 10:40:47 -0800 (PST) MIME-Version: 1.0 References: <53b8973b-40a4-2550-3307-66d7f13707d5@symas.com> <1aaf4429-074c-7912-e6e6-4d2f82d6ef10@redhat.com> <7b118db2-9502-c45e-9f47-6b6f6a5f9646@symas.com> <7dba4046-3d50-c7e6-915d-08bf590bf057@redhat.com> <7b124cd4-529b-0069-3044-9d733a4e4e5c@symas.com> <20ad87a3-283d-7e49-9c2e-ed13001f6c87@symas.com> <70139665-0b8c-63dc-3a9d-b24a25bd8122@redhat.com> <2475d2a6-c63e-6dac-0f56-fa9acb6f20de@symas.com> <0e9925e6-512b-0ed6-8846-a86a40fb0a47@redhat.com> <3bfc2ea0-d49d-a194-18e0-57c007fd3746@redhat.com> <7ce0403d-00ac-d853-3af8-c612a6eaa1d0@redhat.com> <5329641c-0689-1f8a-cfbd-d728087b4ebf@symas.com> In-Reply-To: <5329641c-0689-1f8a-cfbd-d728087b4ebf@symas.com> From: "H.J. Lu" Date: Wed, 16 Dec 2020 10:40:11 -0800 Message-ID: Subject: Re: [PATCH] ld: Call plugin hooks only if they are available To: Howard Chu Cc: Nick Clifton , Cary Coutant , Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3037.2 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, URIBL_RED 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, 16 Dec 2020 18:40:49 -0000 On Wed, Dec 16, 2020 at 10:34 AM Howard Chu wrote: > > H.J. Lu wrote: > > On Wed, Dec 16, 2020 at 3:16 AM Nick Clifton via Binutils > > wrote: > >> > >> Hi Howard, > >> > >>>> Why not just make the new plugin disable itself if the host tool > >>>> doesn't provide the all_symbols_read entry point? > >>> > >>> Yeah, that'd be fine too. Just noop/silently exit if entry points are missing. > >>> I can write that up if folks agree it's better. > >> > >> Please do. > >> > >> It turns out that my proposed fix breaks the LTO plugin, so it is a no-go. :-( > >> > > > > I am going to check this in if there are no objections today. > > > diff --git a/ld/libdep_plugin.c b/ld/libdep_plugin.c > index 2a7fdc4d0b..37ad7c7f97 100644 > --- a/ld/libdep_plugin.c > +++ b/ld/libdep_plugin.c > @@ -346,20 +346,10 @@ onload (struct ld_plugin_tv *tv) > return LDPS_ERR; > } > (*tv_register_claim_file) (onclaim_file); > - if (!tv_register_all_symbols_read) > - { > - TV_MESSAGE (LDPL_FATAL, "No register_all_symbols_read hook"); > - fflush (NULL); > - return LDPS_ERR; > - } > - (*tv_register_all_symbols_read) (onall_symbols_read); > - if (!tv_register_cleanup) > - { > - TV_MESSAGE (LDPL_FATAL, "No register_cleanup hook"); > - fflush (NULL); > - return LDPS_ERR; > - } > - (*tv_register_cleanup) (oncleanup); > + if (tv_register_all_symbols_read) > + (*tv_register_all_symbols_read) (onall_symbols_read); > + if (tv_register_cleanup) > + (*tv_register_cleanup) (oncleanup); > fflush (NULL); > return LDPS_OK; > } > > The plugin shouldn't register any hooks at all, if any of these aren't available. > There's no point in doing the register_claim_file, that will just be wasted work. My branch has a testcase which fails today: https://gitlab.com/x86-binutils/binutils-gdb/-/commits/users/hjl/pr27081/master Please send me a patch on top of mine to fix the testcase. -- H.J.