PR 21497 supplemental patch

H.J. Lu hjl.tools@gmail.com
Tue Jul 22 17:29:14 GMT 2025


On Tue, Jul 22, 2025 at 7:21 AM Nick Clifton <nickc@redhat.com> wrote:
>
> Hi HJ, Hi Sam,
>
>   We have recently run across a problem in Fedora building LLVM:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=2382341

Hi Nick,

I can't download the attachment in the bug report above.  Can you
open a binutils bug report with a testcase and assign it to me?

Thanks.

>
>   I have traced the problem back to the fact that strip will now load a
>   plugin to handle GCC LTO data in archive members (ie PR 21479).
>   This is great unless the plugin fails to recognise the archive member,
>   because if that happens strip will stop with an unrecognised format
>   error message, rather than continuing to process other elements.
>
>   So I would like to propose a small change to the current code.  The
>   patch below first tries opening the element with the "plugin" target,
>   but if that fails, it carries on to try to open the element normally.
>
>   This solves the problem reported in BZ 2382341 and seems to make sense
>   to me.  Do either of you have any concerns with me applying this patch
>   ?
>
> Cheers
>   Nick
>
> diff --git a/binutils/objcopy.c b/binutils/objcopy.c
> index 2ca04e84d47..b400d4daba7 100644
> --- a/binutils/objcopy.c
> +++ b/binutils/objcopy.c
> @@ -3880,15 +3880,22 @@ copy_file (const char *input_filename, const char *output_filename, int ofd,
>      }
>
>  #if BFD_SUPPORTS_PLUGINS
> -  /* Enable LTO plugin in strip unless all LTO sections should be
> -     removed.  */
> +  /* PR 21479: Enable the LTO plugin in strip
> +     unless all LTO sections should be removed.  */
>    if (is_strip && !target && !lto_sections_removed)
> -    target = "plugin";
> +    {
> +      ibfd = bfd_openr (input_filename, "plugin");
> +      if (ibfd != NULL)
> +       goto loaded;
> +      /* But if that fails, try opening the target as normal.  */
> +    }
>  #endif
>
> +  ibfd = bfd_openr (input_filename, target);
> +
> + loaded:
>    /* To allow us to do "strip *" without dying on the first
>       non-object file, failures are nonfatal.  */
> -  ibfd = bfd_openr (input_filename, target);
>    if (ibfd == NULL || bfd_stat (ibfd, in_stat) != 0)
>      {
>        bfd_nonfatal_message (input_filename, NULL, NULL, NULL);
>
>


-- 
H.J.


More information about the Binutils mailing list