Files
binutils-gdb/bfd
Kito Cheng 44c3932467 RISC-V: Add second-pass relaxation for JAL to C.J/C.JAL
When linker relaxation converts CALL (auipc+jalr, 8 bytes) to JAL
(4 bytes), further relaxation to C.J or C.JAL (2 bytes) may become
possible as code shrinks and jump distances decrease.

This patch adds _bfd_riscv_relax_jal to perform this second-pass
relaxation.  To enable this, we introduce R_RISCV_DELETE_AND_RELAX,
a new internal relocation that combines piecewise deletion with
preservation of relaxation capability.  When _bfd_riscv_relax_call
relaxes CALL to JAL, it marks the deletion as R_RISCV_DELETE_AND_RELAX
instead of R_RISCV_DELETE.  After the piecewise deletion is resolved,
R_RISCV_DELETE_AND_RELAX is converted back to R_RISCV_RELAX at the
JAL instruction offset, allowing _bfd_riscv_relax_jal to further
relax JAL to C.J/C.JAL.

C.JAL is only available on RV32 (rd=ra), while C.J is available on
both RV32 and RV64 (rd=x0).

Changes since v1:
- Use R_RISCV_DELETE_AND_RELAX with piecewise deletion instead of
  calling _riscv_relax_delete_immediate directly, to maintain
  relaxation performance.
- Add preserve_relax parameter to riscv_relax_delete_bytes to
  simplify the logic in _bfd_riscv_relax_call.
2026-01-15 12:04:57 +08:00
..
2026-01-08 09:18:29 -07:00
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 19:30:16 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 19:30:16 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:12:26 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 19:30:16 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 13:14:22 +10:30
2026-01-04 19:30:16 +10:30
2026-01-15 00:00:07 +00:00
2025-07-13 08:57:08 +01:00

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

BFD is an object file library.  It permits applications to use the
same routines to process object files regardless of their format.

BFD is used by the GNU debugger, assembler, linker, and the binary
utilities.

The documentation on using BFD is scanty and may be occasionally
incorrect.  Pointers to documentation problems, or an entirely
rewritten manual, would be appreciated.

There is some BFD internals documentation in doc/bfdint.texi which may
help programmers who want to modify BFD.

BFD is normally built as part of another package.  See the build
instructions for that package, probably in a README file in the
appropriate directory.

BFD supports the following configure options:

  --target=TARGET
	The default target for which to build the library.  TARGET is
	a configuration target triplet, such as sparc-sun-solaris.
  --enable-targets=TARGET,TARGET,TARGET...
	Additional targets the library should support.  To include
	support for all known targets, use --enable-targets=all.
  --enable-64-bit-bfd
	Include support for 64 bit targets.  This is automatically
	turned on if you explicitly request a 64 bit target, but not
	for --enable-targets=all.  This requires a compiler with a 64
	bit integer type, such as gcc.
  --enable-shared
	Build BFD as a shared library.
  --with-mmap
	Use mmap when accessing files.  This is faster on some hosts,
	but slower on others.  It may not work on all hosts.

Report bugs in BFD to https://sourceware.org/bugzilla/

Patches are encouraged.  When sending patches, always send the output
of diff -u or diff -c from the original file to the new file.  Do not
send default diff output.  Do not make the diff from the new file to
the original file.  Remember that any patch must not break other
systems.  Remember that BFD must support cross compilation from any
host to any target, so patches which use ``#ifdef HOST'' are not
acceptable.  Please also read the ``Reporting Bugs'' section of the
gcc manual.

Bug reports without patches will be remembered, but they may never get
fixed until somebody volunteers to fix them.

Copyright (C) 2012-2026 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.