binutils Newspaper
JULY 29, 2026
risc-v/gas Ready to Land

RISC-V/gas: warn about non-power-of-2 stack-align attribute

Warn about non-power-of-2 values for the RISC-V stack_align attribute in the assembler.

This patch adds a warning to the RISC-V GNU Assembler (gas) when the .attribute stack_align directive is used with a non-power-of-2 value. This ensures that developers are informed about potentially invalid alignment settings, which could lead to incorrect behavior or performance issues.

In the Thread 2 participants
  1. Jan Beulich <jbeulich@suse.com> proposer

    Introduces a warning in gas for non-power-of-2 values of the stack_align attribute.

    “Only power-of-2 values are sensible for alignment.”
  2. Jiawei <jiawei@iscas.ac.cn> reviewer

    Reviewed the patch, asking whether existing non-zero values should be rejected and if 0 should be permitted as an 'attribute not set' indicator.

Technical Tradeoffs

  • Adds a runtime check (warning) in the assembler for a specific attribute.
  • Does not reject non-power-of-2 values outright, allowing for later BFD handling or user ignorance.

In Details

This patch modifies the RISC-V assembler's attribute handling to check the Tag_RISCV_stack_align attribute. It issues a warning if the provided value is not a power of two, which is a fundamental requirement for alignment values to be correctly interpreted by the processor and system. This improves the robustness of code generation for RISC-V targets.

For Context
RISC-V
An open-source instruction set architecture (ISA) that is gaining popularity for its modularity and extensibility.
gas
The GNU Assembler, part of the GNU Binutils package.
.attribute
An assembler directive used to specify object file attributes, such as target architecture or features.
Tag_RISCV_stack_align
An ELF tag specific to RISC-V that specifies the required stack alignment.
Filed Under: binutilsrisc-vgasattributewarning