binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
binutils

RISC-V assembler supports '.option [no]exact' directives

RISC-V assembler now supports '.option exact' and '.option noexact' directives to control linker relaxation and instruction aliasing.

The RISC-V assembler in binutils now supports the ‘.option exact’ and ‘.option noexact’ directives, aligning with LLVM’s implementation. These directives control linker relaxations, disable instruction aliases that change encoding, and prevent relaxation of branch instructions. While interactions with ‘.option relax/norelax’ are supported to mimic LLVM, using both sets of options concurrently is discouraged.

In Details

This commit introduces support for '.option exact' and '.option noexact' in the RISC-V assembler, analogous to LLVM's implementation. The 'exact' mode disables linker relaxations (controlled by '.option relax'), prevents instruction aliases that alter encoding (e.g., 'addi' to 'c.addi'), and disables branch instruction relaxation. The interaction with existing '.option relax' directives is designed for LLVM compatibility, where '.option exact' implies '.option norelax' and vice-versa, though using both is not recommended.

For Context
RISC-V
An open-standard instruction set architecture (ISA) based on reduced instruction set computer (RISC) principles. It is designed to be simple, modular, and extensible.
assembler directives
Instructions to the assembler, not translated into machine code. They control aspects like symbol definition, section selection, and macro expansion. Examples include '.global', '.section', and in this case, '.option'.
linker relaxation
A process where the linker adjusts relative addresses and branch offsets after the initial assembly. This is often done to optimize code size by using shorter instruction encodings where possible. '.option relax' enables this, while '.option norelax' disables it.
instruction aliasing
A situation where a mnemonic can represent multiple underlying machine instructions, often differing in encoding or performance. For example, 'addi' might alias to 'c.addi' on RISC-V for compressed instruction sets.
GAS
The GNU Assembler, part of the GNU Binutils package. It translates assembly language code into machine code.
Filed Under: risc-vassembleroptimization