binutils Newspaper
NOVEMBER 30, 2026
avr — Proposed

avr: check relaxation delete range and propagate failure

AVR linker relaxation now validates deletion ranges and propagates errors.

This patch strengthens the AVR ELF relaxation process by validating deletion ranges within elf32_avr_relax_delete_bytes using the _bfd_elf_relax_delete_range_ok helper. It ensures that any failure during the byte deletion is properly propagated in elf32_avr_relax_section, directing execution to the error return path. This change enhances the robustness of the AVR linker.

In the Thread 1 participant
  1. Harshit Kumar <harshit7kr@gmail.com> proposer

    Adds range validation and error propagation to AVR relaxation delete operations.

    “Validate deletion range in elf32_avr_relax_delete_bytes using _bfd_elf_relax_delete_range_ok. Propagate failure returns in elf32_avr_relax_section and branch to error_return on error.”

In Details

This patch modifies the linker relaxation code for the AVR architecture, specifically in bfd/elf32-avr.c. It integrates the _bfd_elf_relax_delete_range_ok function to validate the parameters for elf32_avr_relax_delete_bytes before performing memory operations. Crucially, it ensures that any failure reported by this validation is propagated up to elf32_avr_relax_section and handled by the error_return path, preventing potential heap corruption.

For Context
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.
AVR
A family of microcontrollers developed by Atmel (now Microchip Technology), widely used in embedded systems. The GNU toolchain supports AVR targets.
error propagation
The process of passing an error status from a lower-level function or module to a higher-level one, allowing the program to handle the error appropriately.
Filed Under: linkerrelaxationavrerror handling