Skip to content

Commit 02b2818

Browse files
committed
Fix typos for CALL, CALL_PLT and GOT_HI20
`CALL` and `CALL_PLT` relocations refer `auipc` and `jalr` instruction pairs. `jalr` is not a J-type instruction; it's I-type. As to `GOT_HI20`, `G` means the offset inside the .got in the other ELF specs. So the correct expression is not `G+A-P` but `G+GOT+A-P` where `GOT` means the address of the .got. I found these errata when I was trying to implement a RISC-V support to my linker. rui314/mold@e76f7c0
1 parent 2824f7f commit 02b2818

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

riscv-elf.adoc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ Description:: Additional information about the relocation
299299
<| S + A - P
300300
.2+| 17 .2+| JAL .2+| Static | _J-Type_ .2+| 20-bit PC-relative jump offset
301301
<| S + A - P
302-
.2+| 18 .2+| CALL .2+| Static | _U+J-Type_ .2+| 32-bit PC-relative function call, macros `call`, `tail`
302+
.2+| 18 .2+| CALL .2+| Static | _U+I-Type_ .2+| 32-bit PC-relative function call, macros `call`, `tail`
303303
<| S + A - P
304-
.2+| 19 .2+| CALL_PLT .2+| Static | _U+J-Type_ .2+| 32-bit PC-relative function call, macros `call`, `tail` (PIC)
304+
.2+| 19 .2+| CALL_PLT .2+| Static | _U+I-Type_ .2+| 32-bit PC-relative function call, macros `call`, `tail` (PIC)
305305
<| S + A - P
306306
.2+| 20 .2+| GOT_HI20 .2+| Static | _U-Type_ .2+| High 20 bits of 32-bit PC-relative GOT access, `%got_pcrel_hi(symbol)`
307-
<| G + A - P
307+
<| G + GOT + A - P
308308
.2+| 21 .2+| TLS_GOT_HI20 .2+| Static | _U-Type_ .2+| High 20 bits of 32-bit PC-relative TLS IE GOT access, macro `la.tls.ie`
309309
<|
310310
.2+| 22 .2+| TLS_GD_HI20 .2+| Static | _U-Type_ .2+| High 20 bits of 32-bit PC-relative TLS GD GOT reference, macro `la.tls.gd`
@@ -402,6 +402,7 @@ calculation:
402402
| A | Addend field in the relocation entry associated with the symbol
403403
| B | Base address of a shared object loaded into memory
404404
| G | Offset of the symbol into the GOT (Global Offset Table)
405+
| GOT | Address of the GOT (Global Offset Table)
405406
| P | Position of the relocation
406407
| S | Value of the symbol in the symbol table
407408
| V | Value at the position of the relocation
@@ -437,7 +438,7 @@ of the `__global_pointer$` symbol into register `gp` (aka `x3`).
437438
| _S-Type_ | Specifies a field as the immediate field in an S-type instruction
438439
| _U-Type_ | Specifies a field as the immediate field in an U-type instruction
439440
| _J-Type_ | Specifies a field as the immediate field in a J-type instruction
440-
| _U+J-Type_ | Specifies a field as the immediate fields in a U-type and J-type instruction pair
441+
| _U+I-Type_ | Specifies a field as the immediate fields in a U-type and I-type instruction pair
441442
|===
442443

443444
==== Constants
@@ -576,7 +577,7 @@ and when symbol has an `@plt` suffix it expands to:
576577

577578
==== PC-Relative Jumps and Branches
578579

579-
Unconditional jump (U+J-Type) instructions have a `R_RISCV_JAL` relocation
580+
Unconditional jump (J-Type) instructions have a `R_RISCV_JAL` relocation
580581
that can represent an even signed 21-bit offset (-1MiB to +1MiB-2).
581582

582583
Branch (SB-Type) instructions have a `R_RISCV_BRANCH` relocation that

0 commit comments

Comments
 (0)