RISC-V/gas: warn about non-boolean unaligned-access attribute
Warn about non-boolean values for the RISC-V unaligned-access attribute in the assembler.
This patch introduces a warning in the RISC-V GNU Assembler (gas) when the .attribute unaligned_access directive is used with a value other than 0 or 1. This helps catch potential errors where developers might incorrectly specify this boolean attribute, ensuring better adherence to the RISC-V specification.
- proposer
Adds a warning to gas for non-boolean values of the unaligned_access attribute.
“The attribute being a boolean one, values should be solely 0 or 1.”
- reviewer
Asked if attributes should accumulate rather than being set individually, similar to BFD's behavior.
Technical Tradeoffs
- Introduces a warning for non-compliant attribute values.
- Does not actively merge or normalize values within gas, relying on BFD for that logic.
In Details
This change enhances the RISC-V assembler's handling of the Tag_RISCV_unaligned_access attribute. It warns if the value provided via the .attribute directive is not strictly 0 or 1, ensuring that this boolean flag is correctly interpreted. This is important for security and correctness, as unaligned access behavior can have performance and security implications.
- 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_unaligned_access
- An ELF tag specific to RISC-V that indicates whether unaligned memory access is permitted.