[PATCH] ld: Call plugin hooks only if they are available
H.J. Lu
hjl.tools@gmail.com
Wed Dec 16 18:40:11 GMT 2020
On Wed, Dec 16, 2020 at 10:34 AM Howard Chu <hyc@symas.com> wrote:
>
> H.J. Lu wrote:
> > On Wed, Dec 16, 2020 at 3:16 AM Nick Clifton via Binutils
> > <binutils@sourceware.org> 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.
More information about the Binutils
mailing list