[PATCH v2 18/16] RISC-V: warn about non-power-of-2 stack-align attribute
Jan Beulich
jbeulich@suse.com
Fri Jun 5 09:29:30 GMT 2026
Only power-of-2 values are sensible for alignment.
---
Should libbfd's riscv_merge_attributes() also emit a warning?
Should we reject changing an already set non-zero value, like
riscv_merge_attributes() does?
Should we permit 0 as an explicit indication of "attribute not set"?
---
v2: New.
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -5891,6 +5891,13 @@ s_riscv_attribute (int ignored ATTRIBUTE
"any instructions"));
break;
+ case Tag_RISCV_stack_align:
+ if (!attr[Tag_RISCV_stack_align].i
+ || (attr[Tag_RISCV_stack_align].i &
+ (attr[Tag_RISCV_stack_align].i - 1)))
+ as_warn (_("`stack_align' attribute with non-power-of-2 value"));
+ break;
+
case Tag_RISCV_unaligned_access:
if (attr[Tag_RISCV_unaligned_access].i > 1)
as_warn (_("`unaligned_access' attribute with non-boolean value"));
--- a/gas/testsuite/gas/riscv/attribute-warn.d
+++ b/gas/testsuite/gas/riscv/attribute-warn.d
@@ -4,4 +4,5 @@
Attribute Section: riscv
File Attributes
+ Tag_RISCV_stack_align: 65536-bytes
Tag_RISCV_arch: [a-zA-Z0-9_\"].*
--- a/gas/testsuite/gas/riscv/attribute-warn.l
+++ b/gas/testsuite/gas/riscv/attribute-warn.l
@@ -1,2 +1,4 @@
.*: Assembler messages:
.*:2: Warning: `unaligned_access' attribute with non-boolean value
+.*:5: Warning: `stack_align' attribute with non-power-of-2 value
+.*:6: Warning: `stack_align' attribute with non-power-of-2 value
--- a/gas/testsuite/gas/riscv/attribute-warn.s
+++ b/gas/testsuite/gas/riscv/attribute-warn.s
@@ -1,3 +1,7 @@
.attribute unaligned_access, 1
.attribute unaligned_access, 0x1234
.attribute unaligned_access, 0
+
+ .attribute stack_align, 0
+ .attribute stack_align, 0x4444
+ .attribute stack_align, 0x10000
More information about the Binutils
mailing list