rx: check relaxation delete range, propagate failures
Harden RX linker relaxation by validating deletion ranges and propagating errors.
This patch enhances linker relaxation for the RX architecture by validating deletion ranges in elf32_rx_relax_delete_bytes using _bfd_elf_relax_delete_range_ok. It also propagates any deletion failures in elf32_rx_relax_section to the error handling path. A new DejaGnu test case, ld-rx/rx-relax-underflow.exp, is added to cover these scenarios. The patch notes that some out-of-range relocation issues might still cause faults before deletion.
- proposer
Validates deletion ranges in RX relaxation, propagates failures, and adds a regression test.
“Validate deletion range in elf32_rx_relax_delete_bytes using _bfd_elf_relax_delete_range_ok and drop redundant BFD_ASSERT. Wrap SNIPNR and SNIP macros in do-while(0) blocks. Propagate deletion return status in elf32_rx_relax_section and branch to error_return on error. Add DejaGnu regression test ld-rx/rx-relax-underflow.exp.”
In Details
This patch modifies the linker relaxation code for the RX architecture, specifically in bfd/elf32-rx.c. It introduces checks using _bfd_elf_relax_delete_range_ok to ensure that byte deletion operations during relaxation do not go out of bounds. Failures from these checks are now propagated correctly, and a new regression test is added to catch underflow conditions.
- linker relaxation
- A linker optimization process that adjusts instruction addresses and sizes at link time to improve code density or enable features like position-independent code. It may involve deleting or replacing instructions.
- RX
- Renesas RX microcontrollers, a series of 32-bit embedded processors for which the GNU toolchain provides support.
- DejaGnu
- A testing framework for regression testing of software, often used for compilers and other complex software systems.
- underflow
- In the context of memory or arithmetic operations, underflow occurs when a value becomes smaller than the minimum representable value. For unsigned integers, this typically results in wrap-around to a very large positive number.