binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gas Performance Win

Fix instruction stack overflow for Xtensa loopgtz widening

Increases MAX_ISTACK and improves error reporting for Xtensa loopgtz instruction relaxation.

This commit addresses an instruction stack overflow issue in the Xtensa assembler when relaxing loopgtz instructions using L32R widening. The MAX_ISTACK limit has been increased from 12 to 16, and the error reporting mechanism is improved to use as_fatal which explicitly mentions MAX_ISTACK. A new test case loopgtz-relax.s is added to verify the fix.

In Details

The Xtensa assembler uses an instruction stack (istack) to manage instruction sequences during relaxation. Commit 403b0b61f6d4 replaced loop widening with L32R-based sequences. The loopgtz variant of this new sequence requires 13 istack entries, but MAX_ISTACK was only 12, causing overflows. This patch increases MAX_ISTACK to 16 and modifies istack_push and istack_push_space to use as_fatal for stack overflow errors, providing better diagnostics. A new test suite case is added.

For Context
Xtensa
A configurable processor architecture for embedded systems.
gas
The GNU Assembler, part of the GNU Binutils project.
loopgtz
A loop instruction that continues as long as a value is greater than zero.
L32R widening
A technique used in some architectures to expand short immediate values into longer ones, often involving a load instruction.
instruction stack (istack)
A data structure within the assembler used to keep track of instructions during code generation and relaxation.
relaxation
A process where the assembler adjusts instruction offsets and sizes after an initial pass to accommodate changes introduced by PC-relative addressing or other position-dependent code.
as_fatal
An assembler function to report a fatal error and terminate the assembly process.
Filed Under: gasxtensaoptimizationbugfix