1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#[derive(Debug, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum EntryType {
    /// Marks end of dynamic section
    Null,
    /// Name of needed library
    Needed,
    /// Size in bytes of PLT relocs
    PLTRelSz,
    /// Processor defined value
    PLTGOT,
    /// Address of symbol hash table
    Hash,
    /// Address of string table
    StrTab,
    /// Address of symbol table
    SymTab,
    /// Address of Rela relocs
    Rela,
    /// Total size of Rela relocs
    RelaSz,
    /// Size of one Rela reloc
    RelaEnt,
    /// Size of string table
    StrSz,
    /// Size of one symbol table entry
    SymEnt,
    /// Address of init function
    Init,
    /// Address of termination function
    Fini,
    /// Name of shared object
    SOName,
    /// Library search path (deprecated)
    RPath,
    /// Start Symbol search here
    Symbolic,
    /// Address of Rel relocs
    Rel,
    /// Total size of Rel relocs
    RelSz,
    /// Size of one Rel reloc
    RelEnt,
    /// Type of reloc in PLT
    PLTRel,
    /// For debugging
    Debug,
    /// Reloc might modify .text
    TextRel,
    /// Address of PLT relocs
    JmpRel,
    /// Process relocations of object
    BindNow,
    /// Array with addresses of init fct
    InitArray,
    /// Array with addresses of fini fct
    FiniArray,
    /// Size in bytes of `InitArray`
    InitArraySz,
    /// Size in bytes of `FiniArray`
    FiniArraySz,
    /// Library search path
    RunPath,
    /// Flags for the object being loaded
    Flags,
    /// Start of encode range
    Encoding,
    /// Array with addresses of preinit fct
    PreInitArray,
    /// Size in bytes of `PreInitArray`
    PreInitArraySz,
    /// Address of `SYMTAB_SHNDX` section
    SymTabShNdx,
    /// Number used
    Num,
    /// Start of OS specific
    LoOS,
    /// End of OS specific
    HiOS,
    /// Start of processor specific
    LoProc,
    /// End of processor specific
    HiProc,
    /// Address of table with needed versions
    VerNeed,
    /// Number of needed versions
    VerNeedNum,
    /// GNU-style hash table
    GNUHash,
    /// State Flags, See `Flags::*1`.
    Flags1,
    /// The versioning entry types.
    VerSym,
    RelCount,
    RelaCount,
    /// User defined value
    Any(i64),
}

impl From<i64> for EntryType {
    fn from(v: i64) -> Self {
        match v {
            0 => EntryType::Null,
            1 => EntryType::Needed,
            2 => EntryType::PLTRelSz,
            3 => EntryType::PLTGOT,
            4 => EntryType::Hash,
            5 => EntryType::StrTab,
            6 => EntryType::SymTab,
            7 => EntryType::Rela,
            8 => EntryType::RelaSz,
            9 => EntryType::RelaEnt,
            10 => EntryType::StrSz,
            11 => EntryType::SymEnt,
            12 => EntryType::Init,
            13 => EntryType::Fini,
            14 => EntryType::SOName,
            15 => EntryType::RPath,
            16 => EntryType::Symbolic,
            17 => EntryType::Rel,
            18 => EntryType::RelSz,
            19 => EntryType::RelEnt,
            20 => EntryType::PLTRel,
            21 => EntryType::Debug,
            22 => EntryType::TextRel,
            23 => EntryType::JmpRel,
            24 => EntryType::BindNow,
            25 => EntryType::InitArray,
            26 => EntryType::FiniArray,
            27 => EntryType::InitArraySz,
            28 => EntryType::FiniArraySz,
            29 => EntryType::RunPath,
            30 => EntryType::Flags,
            32 => EntryType::PreInitArray,
            33 => EntryType::PreInitArraySz,
            34 => EntryType::SymTabShNdx,
            35 => EntryType::Num,
            0x6000000d => EntryType::LoOS,
            0x6ffff000 => EntryType::HiOS,
            0x70000000 => EntryType::LoProc,
            0x7fffffff => EntryType::HiProc,
            0x6ffffef5 => EntryType::GNUHash,
            0x6ffffff0 => EntryType::VerSym,
            0x6ffffff9 => EntryType::RelaCount,
            0x6ffffffa => EntryType::RelCount,
            0x6ffffffb => EntryType::Flags1,
            0x6ffffffe => EntryType::VerNeed,
            0x6fffffff => EntryType::VerNeedNum,
            _ => EntryType::Any(v),
        }
    }
}