Skip to content

Commit 13d877c

Browse files
authored
Merge pull request #240 from riscv-non-isa/simplify-lo12-calculation
riscv-elf: Use simpler equivalent expression for LO12 relocations
2 parents 2824f7f + b43debd commit 13d877c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

riscv-elf.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ is followed by an I-Type instruction (add immediate or load) with an
468468
calculated like this:
469469

470470
[horizontal]
471-
HI20:: `((symbol_address + 0x800) >> 12)`
472-
LO12:: `symbol_address - (hi20 << 12)`
471+
HI20:: `(symbol_address + 0x800) >> 12`
472+
LO12:: `symbol_address`
473473

474474
The following assembly and relocations show loading an absolute address:
475475

@@ -610,8 +610,8 @@ immediate on the add, load or store instruction the linker finds the
610610
instruction. The addresses for pair of relocations are calculated like this:
611611

612612
[horizontal]
613-
HI20:: `((symbol_address - hi20_reloc_offset + 0x800) >> 12)`
614-
LO12:: `symbol_address - hi20_reloc_offset - (hi20 << 12)`
613+
HI20:: `(symbol_address - hi20_reloc_offset + 0x800) >> 12`
614+
LO12:: `symbol_address - hi20_reloc_offset`
615615

616616
The successive instruction has a signed 12-bit immediate so the value of the
617617
preceding high 20-bit relocation may have 1 added to it.

0 commit comments

Comments
 (0)