AVR: Prune vector table with --prune-vectab
Adds a new ld option --prune-vectab for AVR targets to remove unused vector table entries and simplify relaxation.
This patch introduces the —prune-vectab option for the AVR target in GNU ld. This new option prunes the vector table by removing unused entries that point to __bad_interrupt, simplifying subsequent relaxation steps. It also allows the removal of trailing NOPs in RJMP+NOP sequences within the vector table. The changes have been tested and pass the avr-gcc testsuite.
In Details
This patch introduces a linker option, --prune-vectab, for the AVR architecture. It targets the vector table, which often contains many unused entries pointing to __bad_interrupt. The option prunes these entries before the standard relaxation pass, which typically converts JMP to RJMP+NOP. This pre-pruning simplifies the relaxation process. Additionally, it allows the removal of the final NOP in a sequence of RJMP+NOP entries. Tests were conducted on ATmega128 and ATmega8, comparing behavior with and without -mrelax --prune-vectab.
- AVR
- A family of microcontrollers manufactured by Atmel (now Microchip Technology). Common in embedded systems.
- vector table
- A table in memory that contains the addresses of interrupt service routines. When an interrupt occurs, the processor uses this table to find the appropriate handler.
- __bad_interrupt
- A placeholder or default interrupt handler function that is typically called when an unassigned interrupt vector is triggered.
- relaxation
- A linker optimization process that adjusts instruction addresses and sizes to use shorter, more efficient opcodes where possible, often converting longer jumps to shorter ones.
- RJMP
- A relative jump instruction in AVR assembly language. It has a shorter encoding than a traditional absolute jump.
- NOP
- No Operation; an instruction that does nothing but consume clock cycles. Often used as padding or to align code.
- CLH
- Possibly 'Clear Halt' or a similar low-level instruction, mentioned in the context of AVR-SD and AVR-LibC.
- AVR-SD
- Likely refers to a specific AVR development toolchain or configuration, possibly related to debug or simulation.
- AVR-LibC
- A standard C library implementation for the AVR microcontroller family.