malwaredb_types/exec/elf/fields.rs
1// SPDX-License-Identifier: Apache-2.0
2
3use flagset::flags;
4
5flags! {
6 /// ELF Program Header flags
7 #[non_exhaustive]
8 pub enum ProgramHeaderFlags: u32 {
9 /// PT_NULL: Program header entry is unused
10 Null = 0,
11
12 /// PT_LOAD: Loadable segment
13 Loadable = 1,
14
15 /// PT_DYNAMIC
16 Dynamic = 2,
17
18 /// PT_INTERP: Interpreter information
19 Interpreter = 3,
20
21 /// PT_NOTE: Extra information
22 Note = 4,
23
24 /// PT_SHLIB: Reserved
25 Reserved = 5,
26
27 /// PT_PHDR: Program header table
28 ProgramHeaderTable = 6,
29
30 /// PT_TLS: Thread Local Storage template
31 TLS = 7,
32
33 /// PT_LOOS: Start of OS-specific fields
34 LoOS = 0x6000_0000,
35
36 /// PT_HIOS: End of OS-specific fields
37 HiOS = 0x6fff_ffff,
38
39 /// PT_LOPROC: Start of processor-specific fields
40 LoProc = 0x7000_0000,
41
42 /// PT_HIPROC: End of processor-specific fields
43 HiProc = 0x7fff_ffff,
44 }
45
46 /// ELF Section Header types
47 #[non_exhaustive]
48 pub enum SectionHeaderTypes: u32 {
49 /// SHT_NULL: Unused
50 NULL = 0,
51
52 /// SHT_PROGBITS: Program data
53 ProgramBits = 1,
54
55 /// SHT_SYMTAB: Symbol table
56 SymbolTable = 2,
57
58 /// SHT_STRTAB: String table
59 StringTable = 3,
60
61 /// SHT_RELA: Relocation entries with addends (to be computed)
62 RelocationsAddends = 4,
63
64 /// SHT_HASH: Symbol hash table
65 Hash = 5,
66
67 /// SHT_DYNAMIC: Dynamic linking information
68 DynamicLinking = 6,
69
70 /// SHT_NOTE: Notes
71 Notes = 7,
72
73 /// SHT_NOBITS: Program space with no data (bss)
74 NoBits = 8,
75
76 /// SHT_REL: Relocation entries, no addends
77 Relocations = 9,
78
79 /// SHT_SHLIB: Reserved
80 Shlib = 0xA,
81
82 /// SHT_DYNSYM: Dynamic symbol linker table
83 DynamicSymbolsTable = 0xB,
84
85 /// SHT_INIT_ARRAY: Array of constructors
86 InitArray = 0xE,
87
88 /// SHT_FINI_ARRAY: Array of destructors
89 FiniArray = 0xF,
90
91 /// SHT_PREINIT_ARRAY: Array of pre-constructors
92 PreInitArray = 0x10,
93
94 /// SHT_GROUP: Section group
95 Group = 0x11,
96
97 /// SHT_SYMTAB_SHNDX: Extended section indices
98 ExtendedIndices = 0x12,
99
100 /// SHT_NUM: Number of defined types
101 NumTypes = 0x13,
102
103 /// SHT_LOOS: Start OS-specific
104 LoOS = 0x6000_0000,
105
106 /// SHT_GNU_ATTRIBUTES: GNU object attributes
107 GnuAttributes = 0x6fff_fff5,
108
109 /// SHT_GNU_HASH: GNU hash table
110 GnuHash = 0x6fff_fff6,
111
112 /// SHT_GNU_LIBLIST: GNU prelink libraries
113 LibList = 0x6fff_fff7,
114
115 /// SHT_GNU_VERDEF: GNU version definitions
116 VerDef = 0x6fff_fffd,
117
118 /// SHT_GNU_VERNEED: GNU version needs
119 VerNeed = 0x6fff_fffe,
120
121 /// SHT_GNU_VERSYM: GNU version symbol table
122 VerSym = 0x6fff_ffff,
123
124 /// SHT_HIOS: Last of OS-specific
125 HiOS = 0x6fff_ffff,
126
127 /// SHT_LOPROC: Reserved range for processors
128 LoProc = 0x7000_0000,
129
130 /// SHT_MIPS_ABIFLAGS: MIPS ABI flags
131 MipsABI = 0x7000_002a,
132
133 /// SHT_HIPROC: Last of processor-specific headers
134 HiProc = 0x7fff_ffff,
135
136 /// SHT_LOUSER: Start of application-specific range
137 LoUser = 0x8000_0000,
138
139 /// SHT_HIUSER: End of application-specific range
140 HiUser = 0xffff_ffff,
141 }
142
143 /// ELF Section Header flags
144 #[non_exhaustive]
145 pub enum SectionHeaderFlags: u32 {
146 /// SHF_WRITE: writable data
147 Write = 1,
148
149 /// SHF_ALLOC: section occupies memory
150 Alloc = 2,
151
152 /// SHF_EXECINSTR: section contains instructions
153 Exec = 4,
154
155 /// SHF_MERGE: section may be merged
156 Mergeable = 0x10,
157
158 /// SHF_STRINGS: section contains strings
159 Strings = 0x20,
160
161 /// SHF_INFO_LINK: holds section index
162 InfoLink = 0x40,
163
164 /// SHF_LINK_ORDER: special ordering requirements
165 LinkOrder = 0x80,
166
167 /// SHF_OS_NONCONFORMING: OS-specific processing required
168 OSNonConforming = 0x100,
169
170 /// SHF_GROUP: Member of section group
171 Group = 0x200,
172
173 /// SHF_TLS: section contains Thread Local Storage (TLS) data
174 TLS = 0x400,
175
176 /// SHF_COMPRESSED: section is compressed
177 Compressed = 0x800,
178
179 /// SHF_MASKOS: OS-specific items
180 MaskOS = 0x0ff0_0000,
181
182 /// SHF_MASKPROC: processor-specific items
183 MaskProc = 0xf000_0000,
184 }
185}