Skip to content

Commit d188bd1

Browse files
author
Evandro Menezes
committed
riscv-elf.md: add TLS relocations
Add the TLS relocations for the compact code model.
1 parent dfa72d5 commit d188bd1

File tree

1 file changed

+77
-71
lines changed

1 file changed

+77
-71
lines changed

riscv-elf.md

Lines changed: 77 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -509,77 +509,83 @@ Global Offset Table or DWARF meta data.
509509
The following table provides details of the RISC-V ELF relocations (instruction
510510
specific relocations show the instruction type in the Details column):
511511

512-
Enum | ELF Reloc Type | Description | Field | Calculation | Details
513-
:--- | :------------- | :---------- | :---- | :---------- | :------
514-
0 | R_RISCV_NONE | None |
515-
1 | R_RISCV_32 | Runtime relocation | _word32_ | S + A
516-
2 | R_RISCV_64 | Runtime relocation | _word64_ | S + A
517-
3 | R_RISCV_RELATIVE | Runtime relocation | _wordclass_ | B + A
518-
4 | R_RISCV_COPY | Runtime relocation | | | Must be in executable. not allowed in shared library
519-
5 | R_RISCV_JUMP_SLOT | Runtime relocation | _wordclass_ | S | Handled by PLT unless `LD_BIND_NOW`
520-
6 | R_RISCV_TLS_DTPMOD32 | TLS relocation | _word32_ | S->TLSINDEX
521-
7 | R_RISCV_TLS_DTPMOD64 | TLS relocation | _word64_ | S->TLSINDEX
522-
8 | R_RISCV_TLS_DTPREL32 | TLS relocation | _word32_ | S + A + TLS - TLS_TP_OFFSET
523-
9 | R_RISCV_TLS_DTPREL64 | TLS relocation | _word64_ | S + A + TLS - TLS_TP_OFFSET
524-
10 | R_RISCV_TLS_TPREL32 | TLS relocation | _word32_ | S + A + TLS + S_TLS_OFFSET - TLS_DTV_OFFSET
525-
11 | R_RISCV_TLS_TPREL64 | TLS relocation | _word64_ | S + A + TLS + S_TLS_OFFSET - TLS_DTV_OFFSET
526-
16 | R_RISCV_BRANCH | PC-relative branch | _B-Type_ | S + A - P
527-
17 | R_RISCV_JAL | PC-relative jump | _J-Type_ | S + A - P
528-
18 | R_RISCV_CALL | PC-relative call | _J-Type_ | S + A - P | Macros `call`, `tail`
529-
19 | R_RISCV_CALL_PLT | PC-relative call (PLT) | _J-Type_ | S + A - P | Macros `call`, `tail` (PIC)
530-
20 | R_RISCV_GOT_HI20 | PC-relative GOT reference | _U-Type_ | G + A | `%got_pcrel_hi(symbol)`
531-
21 | R_RISCV_TLS_GOT_HI20 | PC-relative TLS IE GOT offset | _U-Type_ | | Macro `la.tls.ie`
532-
22 | R_RISCV_TLS_GD_HI20 | PC-relative TLS GD reference | _U-Type_ | | Macro `la.tls.gd`
533-
23 | R_RISCV_PCREL_HI20 | PC-relative reference | _U-Type_ | S + A - P | `%pcrel_hi(symbol)`
534-
24 | R_RISCV_PCREL_LO12_I | PC-relative reference | _I-type_ | S + A - P | `%pcrel_lo(address of %pcrel_hi)`
535-
25 | R_RISCV_PCREL_LO12_S | PC-relative reference | _S-Type_ | S + A - P | `%pcrel_lo(address of %pcrel_hi)`
536-
26 | R_RISCV_HI20 | Absolute address | _U-Type_ | S + A | `%hi(symbol)`
537-
27 | R_RISCV_LO12_I | Absolute address | _I-Type_ | S + A | `%lo(symbol)`
538-
28 | R_RISCV_LO12_S | Absolute address | _S-Type_ | S + A | `%lo(symbol)`
539-
29 | R_RISCV_TPREL_HI20 | TLS LE thread offset | _U-Type_ | | `%tprel_hi(symbol)`
540-
30 | R_RISCV_TPREL_LO12_I | TLS LE thread offset | _I-Type_ | | `%tprel_lo(symbol)`
541-
31 | R_RISCV_TPREL_LO12_S | TLS LE thread offset | _S-Type_ | | `%tprel_lo(symbol)`
542-
32 | R_RISCV_TPREL_ADD | TLS LE thread usage | | | `%tprel_add(symbol)`
543-
33 | R_RISCV_ADD8 | 8-bit label addition | _word8_ | V + S + A
544-
34 | R_RISCV_ADD16 | 16-bit label addition | _word16_ | V + S + A
545-
35 | R_RISCV_ADD32 | 32-bit label addition | _word32_ | V + S + A
546-
36 | R_RISCV_ADD64 | 64-bit label addition | _word64_ | V + S + A
547-
37 | R_RISCV_SUB8 | 8-bit label subtraction | _word8_ | V - S - A
548-
38 | R_RISCV_SUB16 | 16-bit label subtraction | _word16_ | V - S - A
549-
39 | R_RISCV_SUB32 | 32-bit label subtraction | _word32_ | V - S - A
550-
40 | R_RISCV_SUB64 | 64-bit label subtraction | _word64_ | V - S - A
551-
41 | R_RISCV_GNU_VTINHERIT | GNU C++ vtable hierarchy |
552-
42 | R_RISCV_GNU_VTENTRY | GNU C++ vtable member usage |
553-
43 | R_RISCV_ALIGN | Alignment statement |
554-
44 | R_RISCV_RVC_BRANCH | PC-relative branch offset | _CB-Type_ | S + A - P
555-
45 | R_RISCV_RVC_JUMP | PC-relative jump offset | _CJ-Type_ | S + A - P
556-
46 | R_RISCV_RVC_LUI | Absolute address | _CI-Type_ | S + A
557-
47 | R_RISCV_GPREL_I | GP-relative reference | _I-Type_ | S + A - GP
558-
48 | R_RISCV_GPREL_S | GP-relative reference | _S-Type_ | S + A - GP
559-
49 | R_RISCV_TPREL_I | TP-relative TLS LE load | _I-Type_
560-
50 | R_RISCV_TPREL_S | TP-relative TLS LE store | _S-Type_
561-
51 | R_RISCV_RELAX | Instruction pair can be relaxed |
562-
52 | R_RISCV_SUB6 | Local label subtraction | _word6_ | V - S - A
563-
53 | R_RISCV_SET6 | Local label assignment | _word6_ | S + A
564-
54 | R_RISCV_SET8 | Local label assignment | _word8_ | S + A
565-
55 | R_RISCV_SET16 | Local label assignment | _word16_ | S + A
566-
56 | R_RISCV_SET32 | Local label assignment | _word32_ | S + A
567-
57 | R_RISCV_32_PCREL | PC-relative reference | _word32_ | S + A - P
568-
58 | R_RISCV_IRELATIVE | Runtime relocation | _wordclass_ | `ifunc_resolver(B + A)`
569-
59 | R_RISCV_64_PCREL | PC-relative reference | _word64_ | S + A - P
570-
60 | R_RISCV_GPREL_HI20 | GP-relative reference | _U-type_ | S + A - GP | `%gprel_hi(symbol)`
571-
61 | R_RISCV_GPREL_LO12_I | GP-relative reference | _I-type_ | S + A - GP | `%gprel_lo(symbol)`
572-
62 | R_RISCV_GPREL_LO12_S | GP-relative reference | _S-type_ | S + A - GP | `%gprel_lo(symbol)`
573-
63 | R_RISCV_GPREL_ADD | GP-relative usage | | | `%gprel(symbol)`
574-
64 | R_RISCV_GPREL_LOAD | GP-relative usage | | | `%gprel(symbol)`
575-
65 | R_RISCV_GPREL_STORE | GP-relative usage | | | `%gprel(symbol)`
576-
66 | R_RISCV_GOT_GPREL_HI20 | GP-relative GOT reference | _U-type_ | G + A - GP | `%got_gprel_hi(symbol)`
577-
67 | R_RISCV_GOT_GPREL_LO12_I | GP-relative GOT reference | _I-type_ | G + A - GP | `%got_gprel_lo(symbol)`
578-
68 | R_RISCV_GOT_GPREL_ADD | GP-relative GOT usage | | | `%got_gprel(symbol)`
579-
69 | R_RISCV_GOT_GPREL_LOAD | GP-relative GOT usage | | | `%got_gprel(symbol)`
580-
70 | R_RISCV_GOT_GPREL_STORE | GP-relative GOT usage | | | `%got_gprel(symbol)`
581-
71-191 | *Reserved* | Reserved for future standard use |
582-
192-255 | *Reserved* | Reserved for nonstandard ABI extensions |
512+
Enum | ELF Reloc Type | Description | Field | Calculation | Details
513+
:--- | :------------- | :---------- | :---- | :---------- | :------
514+
0 | R_RISCV_NONE | None |
515+
1 | R_RISCV_32 | Runtime relocation | _word32_ | S + A
516+
2 | R_RISCV_64 | Runtime relocation | _word64_ | S + A
517+
3 | R_RISCV_RELATIVE | Runtime relocation | _wordclass_ | B + A
518+
4 | R_RISCV_COPY | Runtime relocation | | | Must be in executable. not allowed in shared library
519+
5 | R_RISCV_JUMP_SLOT | Runtime relocation | _wordclass_ | S | Handled by PLT unless `LD_BIND_NOW`
520+
6 | R_RISCV_TLS_DTPMOD32 | TLS relocation | _word32_ | S->TLSINDEX
521+
7 | R_RISCV_TLS_DTPMOD64 | TLS relocation | _word64_ | S->TLSINDEX
522+
8 | R_RISCV_TLS_DTPREL32 | TLS relocation | _word32_ | S + A + TLS - TLS_TP_OFFSET
523+
9 | R_RISCV_TLS_DTPREL64 | TLS relocation | _word64_ | S + A + TLS - TLS_TP_OFFSET
524+
10 | R_RISCV_TLS_TPREL32 | TLS relocation | _word32_ | S + A + TLS + S_TLS_OFFSET - TLS_DTV_OFFSET
525+
11 | R_RISCV_TLS_TPREL64 | TLS relocation | _word64_ | S + A + TLS + S_TLS_OFFSET - TLS_DTV_OFFSET
526+
16 | R_RISCV_BRANCH | PC-relative branch | _B-Type_ | S + A - P
527+
17 | R_RISCV_JAL | PC-relative jump | _J-Type_ | S + A - P
528+
18 | R_RISCV_CALL | PC-relative call | _J-Type_ | S + A - P | Macros `call`, `tail`
529+
19 | R_RISCV_CALL_PLT | PC-relative call (PLT) | _J-Type_ | S + A - P | Macros `call`, `tail` (PIC)
530+
20 | R_RISCV_GOT_HI20 | PC-relative GOT reference | _U-Type_ | G + A | `%got_pcrel_hi(symbol)`
531+
21 | R_RISCV_TLS_GOT_HI20 | PC-relative TLS IE GOT offset | _U-Type_ | | Macro `la.tls.ie`
532+
22 | R_RISCV_TLS_GD_HI20 | PC-relative TLS GD reference | _U-Type_ | | Macro `la.tls.gd`
533+
23 | R_RISCV_PCREL_HI20 | PC-relative reference | _U-Type_ | S + A - P | `%pcrel_hi(symbol)`
534+
24 | R_RISCV_PCREL_LO12_I | PC-relative reference | _I-type_ | S + A - P | `%pcrel_lo(address of %pcrel_hi)`
535+
25 | R_RISCV_PCREL_LO12_S | PC-relative reference | _S-Type_ | S + A - P | `%pcrel_lo(address of %pcrel_hi)`
536+
26 | R_RISCV_HI20 | Absolute address | _U-Type_ | S + A | `%hi(symbol)`
537+
27 | R_RISCV_LO12_I | Absolute address | _I-Type_ | S + A | `%lo(symbol)`
538+
28 | R_RISCV_LO12_S | Absolute address | _S-Type_ | S + A | `%lo(symbol)`
539+
29 | R_RISCV_TPREL_HI20 | TLS LE thread offset | _U-Type_ | | `%tprel_hi(symbol)`
540+
30 | R_RISCV_TPREL_LO12_I | TLS LE thread offset | _I-Type_ | | `%tprel_lo(symbol)`
541+
31 | R_RISCV_TPREL_LO12_S | TLS LE thread offset | _S-Type_ | | `%tprel_lo(symbol)`
542+
32 | R_RISCV_TPREL_ADD | TLS LE thread usage | | | `%tprel_add(symbol)`
543+
33 | R_RISCV_ADD8 | 8-bit label addition | _word8_ | V + S + A
544+
34 | R_RISCV_ADD16 | 16-bit label addition | _word16_ | V + S + A
545+
35 | R_RISCV_ADD32 | 32-bit label addition | _word32_ | V + S + A
546+
36 | R_RISCV_ADD64 | 64-bit label addition | _word64_ | V + S + A
547+
37 | R_RISCV_SUB8 | 8-bit label subtraction | _word8_ | V - S - A
548+
38 | R_RISCV_SUB16 | 16-bit label subtraction | _word16_ | V - S - A
549+
39 | R_RISCV_SUB32 | 32-bit label subtraction | _word32_ | V - S - A
550+
40 | R_RISCV_SUB64 | 64-bit label subtraction | _word64_ | V - S - A
551+
41 | R_RISCV_GNU_VTINHERIT | GNU C++ vtable hierarchy |
552+
42 | R_RISCV_GNU_VTENTRY | GNU C++ vtable member usage |
553+
43 | R_RISCV_ALIGN | Alignment statement |
554+
44 | R_RISCV_RVC_BRANCH | PC-relative branch offset | _CB-Type_ | S + A - P
555+
45 | R_RISCV_RVC_JUMP | PC-relative jump offset | _CJ-Type_ | S + A - P
556+
46 | R_RISCV_RVC_LUI | Absolute address | _CI-Type_ | S + A
557+
47 | R_RISCV_GPREL_I | GP-relative reference | _I-Type_ | S + A - GP
558+
48 | R_RISCV_GPREL_S | GP-relative reference | _S-Type_ | S + A - GP
559+
49 | R_RISCV_TPREL_I | TP-relative TLS LE load | _I-Type_
560+
50 | R_RISCV_TPREL_S | TP-relative TLS LE store | _S-Type_
561+
51 | R_RISCV_RELAX | Instruction pair can be relaxed |
562+
52 | R_RISCV_SUB6 | Local label subtraction | _word6_ | V - S - A
563+
53 | R_RISCV_SET6 | Local label assignment | _word6_ | S + A
564+
54 | R_RISCV_SET8 | Local label assignment | _word8_ | S + A
565+
55 | R_RISCV_SET16 | Local label assignment | _word16_ | S + A
566+
56 | R_RISCV_SET32 | Local label assignment | _word32_ | S + A
567+
57 | R_RISCV_32_PCREL | PC-relative reference | _word32_ | S + A - P
568+
58 | R_RISCV_IRELATIVE | Runtime relocation | _wordclass_ | `ifunc_resolver(B + A)`
569+
59 | R_RISCV_64_PCREL | PC-relative reference | _word64_ | S + A - P
570+
60 | R_RISCV_GPREL_HI20 | GP-relative reference | _U-type_ | S + A - GP | `%gprel_hi(symbol)`
571+
61 | R_RISCV_GPREL_LO12_I | GP-relative reference | _I-type_ | S + A - GP | `%gprel_lo(symbol)`
572+
62 | R_RISCV_GPREL_LO12_S | GP-relative reference | _S-type_ | S + A - GP | `%gprel_lo(symbol)`
573+
63 | R_RISCV_GPREL_ADD | GP-relative usage | | | `%gprel_add(symbol)`
574+
64 | R_RISCV_GPREL_LOAD | GP-relative usage | | | `%gprel(symbol)`
575+
65 | R_RISCV_GPREL_STORE | GP-relative usage | | | `%gprel(symbol)`
576+
66 | R_RISCV_GOT_GPREL_HI20 | GP-relative GOT reference | _U-type_ | G + A - GP | `%got_gprel_hi(symbol)`
577+
67 | R_RISCV_GOT_GPREL_LO12_I | GP-relative GOT reference | _I-type_ | G + A - GP | `%got_gprel_lo(symbol)`
578+
68 | R_RISCV_GOT_GPREL_ADD | GP-relative GOT usage | | | `%got_gprel_add(symbol)`
579+
69 | R_RISCV_GOT_GPREL_LOAD | GP-relative GOT usage | | | `%got_gprel(symbol)`
580+
70 | R_RISCV_GOT_GPREL_STORE | GP-relative GOT usage | | | `%got_gprel(symbol)`
581+
71 | R_RISCV_TLS_GOT_GPREL_HI20 | GP-relative TLS GOT reference | | | Macro `la.tls.ie.gprel`
582+
72 | R_RISCV_TLS_GOT_GPREL_LO20_I | GP-relative TLS GOT reference | | | Macro `la.tls.ie.gprel`
583+
73 | R_RISCV_TLS_GOT_GPREL_ADD | GP-relative TLS GOT usage | | | `%tls_ie_gprel(<symbol>)`
584+
74 | R_RISCV_TLS_GD_GPREL_HI20 | GP-relative TLS GD reference | | | Macro `la.tls.gd.gprel`
585+
75 | R_RISCV_TLS_GD_GPREL_LO20_I | GP-relative TLS GD reference | | | Macro `la.tls.gd.gprel`
586+
76 | R_RISCV_TLS_GD_GPREL_ADD | GP-relative TLS GD usage | | | `%tls_gd_gprel(<symbol>)`
587+
77-191 | *Reserved* | Reserved for future standard use
588+
192-255 | *Reserved* | Reserved for nonstandard ABI extensions
583589

584590
Nonstandard extensions are free to use relocation numbers 192-255 for any
585591
purpose. These relocations may conflict with other nonstandard extensions.

0 commit comments

Comments
 (0)