@@ -325,16 +325,7 @@ assembled as PIC:
325325
326326For non-PIC this is an alias for the ` lla ` pseudo instruction documented below.
327327
328- For PIC this generates the following instructions and relocations as seen by
329- ` objdump ` (for RV64; RV32 will use ` lw ` instead of ` ld ` ):
330-
331- ``` assembly
332- 0000000000000000 <.text>:
333- 0: 00000517 auipc a0,0x0
334- 0: R_RISCV_GOT_HI20 msg+0x1
335- 4: 00053503 ld a0,0(a0) # 0 <.text>
336- 4: R_RISCV_PCREL_LO12_I .L0
337- ```
328+ For PIC this is an alias for the ` lga ` pseudo instruction documented below.
338329
339330The ` la ` pseudo instruction is the preferred way for getting the address of
340331variables in assembly unless explicit control over PC-relative or GOT-indirect
@@ -360,6 +351,27 @@ This generates the following instructions and relocations as seen by `objdump`:
360351 4: R_RISCV_PCREL_LO12_I .L0
361352```
362353
354+ Load Global Address
355+ ------------------
356+
357+ The following example shows the ` lga ` pseudo instruction which is used to load
358+ global symbol addresses:
359+
360+ ``` assembly
361+ lga a0, msg + 1
362+ ```
363+
364+ This generates the following instructions and relocations as seen by ` objdump `
365+ (for RV64; RV32 will use ` lw ` instead of ` ld ` ):
366+
367+ ``` assembly
368+ 0000000000000000 <.text>:
369+ 0: 00000517 auipc a0,0x0
370+ 0: R_RISCV_GOT_HI20 msg+0x1
371+ 4: 00053503 ld a0,0(a0) # 0 <.text>
372+ 4: R_RISCV_PCREL_LO12_I .L0
373+ ```
374+
363375Load and Store Global
364376---------------------
365377
@@ -559,6 +571,7 @@ Pseudoinstruction | Base Instruction(s)
559571la rd, symbol | auipc rd, symbol[ 31:12] ; addi rd, rd, symbol[ 11:0] | Load address | Without -fPIC
560572la rd, symbol | auipc rd, symbol@GOT[ 31:12] ; l{w\| d} rd, symbol@GOT[ 11:0] \( rd\) | Load address | With -fPIC
561573lla rd, symbol | auipc rd, symbol[ 31:12] ; addi rd, rd, symbol[ 11:0] | Load local address
574+ lga rd, symbol | auipc rd, symbol@GOT[ 31:12] ; l{w\| d} rd, symbol@GOT[ 11:0] \( rd\) | Load global address
562575l{b\| h\| w\| d} rd, symbol | auipc rd, symbol[ 31:12] ; l{b\| h\| w\| d} rd, symbol[ 11:0] \( rd\) | Load global
563576s{b\| h\| w\| d} rd, symbol, rt | auipc rt, symbol[ 31:12] ; s{b\| h\| w\| d} rd, symbol[ 11:0] \( rt\) | Store global
564577fl{w\| d} rd, symbol, rt | auipc rt, symbol[ 31:12] ; fl{w\| d} rd, symbol[ 11:0] \( rt\) | Floating-point load global
0 commit comments