binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
bfd

AVR: Prune unused vectab entries.

New linker option `--prune-vectab` removes unused entries from AVR vector tables during relaxation.

This patch introduces the --prune-vectab linker option for AVR targets, which removes unused entries from the interrupt vector table. It operates during the relaxation phase, cleaning up tail-end entries that typically point to __bad_interrupt. This feature helps optimize code size and resolves an issue with AVR-LibC’s vector table structure (PR ld/34679).

In Details

Introduces a new linker relaxation pass, avr_maybe_prune_vectab, in elf32-avr.c to conditionally remove trailing unused entries from the AVR interrupt vector table (.vectors). This pass specifically targets sequences of NOPs or RJMP+NOP that result from unused entries, addressing PR ld/34679. It also handles the case where AVR-LibC appends a CLH instruction. The functionality is controlled by the new -Wl,--prune-vectab linker option.

For Context
AVR
A family of microcontrollers developed by Atmel (now Microchip Technology). They are popular for hobbyist projects and embedded systems.
vector table
A table in memory that stores the starting addresses of interrupt service routines. When an interrupt occurs, the processor uses the interrupt number as an index into this table to find the correct handler.
relaxation
A linker optimization phase that adjusts addresses and instruction encodings based on final layout information. This can involve changing short jumps to longer ones, or vice versa, to optimize code size or fix up addresses.
RJMP
Relative Jump, an instruction on AVR microcontrollers that jumps to a target address relative to the current program counter. It typically has a shorter encoding than an absolute jump.
NOP
No Operation, an instruction that does nothing. It is often used for padding or alignment.
CLH
Clear Handled flag, an instruction related to interrupt handling on some AVR microcontrollers.
AVR-LibC
A C standard library specifically tailored for AVR microcontrollers.
Filed Under: avrlinkeroptimizationembedded