[binutils-gdb/binutils-2_44-branch] lto: Set plugin_format to bfd_plugin_no only if known_used is set

H.J. Lu hjl@sourceware.org
Fri Oct 31 23:15:14 GMT 2025


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

commit f58151627fb61483e6e065d8ce1b334280abdf82
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Oct 28 20:21:19 2025 +0800

    lto: Set plugin_format to bfd_plugin_no only if known_used is set
    
    commit b21318bd2c29fcca8f99c1de7facdaa5cb2e66e2
    Author: Joseph Myers <joseph@codesourcery.com>
    Date:   Thu May 11 14:31:09 2023 +0000
    
        Add LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook [GCC PR109128]
    
    added the LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook for offload
    support.  Since the V2 linker plugin hook doesn't claim the offload IR if
    known_used is unset, set input plugin_format to bfd_plugin_no only if
    known_used is set or the V2 linker plugin hook is unused.
    
            PR ld/33584
            * plugin.c (plugin_object_p): Set plugin_format to bfd_plugin_no
            only if known_used is set or the V2 linker plugin hook is unused.
    
    Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
    (cherry picked from commit 19c4084cfaadabe7d514a98019d68fe0a8bb8940)

Diff:
---
 ld/plugin.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ld/plugin.c b/ld/plugin.c
index e0013fc44bc..d44a00463a0 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -1325,8 +1325,13 @@ plugin_object_p (bfd *ibfd, bool known_used)
 #endif
 
       /* If plugin didn't claim the file, we don't need the dummy bfd.
-	 Can't avoid speculatively creating it, alas.  */
-      ibfd->plugin_format = bfd_plugin_no;
+	 Can't avoid speculatively creating it, alas.  NB: Set input
+	 plugin_format to bfd_plugin_no only if known_used is set or
+	 the LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook is
+	 unused since the V2 linker plugin hook doesn't claim the
+	 offload IR if known_used is unset.  */
+      if (known_used || !claim_file_handler_v2)
+	ibfd->plugin_format = bfd_plugin_no;
       bfd_close_all_done (abfd);
       return NULL;
     }


More information about the Binutils-cvs mailing list