]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
strip: Don't treat fat IR objects as plugin object
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 3 Aug 2025 17:28:40 +0000 (10:28 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 6 Aug 2025 11:51:20 +0000 (04:51 -0700)
commitc2729c37f10af09126b2916215cae425ae724f55
tree96223ddb0cdb402f063147be060f247005138994
parentd6e93eedfb9e75846c3083f49f9015eda1a2be33
strip: Don't treat fat IR objects as plugin object

Fat IR objects contains both regular sections and IR sections.  After

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

    strip: Add GCC LTO IR support

"strip --strip-debug" no longer strips debug sections in fat IR objects
since fat IR objects are recognized as plugin object and copied as unknown
objects.  Add a is_strip_input field to bfd to indicate called from strip.
Update bfd_check_format_matches not to treat archive member nor standalone
fat IR object as IR object so that strip can remove debug and IR sections
in fat IR object.  For archive member, it is copied as an unknown object
if the plugin target is in use or it is a slim IR object.  For standalone
fat IR object, it is copied as non-IR object.

bfd/

PR binutils/33246
* archive.c: Include "plugin-api.h" and "plugin.h" if plugin is
enabled.
(_bfd_compute_and_write_armap): Don't complain plugin is needed
when the plugin target is in use.
* bfd-in2.h: Regenerated.
* bfd.c (bfd): Add is_strip_input.
* format.c (bfd_set_lto_type): If there is .llvm.lto section,
set LTO type to lto_fat_ir_object.
(bfd_check_format_matches): Don't set LTO type when setting
format.  When called from strip, don't treat archive member nor
standalone fat IR object as an IR object.
* plugin.c (bfd_plugin_get_symbols_in_object_only): Copy LTO
type derived from input sections.

nm/

PR binutils/33246
* nm.c (filter_symbols): Don't complain plugin is needed when
the plugin target is in use.
(display_rel_file): Likewise.
* objcopy.c (copy_archive): Set the BFD is_strip_input field of
archive member to 1 to indicate called from strip.  Also copy
slim IR archive member as unknown object.
(copy_file): Set the BFD is_strip_input field of input bfd to
1 to indicate called from strip.
(strip_main): Keep .gnu.debuglto_* sections unless all GCC LTO
sections will be removed.

ld/

PR binutils/33246
* testsuite/ld-plugin/lto-binutils.exp (run_pr33246_test): New.
Run binutils/33246 tests with GCC and Clang.
* testsuite/ld-plugin/pr33246.c: New file.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
bfd/archive.c
bfd/bfd-in2.h
bfd/bfd.c
bfd/format.c
bfd/plugin.c
binutils/nm.c
binutils/objcopy.c
ld/testsuite/ld-plugin/lto-binutils.exp
ld/testsuite/ld-plugin/pr33246.c [new file with mode: 0644]