Skip to content

Commit a9945e1

Browse files
authored
Merge pull request #68 from kito-cheng/doc-option
Add more description for .option directive
2 parents 44cd201 + 3462df7 commit a9945e1

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

riscv-asm.md

Lines changed: 33 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,35 @@ 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+
NOTE: Recommended way to disable linker relaxation of specific code region is
209+
use `.option push`, `.option norelax` and `.option pop`, that prevent enabled
210+
linker relaxation accidentally if user already disable linker relaxation.
211+
212+
#### `push`/`pop`
213+
214+
Push/pop current options to/from the options stack.
215+
187216
## Assembler Relocation Functions
188217

189218
The following table lists assembler relocation expansions:
@@ -565,12 +594,12 @@ fail_msg:
565594
.string "FAIL\n"
566595
```
567596

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

570599
Pseudoinstruction | Base Instruction(s) | Meaning | Comment
571600
:----------------------------|:--------------------------------------------------------------|:----------|:--------|
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
601+
la rd, symbol | auipc rd, symbol[31:12]; addi rd, rd, symbol[11:0] | Load address | With `.option nopic` (Default)
602+
la rd, symbol | auipc rd, symbol@GOT[31:12]; l{w\|d} rd, symbol@GOT[11:0]\(rd\) | Load address | With `.option pic`
574603
lla rd, symbol | auipc rd, symbol[31:12]; addi rd, rd, symbol[11:0] | Load local address
575604
lga rd, symbol | auipc rd, symbol@GOT[31:12]; l{w\|d} rd, symbol@GOT[11:0]\(rd\) | Load global address
576605
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)