@@ -469,65 +469,65 @@ Global Offset Table or DWARF meta data.
469469The following table provides details of the RISC-V ELF relocations (instruction
470470specific relocations show the instruction type in the Details column):
471471
472- Enum | ELF Reloc Type | Description | Details
473- :--- | :------------------ | :--------------- | :-----------
474- 0 | R_RISCV_NONE | None |
475- 1 | R_RISCV_32 | Runtime relocation | word32 = S + A
476- 2 | R_RISCV_64 | Runtime relocation | word64 = S + A
477- 3 | R_RISCV_RELATIVE | Runtime relocation | word32,64 = B + A
478- 4 | R_RISCV_COPY | Runtime relocation | must be in executable. not allowed in shared library
479- 5 | R_RISCV_JUMP_SLOT | Runtime relocation | word32,64 = S ;handled by PLT unless LD_BIND_NOW
480- 6 | R_RISCV_TLS_DTPMOD32 | TLS relocation | word32 = S->TLSINDEX
481- 7 | R_RISCV_TLS_DTPMOD64 | TLS relocation | word64 = S->TLSINDEX
482- 8 | R_RISCV_TLS_DTPREL32 | TLS relocation | word32 = TLS + S + A - TLS_TP_OFFSET
483- 9 | R_RISCV_TLS_DTPREL64 | TLS relocation | word64 = TLS + S + A - TLS_TP_OFFSET
484- 10 | R_RISCV_TLS_TPREL32 | TLS relocation | word32 = TLS + S + A + S_TLS_OFFSET - TLS_DTV_OFFSET
485- 11 | R_RISCV_TLS_TPREL64 | TLS relocation | word64 = TLS + S + A + S_TLS_OFFSET - TLS_DTV_OFFSET
486- 16 | R_RISCV_BRANCH | PC-relative branch | (SB-Type)
487- 17 | R_RISCV_JAL | PC-relative jump | (UJ-Type)
488- 18 | R_RISCV_CALL | PC-relative call | MACRO call,tail (auipc+jalr pair)
489- 19 | R_RISCV_CALL_PLT | PC-relative call (PLT) | MACRO call, tail (auipc+jalr pair) PIC
490- 20 | R_RISCV_GOT_HI20 | PC-relative GOT reference | %got_pcrel_hi(symbol) (U-Type)
491- 21 | R_RISCV_TLS_GOT_HI20 | PC-relative TLS IE GOT offset | MACRO la.tls.ie
492- 22 | R_RISCV_TLS_GD_HI20 | PC-relative TLS GD reference | MACRO la.tls.gd
493- 23 | R_RISCV_PCREL_HI20 | PC-relative reference | %pcrel_hi(symbol) (U-Type)
494- 24 | R_RISCV_PCREL_LO12_I | PC-relative reference | %pcrel_lo(pcrel_hi20_address) (I-Type)
495- 25 | R_RISCV_PCREL_LO12_S | PC-relative reference | %pcrel_lo(pcrel_hi20_address) (S-Type)
496- 26 | R_RISCV_HI20 | Absolute address | %hi(symbol) (U-Type)
497- 27 | R_RISCV_LO12_I | Absolute address | %lo(symbol) (I-Type)
498- 28 | R_RISCV_LO12_S | Absolute address | %lo(symbol) (S-Type)
499- 29 | R_RISCV_TPREL_HI20 | TLS LE thread offset | %tprel_hi(symbol) (U-Type)
500- 30 | R_RISCV_TPREL_LO12_I | TLS LE thread offset | %tprel_lo(symbol) (I-Type)
501- 31 | R_RISCV_TPREL_LO12_S | TLS LE thread offset | %tprel_lo(symbol) (S-Type)
502- 32 | R_RISCV_TPREL_ADD | TLS LE thread usage | %tprel_add(symbol)
503- 33 | R_RISCV_ADD8 | 8-bit label addition | word8 = old + S + A
504- 34 | R_RISCV_ADD16 | 16-bit label addition | word16 = old + S + A
505- 35 | R_RISCV_ADD32 | 32-bit label addition | word32 = old + S + A
506- 36 | R_RISCV_ADD64 | 64-bit label addition | word64 = old + S + A
507- 37 | R_RISCV_SUB8 | 8-bit label subtraction | word8 = old - S - A
508- 38 | R_RISCV_SUB16 | 16-bit label subtraction | word16 = old - S - A
509- 39 | R_RISCV_SUB32 | 32-bit label subtraction | word32 = old - S - A
510- 40 | R_RISCV_SUB64 | 64-bit label subtraction | word64 = old - S - A
511- 41 | R_RISCV_GNU_VTINHERIT| GNU C++ vtable hierarchy |
512- 42 | R_RISCV_GNU_VTENTRY | GNU C++ vtable member usage |
513- 43 | R_RISCV_ALIGN | Alignment statement |
514- 44 | R_RISCV_RVC_BRANCH | PC-relative branch offset | (CB-Type)
515- 45 | R_RISCV_RVC_JUMP | PC-relative jump offset | (CJ-Type)
516- 46 | R_RISCV_RVC_LUI | Absolute address | (CI-Type)
517- 47 | R_RISCV_GPREL_I | GP-relative reference | (I-Type)
518- 48 | R_RISCV_GPREL_S | GP-relative reference | (S-Type)
519- 49 | R_RISCV_TPREL_I | TP-relative TLS LE load | (I-Type)
520- 50 | R_RISCV_TPREL_S | TP-relative TLS LE store | (S-Type)
521- 51 | R_RISCV_RELAX | Instruction pair can be relaxed |
522- 52 | R_RISCV_SUB6 | Local label subtraction |
523- 53 | R_RISCV_SET6 | Local label subtraction |
524- 54 | R_RISCV_SET8 | Local label subtraction |
525- 55 | R_RISCV_SET16 | Local label subtraction |
526- 56 | R_RISCV_SET32 | Local label subtraction |
527- 57 | R_RISCV_32_PCREL | PC-relative reference | word32 = S + A - PC
528- 58 | R_RISCV_IRELATIVE | Runtime relocation | word32,64 = ifunc_resolver(B + A)
529- 59-191 | * Reserved* | Reserved for future standard use |
530- 192-255 | * Reserved* | Reserved for nonstandard ABI extensions |
472+ Enum | ELF Reloc Type | Description | Field | Calculation | Details
473+ :--- | :------------------ | :--------------- | :---- | :---------- | : -------
474+ 0 | R_RISCV_NONE | None |
475+ 1 | R_RISCV_32 | Runtime relocation | _ word32 _ | S + A
476+ 2 | R_RISCV_64 | Runtime relocation | _ word64 _ | S + A
477+ 3 | R_RISCV_RELATIVE | Runtime relocation | _ wordclass _ | B + A
478+ 4 | R_RISCV_COPY | Runtime relocation | | | Must be in executable. not allowed in shared library
479+ 5 | R_RISCV_JUMP_SLOT | Runtime relocation | _ wordclass _ | S | Handled by PLT unless ` LD_BIND_NOW `
480+ 6 | R_RISCV_TLS_DTPMOD32 | TLS relocation | _ word32 _ | S->TLSINDEX
481+ 7 | R_RISCV_TLS_DTPMOD64 | TLS relocation | _ word64 _ | S->TLSINDEX
482+ 8 | R_RISCV_TLS_DTPREL32 | TLS relocation | _ word32 _ | S + A + TLS - TLS_TP_OFFSET
483+ 9 | R_RISCV_TLS_DTPREL64 | TLS relocation | _ word64 _ | S + A + TLS - TLS_TP_OFFSET
484+ 10 | R_RISCV_TLS_TPREL32 | TLS relocation | _ word32 _ | S + A + TLS + S_TLS_OFFSET - TLS_DTV_OFFSET
485+ 11 | R_RISCV_TLS_TPREL64 | TLS relocation | _ word64 _ | S + A + TLS + S_TLS_OFFSET - TLS_DTV_OFFSET
486+ 16 | R_RISCV_BRANCH | PC-relative branch | _ B-Type _ | S + A - P
487+ 17 | R_RISCV_JAL | PC-relative jump | _ J-Type _ | S + A - P
488+ 18 | R_RISCV_CALL | PC-relative call | _ J-Type _ | S + A - P | Macros ` call ` , ` tail `
489+ 19 | R_RISCV_CALL_PLT | PC-relative call (PLT) | _ J-Type _ | S + A - P | Macros ` call ` , ` tail ` ( PIC)
490+ 20 | R_RISCV_GOT_HI20 | PC-relative GOT reference | _ U-Type _ | G + A | ` %got_pcrel_hi(symbol) `
491+ 21 | R_RISCV_TLS_GOT_HI20 | PC-relative TLS IE GOT offset | _ U-Type _ | | Macro ` la.tls.ie `
492+ 22 | R_RISCV_TLS_GD_HI20 | PC-relative TLS GD reference | _ U-Type _ | | Macro ` la.tls.gd `
493+ 23 | R_RISCV_PCREL_HI20 | PC-relative reference | _ U-Type _ | S + A - P | ` %pcrel_hi(symbol) `
494+ 24 | R_RISCV_PCREL_LO12_I | PC-relative reference | _ I-type _ | S + A - P | ` %pcrel_lo(address of %pcrel_hi) `
495+ 25 | R_RISCV_PCREL_LO12_S | PC-relative reference | _ S-Type _ | S + A - P | ` %pcrel_lo(address of %pcrel_hi) `
496+ 26 | R_RISCV_HI20 | Absolute address | _ U-Type _ | S + A | ` %hi(symbol) `
497+ 27 | R_RISCV_LO12_I | Absolute address | _ I-Type _ | S + A | ` %lo(symbol) `
498+ 28 | R_RISCV_LO12_S | Absolute address | _ S-Type _ | S + A | ` %lo(symbol) `
499+ 29 | R_RISCV_TPREL_HI20 | TLS LE thread offset | _ U-Type _ | | ` %tprel_hi(symbol) `
500+ 30 | R_RISCV_TPREL_LO12_I | TLS LE thread offset | _ I-Type _ | | ` %tprel_lo(symbol) `
501+ 31 | R_RISCV_TPREL_LO12_S | TLS LE thread offset | _ S-Type _ | | ` %tprel_lo(symbol) `
502+ 32 | R_RISCV_TPREL_ADD | TLS LE thread usage | | | ` %tprel_add(symbol) `
503+ 33 | R_RISCV_ADD8 | 8-bit label addition | _ word8 _ | S + A + V
504+ 34 | R_RISCV_ADD16 | 16-bit label addition | _ word16 _ | S + A + V
505+ 35 | R_RISCV_ADD32 | 32-bit label addition | _ word32 _ | S + A + V
506+ 36 | R_RISCV_ADD64 | 64-bit label addition | _ word64 _ | S + A + V
507+ 37 | R_RISCV_SUB8 | 8-bit label subtraction | _ word8 _ | V - S - A
508+ 38 | R_RISCV_SUB16 | 16-bit label subtraction | _ word16 _ | V - S - A
509+ 39 | R_RISCV_SUB32 | 32-bit label subtraction | _ word32 _ | V - S - A
510+ 40 | R_RISCV_SUB64 | 64-bit label subtraction | _ word64 _ | V - S - A
511+ 41 | R_RISCV_GNU_VTINHERIT | GNU C++ vtable hierarchy |
512+ 42 | R_RISCV_GNU_VTENTRY | GNU C++ vtable member usage |
513+ 43 | R_RISCV_ALIGN | Alignment statement |
514+ 44 | R_RISCV_RVC_BRANCH | PC-relative branch offset | _ CB-Type _ | S + A - P
515+ 45 | R_RISCV_RVC_JUMP | PC-relative jump offset | _ CJ-Type _ | S + A - P
516+ 46 | R_RISCV_RVC_LUI | Absolute address | _ CI-Type _ | S + A - P
517+ 47 | R_RISCV_GPREL_I | GP-relative reference | _ I-Type _ | S + A - GP
518+ 48 | R_RISCV_GPREL_S | GP-relative reference | _ S-Type _ | S + A - GP
519+ 49 | R_RISCV_TPREL_I | TP-relative TLS LE load | _ I-Type _
520+ 50 | R_RISCV_TPREL_S | TP-relative TLS LE store | _ S-Type _
521+ 51 | R_RISCV_RELAX | Instruction pair can be relaxed |
522+ 52 | R_RISCV_SUB6 | Local label subtraction |
523+ 53 | R_RISCV_SET6 | Local label subtraction |
524+ 54 | R_RISCV_SET8 | Local label subtraction |
525+ 55 | R_RISCV_SET16 | Local label subtraction |
526+ 56 | R_RISCV_SET32 | Local label subtraction |
527+ 57 | R_RISCV_32_PCREL | PC-relative reference | _ word32 _ | S + A - P
528+ 58 | R_RISCV_IRELATIVE | Runtime relocation | _ wordclass _ | ` ifunc_resolver(B + A) `
529+ 59-191 | * Reserved* | Reserved for future standard use |
530+ 192-255 | * Reserved* | Reserved for nonstandard ABI extensions |
531531
532532Nonstandard extensions are free to use relocation numbers 192-255 for any
533533purpose. These relocations may conflict with other nonstandard extensions.
@@ -536,21 +536,44 @@ This section and later ones contain fragments written in assembler. The precise
536536assembler syntax, including that of the relocations, is described in the
537537[ RISC-V Assembly Programmer's Manual] ( https://github.com/riscv/riscv-asm-manual ) .
538538
539- ### Address Calculation Symbols
539+ ### Calculation Symbols
540540
541- The following table provides details on the variables used in address calculation:
541+ The following table provides details on the variables used in relocation
542+ calculation:
542543
543- Variable | Description
544- :------------- | :----------------
545- A | Addend field in the relocation entry associated with the symbol
546- B | Base address of a shared object loaded into memory
547- G | Offset of the symbol into the GOT (Global Offset Table)
548- S | Value of the symbol in the symbol table
549- GP | Value of ` __global_pointer$ ` symbol.
544+ Variable | Description
545+ :------- | :----------------
546+ A | Addend field in the relocation entry associated with the symbol
547+ B | Base address of a shared object loaded into memory
548+ G | Offset of the symbol into the GOT (Global Offset Table)
549+ P | Position of the relocation
550+ S | Value of the symbol in the symbol table
551+ V | Value at the position of the relocation
552+ GP | Value of ` __global_pointer$ ` symbol
550553
551554** Global Pointer** : It is assumed that program startup code will load the value
552555of the ` __global_pointer$ ` symbol into register ` gp ` (aka ` x3 ` ).
553556
557+ ### Field Symbols
558+
559+ The following table provides details on the variables used in relocation fields:
560+
561+ Variable | Description
562+ :------- | :----------
563+ _ word8_ | Specifies an 8-bit field
564+ _ word16_ | Specifies a 16-bit field
565+ _ word32_ | Specifies a 32-bit field
566+ _ word64_ | Specifies a 64-bit field
567+ _ wordclass_ | Specifies a _ word32_ field for ILP32 or a _ word64_ field for LP64
568+ _ B-Type_ | Specifies a field as the immediate field in a B-type instruction
569+ _ CB-Type_ | Specifies a field as the immediate field in a CB-type instruction
570+ _ CI-Type_ | Specifies a field as the immediate field in a CI-type instruction
571+ _ CJ-Type_ | Specifies a field as the immediate field in a CJ-type instruction
572+ _ I-Type_ | Specifies a field as the immediate field in an I-type instruction
573+ _ S-Type_ | Specifies a field as the immediate field in an S-type instruction
574+ _ U-Type_ | Specifies a field as the immediate field in an U-type instruction
575+ _ J-Type_ | Specifies a field as the immediate field in a J-type instruction
576+
554577### Absolute Addresses
555578
55657932-bit absolute addresses in position dependent code are loaded with a pair
@@ -951,4 +974,3 @@ there is no differentiation between ILP32 and LP64 abis.
951974 Here a combination of the ** gABI** and the ** psABI**
952975* ** gABI** : generic ABI
953976* ** psABI** : processor specific ABI
954-
0 commit comments