binutils Newspaper
OCTOBER 6, 2026
avr/ld — Proposed

AVR: Elide global RJMP .+0 with -mrelax

Patch allows the AVR linker, with -mrelax, to elide RJMP instructions with a zero offset targeting global symbols.

Georg-Johann Lay proposes a patch to extend the AVR linker’s relaxation capabilities to elide zero-offset RJMP instructions that target global symbols. This optimization is intended for cases where a function tail-calls another function located immediately after it. The new feature can be disabled using the --no-elide-rjmp0 linker option.

In the Thread 1 participant
  1. Georg-Johann Lay proposer

    Submits a patch to allow the AVR linker to elide specific RJMP instructions when relaxation is enabled.

    “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.”

In Details

This patch modifies the AVR backend of the GNU linker (ld) to introduce a new relaxation optimization. When the -mrelax option is used, the linker will now elide RJMP .+0 instructions if they target a global symbol. This is specifically for cases like tail calls where the called function immediately follows the caller, and the RJMP is effectively a no-op. A new option, --no-elide-rjmp0, is added to disable this behavior.

For Context
AVR
A family of microcontrollers developed by Atmel (now Microchip Technology).
ld
The GNU linker, responsible for combining object files and libraries into an executable or another object file.
Relaxation
A linker optimization process where instructions with relative offsets are adjusted after the initial linking phase to accommodate final code placement, potentially allowing for shorter or more efficient instruction forms.
RJMP
Relative Jump, an instruction on AVR microcontrollers that jumps to a target address relative to the current program counter.
Elide
To omit or suppress; in this context, to remove an instruction that has no functional effect.
Global symbol
A symbol (like a function or variable name) that is visible and accessible across different object files or modules.
Tail call
A function call that is the very last operation in a function before it returns. Tail call optimization can replace the call with a jump, avoiding stack growth.
Filed Under: avrldlinkeroptimizationrelaxation