H.J. Lu a0d3507d10 strip: Properly handle LLVM IR bitcode
commit 717a38e9a0
Author: H.J. Lu <hjl.tools@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.tools@gmail.com>
(cherry picked from commit f752be8f91)
2025-07-24 06:57:44 -07:00
2025-07-13 08:35:45 +01:00
2025-07-13 08:35:45 +01:00
2025-07-13 08:57:43 +01:00
2025-07-21 09:22:09 -07:00
2025-07-13 08:35:45 +01:00
2025-07-13 08:35:45 +01:00
2023-08-12 10:27:57 +09:30
2025-07-10 14:26:10 +01:00
2025-02-28 16:06:25 +00:00
2025-07-13 08:35:45 +01:00

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.
Description
Unofficial mirror of sourceware binutils-gdb repository. Updated daily.
Readme 1,005 MiB
Languages
C 50.5%
Makefile 22.7%
Assembly 13.2%
C++ 5.9%
Roff 1.5%
Other 5.6%