moto_runtime/external/elfloader/arch/
x86.rs

1// Should be in xmas-elf see: https://github.com/nrc/xmas-elf/issues/54
2#[derive(Eq, PartialEq, Debug, Clone, Copy)]
3#[allow(non_camel_case_types)]
4#[repr(u32)]
5pub enum RelocationTypes {
6    /// No relocation.
7    R_386_NONE,
8    /// Add 32 bit dword symbol value.
9    R_386_32,
10    /// PC-relative 32 bit signed sym value.
11    R_386_PC32,
12    /// 32 bit GOT offset.
13    R_386_GOT32,
14    /// 32 bit PLT offset.
15    R_386_PLT32,
16    /// Copy data from shared object.
17    R_386_COPY,
18    /// Set GOT entry to data address.
19    R_386_GLOB_DAT,
20    /// Set PLT entry to code address.
21    R_386_JMP_SLOT,
22    /// Add load address of shared object.
23    R_386_RELATIVE,
24    /// 32-bit GOT offset
25    R_386_GOTOFF,
26    /// 32-bit PC relative offset to GOT
27    R_386_GOTPC,
28    /// Direct 32 bit PLT address
29    R_386_32PLT,
30    /// Direct 16 bit zero extended
31    R_386_16,
32    /// 16 bit sign extended pc relative
33    R_386_PC16,
34    /// Direct 8 bit sign extended
35    R_386_8,
36    /// 8 bit sign extended pc relative
37    R_386_PC8,
38    /// 32-bit symbol size
39    R_386_SIZE32,
40    /// Unknown
41    Unknown(u32),
42}
43
44impl RelocationTypes {
45    pub fn from(typ: u32) -> RelocationTypes {
46        use RelocationTypes::*;
47        match typ {
48            0 => R_386_NONE,
49            1 => R_386_PC32,
50            2 => R_386_32,
51            3 => R_386_GOT32,
52            4 => R_386_PLT32,
53            5 => R_386_COPY,
54            6 => R_386_GLOB_DAT,
55            7 => R_386_JMP_SLOT,
56            8 => R_386_RELATIVE,
57            9 => R_386_GOTOFF,
58            10 => R_386_GOTPC,
59            11 => R_386_32PLT,
60            20 => R_386_16,
61            21 => R_386_PC16,
62            22 => R_386_8,
63            23 => R_386_PC8,
64            38 => R_386_SIZE32,
65            x => Unknown(x),
66        }
67    }
68}