https://sourceware.org/bugzilla/show_bug.cgi?id=33198

--- Comment #16 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <h...@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f752be8f916efa70aea9c2e4f664c75690fd136c

commit f752be8f916efa70aea9c2e4f664c75690fd136c
Author: H.J. Lu <hjl.to...@gmail.com>
Date:   Tue Jul 22 14:09:48 2025 -0700

    strip: Properly handle LLVM IR bitcode

    commit 717a38e9a02109fcbcb18bb2ec3aa251e2ad0a0d
    Author: H.J. Lu <hjl.to...@gmail.com>
    Date:   Sun May 4 05:12:46 2025 +0800

        strip: Add GCC LTO IR support

    added "-R .gnu.lto_.*" to strip to remove all GCC LTO sections.  When
    "-R .gnu.lto_.*" is used, the plugin target is ignored so that all LTO
    sections are stripped as the regular sections.  It works for the slim
    GCC LTO IR since the GCC LTO IR is stored in the regular sections.  When
    the plugin target is ignored, the GCC LTO IR can be recognized as the
    normal object files.  But it doesn't work for the slim LLVM IR which
    is stored in a standalone file.

    1. Add bfd_check_format_matches_lto and bfd_check_format_lto to take an
    argument, lto_sections_removed, to indicate if all LTO sections should
    be removed.
    2. Update strip to always enable the plugin target so that the plugin
    target is enabled when checking for bfd_archive.
    3. Update strip to ignore the plugin target for bfd_object when all LTO
    sections should be removed.  If the object is unknown, copy it as an
    unknown file without any messages.
    4. Treat the "-R .llvm.lto" strip option as removing all LTO sections.

    bfd/

            PR binutils/33198
            * format.c (bfd_check_format_lto): New function.
            (bfd_check_format): Call bfd_check_format_matches_lto.
            (bfd_check_format_matches): Renamed to ...
            (bfd_check_format_matches_lto): This.  Add an argument,
            lto_sections_removed, to indicate if all LTO sections should be
            removed and don't match the plugin target if lto_sections_removed
            is true.
            (bfd_check_format_matches): Call bfd_check_format_matches_lto.
            * bfd-in2.h: Regenerated.

    binutils/

            PR binutils/33198
            * objcopy.c (copy_archive): Call bfd_check_format_lto, instead
            of bfd_check_format, and pass lto_sections_removed.  Remove the
            non-fatal message on unknown element since it will be copied as
            an unknown file.
            (copy_file): Don't check lto_sections_removed when enabling LTO
            plugin in strip.
            (copy_file): Ignore the plugin target first if all LTO sections
            should be removed.  Try with the plugin target next if ignoring
            the plugin target failed to match the format.
            (strip_main): Also set lto_sections_removed for -R .llvm.lto.
            * testsuite/binutils-all/x86-64/pr33198.c: New file.
            * testsuite/binutils-all/x86-64/x86-64.exp (run_pr33198_test):
            New.
            Run binutils/33198 tests.
            * testsuite/lib/binutils-common.exp (llvm_plug_opt): New.
            (CLANG_FOR_TARGET): New.  Set to "clang" for native build if
            "clang -v" reports "clang version".

    Signed-off-by: H.J. Lu <hjl.to...@gmail.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to