binutils Newspaper
OCTOBER 6, 2026
avr — Proposed

AVR: Let -mrelax elide global RJMP .+0

Allow the AVR linker's relaxation to elide RJMP instructions targeting global symbols.

This patch extends the AVR linker’s relaxation capabilities to elide RJMP instructions that jump to a global symbol with a zero offset. This optimization is useful in scenarios like tail-calling functions where the called function immediately follows the caller. A new option, —no-elide-rjmp0, is introduced to disable this feature. The patch has been tested and approved.

In the Thread 1 participant
  1. Georg-Johann Lay <avr@gjlay.de> proposer

    Extends AVR linker relaxation to elide RJMP instructions with zero offset targeting global symbols. Passes test suite.

    “This patch extends the avr-specific linker relaxation machine to elide trivial RJMP instructions. These are RJMP instructions with a jump offset of 0 that are targeting a global symbol. The use case is when a function is tail-calling some other function, and the latter happens to be located right after the former, like in: rjmp func ;; from module A .global func ;; from module B…”

In Details

This patch targets the AVR architecture's linker relaxation pass within binutils. Specifically, it allows the linker to optimize away redundant RJMP instructions (relative jumps) when they target a global symbol and the jump offset is zero. This is a micro-optimization for specific code generation patterns.

Filed Under: avrlinkeroptimizationrelaxation