Skip to content

Commit 4931021

Browse files
committed
riscv: fix relocation constants numbering
references: 1. https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc 2. https://riscv-non-isa.github.io/riscv-elf-psabi-doc/ version 1.1, November 26, 2025 Signed-off-by: Jvle <[email protected]>
1 parent 499e308 commit 4931021

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

src/elf/constants_relocation.rs

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -856,21 +856,21 @@ pub const R_RISCV_TPREL_LO12_I: u32 = 30;
856856
pub const R_RISCV_TPREL_LO12_S: u32 = 31;
857857
/// TLS LE thread usage: %tprel_add(symbol)
858858
pub const R_RISCV_TPREL_ADD: u32 = 32;
859-
/// 8-bit label addition: word8 = S + A
859+
/// 8-bit label addition: word8 = V + S + A
860860
pub const R_RISCV_ADD8: u32 = 33;
861-
/// 16-bit label addition: word16 = S + A
861+
/// 16-bit label addition: word16 = V + S + A
862862
pub const R_RISCV_ADD16: u32 = 34;
863-
/// 32-bit label addition: word32 = S + A
863+
/// 32-bit label addition: word32 = V + S + A
864864
pub const R_RISCV_ADD32: u32 = 35;
865-
/// 64-bit label addition: word64 = S + A
865+
/// 64-bit label addition: word64 = V + S + A
866866
pub const R_RISCV_ADD64: u32 = 36;
867-
/// 8-bit label subtraction: word8 = S - A
867+
/// 8-bit label subtraction: word8 = V - S - A
868868
pub const R_RISCV_SUB8: u32 = 37;
869-
/// 16-bit label subtraction: word16 = S - A
869+
/// 16-bit label subtraction: word16 = V - S - A
870870
pub const R_RISCV_SUB16: u32 = 38;
871-
/// 32-bit label subtraction: word32 = S - A
871+
/// 32-bit label subtraction: word32 = V - S - A
872872
pub const R_RISCV_SUB32: u32 = 39;
873-
/// 64-bit label subtraction: word64 = S - A
873+
/// 64-bit label subtraction: word64 = V - S - A
874874
pub const R_RISCV_SUB64: u32 = 40;
875875
/// GNU C++ vtable hierarchy
876876
pub const R_RISCV_GNU_VTINHERIT: u32 = 41;
@@ -896,14 +896,34 @@ pub const R_RISCV_TPREL_S: u32 = 50;
896896
pub const R_RISCV_RELAX: u32 = 51;
897897
/// Local label subtraction
898898
pub const R_RISCV_SUB6: u32 = 52;
899-
/// Local label subtraction
899+
/// Local label assignment
900900
pub const R_RISCV_SET6: u32 = 53;
901-
/// Local label subtraction
901+
/// Local label assignment
902902
pub const R_RISCV_SET8: u32 = 54;
903-
/// Local label subtraction
903+
/// Local label assignment
904904
pub const R_RISCV_SET16: u32 = 55;
905-
/// Local label subtraction
905+
/// Local label assignment
906906
pub const R_RISCV_SET32: u32 = 56;
907+
/// 32-bit PC-relative relocation
908+
pub const R_RISCV_32_PCREL: u32 = 57;
909+
/// IRELATIVE relocation against non-preemptible ifunc symbol
910+
pub const R_RISCV_IRELATIVE: u32 = 58;
911+
/// 32-bit relative offset to a function or its PLT entry
912+
pub const R_RISCV_PLT32: u32 = 59;
913+
/// ULEB128 local label assignment
914+
pub const R_RISCV_SET_ULEB128: u32 = 60;
915+
/// ULEB128 local label subtraction
916+
pub const R_RISCV_SUB_ULEB128: u32 = 61;
917+
/// TLS descriptor: high 20 bits
918+
pub const R_RISCV_TLSDESC_HI20: u32 = 62;
919+
/// TLS descriptor: load low 12 bits
920+
pub const R_RISCV_TLSDESC_LOAD_LO12: u32 = 63;
921+
/// TLS descriptor: add low 12 bits
922+
pub const R_RISCV_TLSDESC_ADD_LO12: u32 = 64;
923+
/// TLS descriptor: call
924+
pub const R_RISCV_TLSDESC_CALL: u32 = 65;
925+
/// Vendor marker
926+
pub const R_RISCV_VENDOR: u32 = 191;
907927

908928
/////////////////////
909929
// PowerPC 32-bit
@@ -1845,6 +1865,16 @@ pub fn r_to_str(typ: u32, machine: u16) -> &'static str {
18451865
R_RISCV_SET8 => "R_RISCV_SET8",
18461866
R_RISCV_SET16 => "R_RISCV_SET16",
18471867
R_RISCV_SET32 => "R_RISCV_SET32",
1868+
R_RISCV_32_PCREL => "R_RISCV_32_PCREL",
1869+
R_RISCV_IRELATIVE => "R_RISCV_IRELATIVE",
1870+
R_RISCV_PLT32 => "R_RISCV_PLT32",
1871+
R_RISCV_SET_ULEB128 => "R_RISCV_SET_ULEB128",
1872+
R_RISCV_SUB_ULEB128 => "R_RISCV_SUB_ULEB128",
1873+
R_RISCV_TLSDESC_HI20 => "R_RISCV_TLSDESC_HI20",
1874+
R_RISCV_TLSDESC_LOAD_LO12 => "R_RISCV_TLSDESC_LOAD_LO12",
1875+
R_RISCV_TLSDESC_ADD_LO12 => "R_RISCV_TLSDESC_ADD_LO12",
1876+
R_RISCV_TLSDESC_CALL => "R_RISCV_TLSDESC_CALL",
1877+
R_RISCV_VENDOR => "R_RISCV_VENDOR",
18481878
_ => "R_UNKNOWN_RISCV",
18491879
},
18501880
// Power-PC 32-bit

0 commit comments

Comments
 (0)