Skip to content

Commit 36d28e3

Browse files
committed
Add more description for .option directive
1 parent 44cd201 commit 36d28e3

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

riscv-asm.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Directive | Arguments | Description
164164
.macro | name arg1 [, argn] | begin macro definition \argname to substitute
165165
.endm | | end macro definition
166166
.type | symbol, @function | accepted for source compatibility
167-
.option | {rvc,norvc,pic,nopic,push,pop} | RISC-V options
167+
.option | {rvc,norvc,pic,nopic,relax,norelax,push,pop} | RISC-V options. Refer to [.option](#.option) for a more detailed description.
168168
.byte | expression [, expression]* | 8-bit comma separated words
169169
.2byte | expression [, expression]* | 16-bit comma separated words
170170
.half | expression [, expression]* | 16-bit comma separated words
@@ -184,6 +184,31 @@ Directive | Arguments | Description
184184
.zero | integer | zero bytes
185185
.variant_cc | symbol_name | annotate the symbol with variant calling convention
186186

187+
### <a name=.option></a> `.option`
188+
189+
#### `rvc`/`norvc`
190+
191+
Enable/disable the C-extension for the following code region.
192+
193+
#### `pic`/`nopic`
194+
195+
Set the code model to PIC (position independent code) or non-PIC. This will
196+
affect the expansion of the `la` pseudoinstruction, refer to
197+
[listing of standard RISC-V pseudoinstructions](#pseudoinstructions).
198+
199+
#### `relax`/`norelax`
200+
201+
Enable/disable linker relaxation for the following code region.
202+
203+
NOTE: Code region follows by `.option relax` will emit
204+
`R_RISCV_RELAX`/`R_RISCV_ALIGN` even linker unsupport relaxation, suggested
205+
usage is using `.option norelax` with `.option push`/`.option pop` if
206+
you want to disable linker relaxation on specific code region.
207+
208+
#### `push`/`pop`
209+
210+
Push/pop current options to/from the options stack.
211+
187212
## Assembler Relocation Functions
188213

189214
The following table lists assembler relocation expansions:
@@ -565,12 +590,12 @@ fail_msg:
565590
.string "FAIL\n"
566591
```
567592

568-
## A listing of standard RISC-V pseudoinstructions
593+
## <a name=pseudoinstructions></a> A listing of standard RISC-V pseudoinstructions
569594

570595
Pseudoinstruction | Base Instruction(s) | Meaning | Comment
571596
:----------------------------|:--------------------------------------------------------------|:----------|:--------|
572-
la rd, symbol | auipc rd, symbol[31:12]; addi rd, rd, symbol[11:0] | Load address | Without -fPIC
573-
la rd, symbol | auipc rd, symbol@GOT[31:12]; l{w\|d} rd, symbol@GOT[11:0]\(rd\) | Load address | With -fPIC
597+
la rd, symbol | auipc rd, symbol[31:12]; addi rd, rd, symbol[11:0] | Load address | With `.option nopic` (Default)
598+
la rd, symbol | auipc rd, symbol@GOT[31:12]; l{w\|d} rd, symbol@GOT[11:0]\(rd\) | Load address | With `.option pic`
574599
lla rd, symbol | auipc rd, symbol[31:12]; addi rd, rd, symbol[11:0] | Load local address
575600
lga rd, symbol | auipc rd, symbol@GOT[31:12]; l{w\|d} rd, symbol@GOT[11:0]\(rd\) | Load global address
576601
l{b\|h\|w\|d} rd, symbol | auipc rd, symbol[31:12]; l{b\|h\|w\|d} rd, symbol[11:0]\(rd\) | Load global

0 commit comments

Comments
 (0)