Line data Source code
1 : use lief_ffi as ffi;
2 :
3 : use std::{fmt, marker::PhantomData};
4 :
5 : use crate::common::FromFFI;
6 :
7 :
8 : #[allow(non_camel_case_types)]
9 80 : #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
10 : /// The type of the underlying ELF file. This enum matches
11 : /// the semantic of `ET_NONE`, `ET_REL`, ...
12 : pub enum FileType {
13 : /// Can't be determined
14 : NONE,
15 :
16 : /// Relocatable file (or object file)
17 : REL,
18 :
19 : /// non-pie executable
20 : EXEC,
21 :
22 : /// Shared library **or** a pie-executable
23 : DYN,
24 :
25 : /// Core dump file
26 : CORE,
27 : UNKNOWN(u32),
28 : }
29 :
30 :
31 : impl FileType {
32 80 : pub fn from_value(value: u32) -> Self {
33 80 : match value {
34 0 : 0x00000000 => FileType::NONE,
35 20 : 0x00000001 => FileType::REL,
36 30 : 0x00000002 => FileType::EXEC,
37 20 : 0x00000003 => FileType::DYN,
38 10 : 0x00000004 => FileType::CORE,
39 0 : _ => FileType::UNKNOWN(value),
40 :
41 : }
42 80 : }
43 : }
44 :
45 :
46 : #[allow(non_camel_case_types)]
47 160 : #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
48 : /// Match the result of `Elfxx_Ehdr.e_version`
49 : pub enum Version {
50 : /// Invalid ELF version
51 : NONE,
52 :
53 : /// Current version (default)
54 : CURRENT,
55 : UNKNOWN(u32),
56 : }
57 :
58 : impl Version {
59 160 : pub fn from_value(value: u32) -> Self {
60 160 : match value {
61 0 : 0x00000000 => Version::NONE,
62 160 : 0x00000001 => Version::CURRENT,
63 0 : _ => Version::UNKNOWN(value),
64 :
65 : }
66 160 : }
67 : }
68 :
69 :
70 : #[allow(non_camel_case_types)]
71 80 : #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
72 : /// Match the result of `Elfxx_Ehdr.e_ident[EI_CLASS]`
73 : pub enum Class {
74 : /// Invalid class
75 : NONE,
76 :
77 : /// 32-bit objects
78 : ELF32,
79 :
80 : /// 64-bits objects
81 : ELF64,
82 : UNKNOWN(u32),
83 : }
84 :
85 : impl Class {
86 80 : pub fn from_value(value: u32) -> Self {
87 80 : match value {
88 0 : 0x00000000 => Class::NONE,
89 10 : 0x00000001 => Class::ELF32,
90 70 : 0x00000002 => Class::ELF64,
91 0 : _ => Class::UNKNOWN(value),
92 :
93 : }
94 80 : }
95 : }
96 :
97 :
98 : #[allow(non_camel_case_types)]
99 80 : #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
100 : /// Match the result `Elfxx_Ehdr.e_ident[EI_OSABI]`
101 : pub enum OsAbi {
102 : /// UNIX System V ABI
103 : SYSTEMV,
104 : /// HP-UX operating system
105 : HPUX,
106 : /// NetBSD
107 : NETBSD,
108 : /// GNU/Linux
109 : GNU,
110 : /// Historical alias for ELFOSABI_GNU.
111 : LINUX,
112 : /// GNU/Hurd
113 : HURD,
114 : /// Solaris
115 : SOLARIS,
116 : /// AIX
117 : AIX,
118 : /// IRIX
119 : IRIX,
120 : /// FreeBSD
121 : FREEBSD,
122 : /// TRU64 UNIX
123 : TRU64,
124 : /// Novell Modesto
125 : MODESTO,
126 : /// OpenBSD
127 : OPENBSD,
128 : /// OpenVMS
129 : OPENVMS,
130 : /// Hewlett-Packard Non-Stop Kernel
131 : NSK,
132 : /// AROS
133 : AROS,
134 : /// FenixOS
135 : FENIXOS,
136 : /// Nuxi CloudABI
137 : CLOUDABI,
138 : /// Bare-metal TMS320C6000
139 : C6000_ELFABI,
140 : /// AMD HSA runtim
141 : AMDGPU_HSA,
142 : /// Linux TMS320C6000
143 : C6000_LINUX,
144 : /// ARM
145 : ARM,
146 : /// Standalone (embedded) applicatio
147 : STANDALONE,
148 : UNKNOWN(u32),
149 : }
150 :
151 :
152 : impl OsAbi {
153 80 : pub fn from_value(value: u32) -> Self {
154 80 : match value {
155 70 : 0x00000000 => OsAbi::SYSTEMV,
156 0 : 0x00000001 => OsAbi::HPUX,
157 0 : 0x00000002 => OsAbi::NETBSD,
158 10 : 0x00000003 => OsAbi::LINUX,
159 0 : 0x00000004 => OsAbi::HURD,
160 0 : 0x00000006 => OsAbi::SOLARIS,
161 0 : 0x00000007 => OsAbi::AIX,
162 0 : 0x00000008 => OsAbi::IRIX,
163 0 : 0x00000009 => OsAbi::FREEBSD,
164 0 : 0x0000000a => OsAbi::TRU64,
165 0 : 0x0000000b => OsAbi::MODESTO,
166 0 : 0x0000000c => OsAbi::OPENBSD,
167 0 : 0x0000000d => OsAbi::OPENVMS,
168 0 : 0x0000000e => OsAbi::NSK,
169 0 : 0x0000000f => OsAbi::AROS,
170 0 : 0x00000010 => OsAbi::FENIXOS,
171 0 : 0x00000011 => OsAbi::CLOUDABI,
172 : /* 0x00000040 => OsAbi::C6000_ELFABI, */
173 0 : 0x00000040 => OsAbi::AMDGPU_HSA,
174 0 : 0x00000041 => OsAbi::C6000_LINUX,
175 0 : 0x00000061 => OsAbi::ARM,
176 0 : 0x000000ff => OsAbi::STANDALONE,
177 0 : _ => OsAbi::UNKNOWN(value),
178 :
179 : }
180 80 : }
181 : }
182 :
183 :
184 : #[allow(non_camel_case_types)]
185 80 : #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
186 : /// Match the result `Elfxx_Ehdr.e_ident[EI_DATA]`
187 : pub enum ElfData {
188 : /// Invalid data encodin
189 : NONE,
190 : /// 2's complement, little endian
191 : LSB,
192 : /// 2's complement, big endian
193 : MSB,
194 : UNKNOWN(u32),
195 : }
196 :
197 : impl ElfData {
198 80 : pub fn from_value(value: u32) -> Self {
199 80 : match value {
200 0 : 0x00000000 => ElfData::NONE,
201 70 : 0x00000001 => ElfData::LSB,
202 10 : 0x00000002 => ElfData::MSB,
203 0 : _ => ElfData::UNKNOWN(value),
204 :
205 : }
206 80 : }
207 : }
208 :
209 : /// Class which represents the ELF's header. This class mirrors the raw
210 : /// ELF `Elfxx_Ehdr` structure
211 : pub struct Header<'a> {
212 : ptr: cxx::UniquePtr<ffi::ELF_Header>,
213 : _owner: PhantomData<&'a ffi::ELF_Binary>
214 : }
215 :
216 : impl FromFFI<ffi::ELF_Header> for Header<'_> {
217 80 : fn from_ffi(hdr: cxx::UniquePtr<ffi::ELF_Header>) -> Self {
218 80 : Self {
219 80 : ptr: hdr,
220 80 : _owner: PhantomData
221 80 : }
222 80 : }
223 : }
224 :
225 : impl Header<'_> {
226 : /// Executable entrypoint
227 80 : pub fn entrypoint(&self) -> u64 {
228 80 : self.ptr.entrypoint()
229 80 : }
230 :
231 : /// Define the object file type. (e.g. executable, library...)
232 80 : pub fn file_type(&self) -> FileType {
233 80 : FileType::from_value(self.ptr.file_type())
234 80 : }
235 :
236 : /// Version of the object file format
237 80 : pub fn object_file_version(&self) -> Version {
238 80 : Version::from_value(self.ptr.object_file_version())
239 80 : }
240 :
241 : /// Return the object's class. `ELF64` or `ELF32`
242 80 : pub fn identity_class(&self) -> Class {
243 80 : Class::from_value(self.ptr.identity_class())
244 80 : }
245 :
246 : /// Specify the data encoding
247 80 : pub fn identity_data(&self) -> ElfData {
248 80 : ElfData::from_value(self.ptr.identity_data())
249 80 : }
250 :
251 : /// See: [`Header::object_file_version`]
252 80 : pub fn identity_version(&self) -> Version {
253 80 : Version::from_value(self.ptr.identity_version())
254 80 : }
255 :
256 : /// Identifies the version of the ABI for which the object is prepared
257 80 : pub fn identity_os_abi(&self) -> OsAbi {
258 80 : OsAbi::from_value(self.ptr.identity_os_abi())
259 80 : }
260 :
261 : /// Target architecture
262 80 : pub fn machine_type(&self) -> Arch {
263 80 : Arch::from(self.ptr.machine_type())
264 80 : }
265 :
266 : /// Offset of the programs table (also known as segments table)
267 80 : pub fn program_headers_offset(&self) -> u64 {
268 80 : self.ptr.program_headers_offset()
269 80 : }
270 :
271 : /// Offset of the sections table
272 80 : pub fn section_headers_offset(&self) -> u64 {
273 80 : self.ptr.section_headers_offset()
274 80 : }
275 :
276 : /// Processor-specific flags
277 80 : pub fn processor_flag(&self) -> u32 {
278 80 : self.ptr.processor_flag()
279 80 : }
280 :
281 : /// Size of the current header (i.e. `sizeof(Elfxx_Ehdr)`)
282 : /// This size should be 64 for an `ELF64` binary and 52 for an `ELF32`.
283 80 : pub fn header_size(&self) -> u32 {
284 80 : self.ptr.header_size()
285 80 : }
286 :
287 : /// Return the size of a program header (i.e. `sizeof(Elfxx_Phdr)`)
288 : /// This size should be 56 for an `ELF64` binary and 32 for an `ELF32`.
289 80 : pub fn program_header_size(&self) -> u32 {
290 80 : self.ptr.program_header_size()
291 80 : }
292 :
293 : /// Return the number of segments
294 80 : pub fn numberof_segments(&self) -> u32 {
295 80 : self.ptr.numberof_segments()
296 80 : }
297 :
298 : /// Return the size of a section header (i.e. `sizeof(Elfxx_Shdr)`)
299 : /// This size should be 64 for a ``ELF64`` binary and 40 for an ``ELF32``.
300 80 : pub fn section_header_size(&self) -> u32 {
301 80 : self.ptr.section_header_size()
302 80 : }
303 :
304 : /// Return the number of sections
305 : ///
306 : /// <div class="warning">
307 : /// This value could differ from the real number of sections
308 : /// present in the binary. It must be taken as an <i>indication</i>
309 : /// </div>
310 80 : pub fn numberof_sections(&self) -> u32 {
311 80 : self.ptr.numberof_sections()
312 80 : }
313 :
314 : /// Return the section's index which contains sections' names
315 80 : pub fn section_name_table_idx(&self) -> u32 {
316 80 : self.ptr.section_name_table_idx()
317 80 : }
318 : }
319 :
320 : impl fmt::Debug for Header<'_> {
321 80 : fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
322 80 : f.debug_struct("Header")
323 80 : .field("entrypoint", &self.entrypoint())
324 80 : .field("object_file_version", &self.object_file_version())
325 80 : .field("identity_class", &self.identity_class())
326 80 : .field("identity_os_abi", &self.identity_os_abi())
327 80 : .field("identity_data", &self.identity_data())
328 80 : .field("identity_version", &self.identity_version())
329 80 : .field("file_type", &self.file_type())
330 80 : .field("machine_type", &self.machine_type())
331 80 : .field("program_headers_offset", &self.program_headers_offset())
332 80 : .field("section_headers_offset", &self.section_headers_offset())
333 80 : .field("processor_flag", &self.processor_flag())
334 80 : .field("header_size", &self.header_size())
335 80 : .field("program_header_size", &self.program_header_size())
336 80 : .field("numberof_segments", &self.numberof_segments())
337 80 : .field("section_header_size", &self.section_header_size())
338 80 : .field("numberof_sections", &self.numberof_sections())
339 80 : .field("section_name_table_idx", &self.section_name_table_idx())
340 80 : .finish()
341 80 : }
342 : }
343 :
344 : #[allow(non_camel_case_types)]
345 80 : #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
346 : pub enum Arch {
347 : NONE,
348 : M32,
349 : SPARC,
350 : I386,
351 : M68K,
352 : M88K,
353 : IAMCU,
354 : I860,
355 : MIPS,
356 : S370,
357 : MIPS_RS3_LE,
358 : PARISC,
359 : VPP500,
360 : SPARC32PLUS,
361 : I60,
362 : PPC,
363 : PPC64,
364 : S390,
365 : SPU,
366 : V800,
367 : FR20,
368 : RH32,
369 : RCE,
370 : ARM,
371 : ALPHA,
372 : SH,
373 : SPARCV9,
374 : TRICORE,
375 : ARC,
376 : H8_300,
377 : H8_300H,
378 : H8S,
379 : H8_500,
380 : IA_64,
381 : MIPS_X,
382 : COLDFIRE,
383 : M68HC12,
384 : MMA,
385 : PCP,
386 : NCPU,
387 : NDR1,
388 : STARCORE,
389 : ME16,
390 : ST100,
391 : TINYJ,
392 : X86_64,
393 : PDSP,
394 : PDP10,
395 : PDP11,
396 : FX66,
397 : ST9PLUS,
398 : ST7,
399 : M68HC16,
400 : M68HC11,
401 : M68HC08,
402 : M68HC05,
403 : SVX,
404 : ST19,
405 : VAX,
406 : CRIS,
407 : JAVELIN,
408 : FIREPATH,
409 : ZSP,
410 : MMIX,
411 : HUANY,
412 : PRISM,
413 : AVR,
414 : FR30,
415 : D10V,
416 : D30V,
417 : V850,
418 : M32R,
419 : MN10300,
420 : MN10200,
421 : PJ,
422 : OPENRISC,
423 : ARC_COMPACT,
424 : XTENSA,
425 : VIDEOCORE,
426 : TMM_GPP,
427 : NS32K,
428 : TPC,
429 : SNP1K,
430 : ST200,
431 : IP2K,
432 : MAX,
433 : CR,
434 : F2MC16,
435 : MSP430,
436 : BLACKFIN,
437 : SE_C33,
438 : SEP,
439 : ARCA,
440 : UNICORE,
441 : EXCESS,
442 : DXP,
443 : ALTERA_NIOS2,
444 : CRX,
445 : XGATE,
446 : C166,
447 : M16C,
448 : DSPIC30F,
449 : CE,
450 : M32C,
451 : TSK3000,
452 : RS08,
453 : SHARC,
454 : ECOG2,
455 : SCORE7,
456 : DSP24,
457 : VIDEOCORE3,
458 : LATTICEMICO32,
459 : SE_C17,
460 : TI_C6000,
461 : TI_C2000,
462 : TI_C5500,
463 : MMDSP_PLUS,
464 : CYPRESS_M8C,
465 : R32C,
466 : TRIMEDIA,
467 : HEXAGON,
468 : M8051,
469 : STXP7X,
470 : NDS32,
471 : ECOG1,
472 : //ECOG1X,
473 : MAXQ30,
474 : XIMO16,
475 : MANIK,
476 : CRAYNV2,
477 : RX,
478 : METAG,
479 : MCST_ELBRUS,
480 : ECOG16,
481 : CR16,
482 : ETPU,
483 : SLE9X,
484 : L10M,
485 : K10M,
486 : AARCH64,
487 : AVR32,
488 : STM8,
489 : TILE64,
490 : TILEPRO,
491 : CUDA,
492 : TILEGX,
493 : CLOUDSHIELD,
494 : COREA_1ST,
495 : COREA_2ND,
496 : ARC_COMPACT2,
497 : OPEN8,
498 : RL78,
499 : VIDEOCORE5,
500 : M78KOR,
501 : M56800EX,
502 : BA1,
503 : BA2,
504 : XCORE,
505 : MCHP_PIC,
506 : INTEL205,
507 : INTEL206,
508 : INTEL207,
509 : INTEL208,
510 : INTEL209,
511 : KM32,
512 : KMX32,
513 : KMX16,
514 : KMX8,
515 : KVARC,
516 : CDP,
517 : COGE,
518 : COOL,
519 : NORC,
520 : CSR_KALIMBA,
521 : AMDGPU,
522 : RISCV,
523 : BPF,
524 : CSKY,
525 : LOONGARCH,
526 : UNKNOWN(u32),
527 : }
528 :
529 : impl From<u32> for Arch {
530 80 : fn from(value: u32) -> Self {
531 80 : match value {
532 0 : 0x00000000 => Arch::NONE,
533 0 : 0x00000001 => Arch::M32,
534 0 : 0x00000002 => Arch::SPARC,
535 0 : 0x00000003 => Arch::I386,
536 0 : 0x00000004 => Arch::M68K,
537 0 : 0x00000005 => Arch::M88K,
538 0 : 0x00000006 => Arch::IAMCU,
539 0 : 0x00000007 => Arch::I860,
540 10 : 0x00000008 => Arch::MIPS,
541 0 : 0x00000009 => Arch::S370,
542 0 : 0x0000000a => Arch::MIPS_RS3_LE,
543 0 : 0x0000000f => Arch::PARISC,
544 0 : 0x00000011 => Arch::VPP500,
545 0 : 0x00000012 => Arch::SPARC32PLUS,
546 0 : 0x00000013 => Arch::I60,
547 0 : 0x00000014 => Arch::PPC,
548 0 : 0x00000015 => Arch::PPC64,
549 0 : 0x00000016 => Arch::S390,
550 0 : 0x00000017 => Arch::SPU,
551 0 : 0x00000024 => Arch::V800,
552 0 : 0x00000025 => Arch::FR20,
553 0 : 0x00000026 => Arch::RH32,
554 0 : 0x00000027 => Arch::RCE,
555 0 : 0x00000028 => Arch::ARM,
556 0 : 0x00000029 => Arch::ALPHA,
557 0 : 0x0000002a => Arch::SH,
558 0 : 0x0000002b => Arch::SPARCV9,
559 0 : 0x0000002c => Arch::TRICORE,
560 0 : 0x0000002d => Arch::ARC,
561 0 : 0x0000002e => Arch::H8_300,
562 0 : 0x0000002f => Arch::H8_300H,
563 0 : 0x00000030 => Arch::H8S,
564 0 : 0x00000031 => Arch::H8_500,
565 0 : 0x00000032 => Arch::IA_64,
566 0 : 0x00000033 => Arch::MIPS_X,
567 0 : 0x00000034 => Arch::COLDFIRE,
568 0 : 0x00000035 => Arch::M68HC12,
569 0 : 0x00000036 => Arch::MMA,
570 0 : 0x00000037 => Arch::PCP,
571 0 : 0x00000038 => Arch::NCPU,
572 0 : 0x00000039 => Arch::NDR1,
573 0 : 0x0000003a => Arch::STARCORE,
574 0 : 0x0000003b => Arch::ME16,
575 0 : 0x0000003c => Arch::ST100,
576 0 : 0x0000003d => Arch::TINYJ,
577 50 : 0x0000003e => Arch::X86_64,
578 0 : 0x0000003f => Arch::PDSP,
579 0 : 0x00000040 => Arch::PDP10,
580 0 : 0x00000041 => Arch::PDP11,
581 0 : 0x00000042 => Arch::FX66,
582 0 : 0x00000043 => Arch::ST9PLUS,
583 0 : 0x00000044 => Arch::ST7,
584 0 : 0x00000045 => Arch::M68HC16,
585 0 : 0x00000046 => Arch::M68HC11,
586 0 : 0x00000047 => Arch::M68HC08,
587 0 : 0x00000048 => Arch::M68HC05,
588 0 : 0x00000049 => Arch::SVX,
589 0 : 0x0000004a => Arch::ST19,
590 0 : 0x0000004b => Arch::VAX,
591 0 : 0x0000004c => Arch::CRIS,
592 0 : 0x0000004d => Arch::JAVELIN,
593 0 : 0x0000004e => Arch::FIREPATH,
594 0 : 0x0000004f => Arch::ZSP,
595 0 : 0x00000050 => Arch::MMIX,
596 0 : 0x00000051 => Arch::HUANY,
597 0 : 0x00000052 => Arch::PRISM,
598 0 : 0x00000053 => Arch::AVR,
599 0 : 0x00000054 => Arch::FR30,
600 0 : 0x00000055 => Arch::D10V,
601 0 : 0x00000056 => Arch::D30V,
602 0 : 0x00000057 => Arch::V850,
603 0 : 0x00000058 => Arch::M32R,
604 0 : 0x00000059 => Arch::MN10300,
605 0 : 0x0000005a => Arch::MN10200,
606 0 : 0x0000005b => Arch::PJ,
607 0 : 0x0000005c => Arch::OPENRISC,
608 0 : 0x0000005d => Arch::ARC_COMPACT,
609 0 : 0x0000005e => Arch::XTENSA,
610 0 : 0x0000005f => Arch::VIDEOCORE,
611 0 : 0x00000060 => Arch::TMM_GPP,
612 0 : 0x00000061 => Arch::NS32K,
613 0 : 0x00000062 => Arch::TPC,
614 0 : 0x00000063 => Arch::SNP1K,
615 0 : 0x00000064 => Arch::ST200,
616 0 : 0x00000065 => Arch::IP2K,
617 0 : 0x00000066 => Arch::MAX,
618 0 : 0x00000067 => Arch::CR,
619 0 : 0x00000068 => Arch::F2MC16,
620 0 : 0x00000069 => Arch::MSP430,
621 0 : 0x0000006a => Arch::BLACKFIN,
622 0 : 0x0000006b => Arch::SE_C33,
623 0 : 0x0000006c => Arch::SEP,
624 0 : 0x0000006d => Arch::ARCA,
625 0 : 0x0000006e => Arch::UNICORE,
626 0 : 0x0000006f => Arch::EXCESS,
627 0 : 0x00000070 => Arch::DXP,
628 0 : 0x00000071 => Arch::ALTERA_NIOS2,
629 0 : 0x00000072 => Arch::CRX,
630 0 : 0x00000073 => Arch::XGATE,
631 0 : 0x00000074 => Arch::C166,
632 0 : 0x00000075 => Arch::M16C,
633 0 : 0x00000076 => Arch::DSPIC30F,
634 0 : 0x00000077 => Arch::CE,
635 0 : 0x00000078 => Arch::M32C,
636 0 : 0x00000083 => Arch::TSK3000,
637 0 : 0x00000084 => Arch::RS08,
638 0 : 0x00000085 => Arch::SHARC,
639 0 : 0x00000086 => Arch::ECOG2,
640 0 : 0x00000087 => Arch::SCORE7,
641 0 : 0x00000088 => Arch::DSP24,
642 0 : 0x00000089 => Arch::VIDEOCORE3,
643 0 : 0x0000008a => Arch::LATTICEMICO32,
644 0 : 0x0000008b => Arch::SE_C17,
645 0 : 0x0000008c => Arch::TI_C6000,
646 0 : 0x0000008d => Arch::TI_C2000,
647 0 : 0x0000008e => Arch::TI_C5500,
648 0 : 0x000000a0 => Arch::MMDSP_PLUS,
649 0 : 0x000000a1 => Arch::CYPRESS_M8C,
650 0 : 0x000000a2 => Arch::R32C,
651 0 : 0x000000a3 => Arch::TRIMEDIA,
652 0 : 0x000000a4 => Arch::HEXAGON,
653 0 : 0x000000a5 => Arch::M8051,
654 0 : 0x000000a6 => Arch::STXP7X,
655 0 : 0x000000a7 => Arch::NDS32,
656 0 : 0x000000a8 => Arch::ECOG1,
657 : /*0x000000a8 => Arch::ECOG1X,*/
658 0 : 0x000000a9 => Arch::MAXQ30,
659 0 : 0x000000aa => Arch::XIMO16,
660 0 : 0x000000ab => Arch::MANIK,
661 0 : 0x000000ac => Arch::CRAYNV2,
662 0 : 0x000000ad => Arch::RX,
663 0 : 0x000000ae => Arch::METAG,
664 0 : 0x000000af => Arch::MCST_ELBRUS,
665 0 : 0x000000b0 => Arch::ECOG16,
666 0 : 0x000000b1 => Arch::CR16,
667 0 : 0x000000b2 => Arch::ETPU,
668 0 : 0x000000b3 => Arch::SLE9X,
669 0 : 0x000000b4 => Arch::L10M,
670 0 : 0x000000b5 => Arch::K10M,
671 10 : 0x000000b7 => Arch::AARCH64,
672 0 : 0x000000b9 => Arch::AVR32,
673 0 : 0x000000ba => Arch::STM8,
674 0 : 0x000000bb => Arch::TILE64,
675 0 : 0x000000bc => Arch::TILEPRO,
676 0 : 0x000000be => Arch::CUDA,
677 0 : 0x000000bf => Arch::TILEGX,
678 0 : 0x000000c0 => Arch::CLOUDSHIELD,
679 0 : 0x000000c1 => Arch::COREA_1ST,
680 0 : 0x000000c2 => Arch::COREA_2ND,
681 0 : 0x000000c3 => Arch::ARC_COMPACT2,
682 0 : 0x000000c4 => Arch::OPEN8,
683 0 : 0x000000c5 => Arch::RL78,
684 0 : 0x000000c6 => Arch::VIDEOCORE5,
685 0 : 0x000000c7 => Arch::M78KOR,
686 0 : 0x000000c8 => Arch::M56800EX,
687 0 : 0x000000c9 => Arch::BA1,
688 0 : 0x000000ca => Arch::BA2,
689 0 : 0x000000cb => Arch::XCORE,
690 0 : 0x000000cc => Arch::MCHP_PIC,
691 0 : 0x000000cd => Arch::INTEL205,
692 0 : 0x000000ce => Arch::INTEL206,
693 0 : 0x000000cf => Arch::INTEL207,
694 0 : 0x000000d0 => Arch::INTEL208,
695 0 : 0x000000d1 => Arch::INTEL209,
696 0 : 0x000000d2 => Arch::KM32,
697 0 : 0x000000d3 => Arch::KMX32,
698 0 : 0x000000d4 => Arch::KMX16,
699 0 : 0x000000d5 => Arch::KMX8,
700 0 : 0x000000d6 => Arch::KVARC,
701 0 : 0x000000d7 => Arch::CDP,
702 0 : 0x000000d8 => Arch::COGE,
703 0 : 0x000000d9 => Arch::COOL,
704 0 : 0x000000da => Arch::NORC,
705 0 : 0x000000db => Arch::CSR_KALIMBA,
706 0 : 0x000000e0 => Arch::AMDGPU,
707 0 : 0x000000f3 => Arch::RISCV,
708 0 : 0x000000f7 => Arch::BPF,
709 0 : 0x000000fc => Arch::CSKY,
710 10 : 0x00000102 => Arch::LOONGARCH,
711 0 : _ => Arch::UNKNOWN(value),
712 :
713 : }
714 80 : }
715 : }
716 : impl From<Arch> for u32 {
717 0 : fn from(value: Arch) -> u32 {
718 0 : match value {
719 0 : Arch::NONE => 0x00000000,
720 0 : Arch::M32 => 0x00000001,
721 0 : Arch::SPARC => 0x00000002,
722 0 : Arch::I386 => 0x00000003,
723 0 : Arch::M68K => 0x00000004,
724 0 : Arch::M88K => 0x00000005,
725 0 : Arch::IAMCU => 0x00000006,
726 0 : Arch::I860 => 0x00000007,
727 0 : Arch::MIPS => 0x00000008,
728 0 : Arch::S370 => 0x00000009,
729 0 : Arch::MIPS_RS3_LE => 0x0000000a,
730 0 : Arch::PARISC => 0x0000000f,
731 0 : Arch::VPP500 => 0x00000011,
732 0 : Arch::SPARC32PLUS => 0x00000012,
733 0 : Arch::I60 => 0x00000013,
734 0 : Arch::PPC => 0x00000014,
735 0 : Arch::PPC64 => 0x00000015,
736 0 : Arch::S390 => 0x00000016,
737 0 : Arch::SPU => 0x00000017,
738 0 : Arch::V800 => 0x00000024,
739 0 : Arch::FR20 => 0x00000025,
740 0 : Arch::RH32 => 0x00000026,
741 0 : Arch::RCE => 0x00000027,
742 0 : Arch::ARM => 0x00000028,
743 0 : Arch::ALPHA => 0x00000029,
744 0 : Arch::SH => 0x0000002a,
745 0 : Arch::SPARCV9 => 0x0000002b,
746 0 : Arch::TRICORE => 0x0000002c,
747 0 : Arch::ARC => 0x0000002d,
748 0 : Arch::H8_300 => 0x0000002e,
749 0 : Arch::H8_300H => 0x0000002f,
750 0 : Arch::H8S => 0x00000030,
751 0 : Arch::H8_500 => 0x00000031,
752 0 : Arch::IA_64 => 0x00000032,
753 0 : Arch::MIPS_X => 0x00000033,
754 0 : Arch::COLDFIRE => 0x00000034,
755 0 : Arch::M68HC12 => 0x00000035,
756 0 : Arch::MMA => 0x00000036,
757 0 : Arch::PCP => 0x00000037,
758 0 : Arch::NCPU => 0x00000038,
759 0 : Arch::NDR1 => 0x00000039,
760 0 : Arch::STARCORE => 0x0000003a,
761 0 : Arch::ME16 => 0x0000003b,
762 0 : Arch::ST100 => 0x0000003c,
763 0 : Arch::TINYJ => 0x0000003d,
764 0 : Arch::X86_64 => 0x0000003e,
765 0 : Arch::PDSP => 0x0000003f,
766 0 : Arch::PDP10 => 0x00000040,
767 0 : Arch::PDP11 => 0x00000041,
768 0 : Arch::FX66 => 0x00000042,
769 0 : Arch::ST9PLUS => 0x00000043,
770 0 : Arch::ST7 => 0x00000044,
771 0 : Arch::M68HC16 => 0x00000045,
772 0 : Arch::M68HC11 => 0x00000046,
773 0 : Arch::M68HC08 => 0x00000047,
774 0 : Arch::M68HC05 => 0x00000048,
775 0 : Arch::SVX => 0x00000049,
776 0 : Arch::ST19 => 0x0000004a,
777 0 : Arch::VAX => 0x0000004b,
778 0 : Arch::CRIS => 0x0000004c,
779 0 : Arch::JAVELIN => 0x0000004d,
780 0 : Arch::FIREPATH => 0x0000004e,
781 0 : Arch::ZSP => 0x0000004f,
782 0 : Arch::MMIX => 0x00000050,
783 0 : Arch::HUANY => 0x00000051,
784 0 : Arch::PRISM => 0x00000052,
785 0 : Arch::AVR => 0x00000053,
786 0 : Arch::FR30 => 0x00000054,
787 0 : Arch::D10V => 0x00000055,
788 0 : Arch::D30V => 0x00000056,
789 0 : Arch::V850 => 0x00000057,
790 0 : Arch::M32R => 0x00000058,
791 0 : Arch::MN10300 => 0x00000059,
792 0 : Arch::MN10200 => 0x0000005a,
793 0 : Arch::PJ => 0x0000005b,
794 0 : Arch::OPENRISC => 0x0000005c,
795 0 : Arch::ARC_COMPACT => 0x0000005d,
796 0 : Arch::XTENSA => 0x0000005e,
797 0 : Arch::VIDEOCORE => 0x0000005f,
798 0 : Arch::TMM_GPP => 0x00000060,
799 0 : Arch::NS32K => 0x00000061,
800 0 : Arch::TPC => 0x00000062,
801 0 : Arch::SNP1K => 0x00000063,
802 0 : Arch::ST200 => 0x00000064,
803 0 : Arch::IP2K => 0x00000065,
804 0 : Arch::MAX => 0x00000066,
805 0 : Arch::CR => 0x00000067,
806 0 : Arch::F2MC16 => 0x00000068,
807 0 : Arch::MSP430 => 0x00000069,
808 0 : Arch::BLACKFIN => 0x0000006a,
809 0 : Arch::SE_C33 => 0x0000006b,
810 0 : Arch::SEP => 0x0000006c,
811 0 : Arch::ARCA => 0x0000006d,
812 0 : Arch::UNICORE => 0x0000006e,
813 0 : Arch::EXCESS => 0x0000006f,
814 0 : Arch::DXP => 0x00000070,
815 0 : Arch::ALTERA_NIOS2 => 0x00000071,
816 0 : Arch::CRX => 0x00000072,
817 0 : Arch::XGATE => 0x00000073,
818 0 : Arch::C166 => 0x00000074,
819 0 : Arch::M16C => 0x00000075,
820 0 : Arch::DSPIC30F => 0x00000076,
821 0 : Arch::CE => 0x00000077,
822 0 : Arch::M32C => 0x00000078,
823 0 : Arch::TSK3000 => 0x00000083,
824 0 : Arch::RS08 => 0x00000084,
825 0 : Arch::SHARC => 0x00000085,
826 0 : Arch::ECOG2 => 0x00000086,
827 0 : Arch::SCORE7 => 0x00000087,
828 0 : Arch::DSP24 => 0x00000088,
829 0 : Arch::VIDEOCORE3 => 0x00000089,
830 0 : Arch::LATTICEMICO32 => 0x0000008a,
831 0 : Arch::SE_C17 => 0x0000008b,
832 0 : Arch::TI_C6000 => 0x0000008c,
833 0 : Arch::TI_C2000 => 0x0000008d,
834 0 : Arch::TI_C5500 => 0x0000008e,
835 0 : Arch::MMDSP_PLUS => 0x000000a0,
836 0 : Arch::CYPRESS_M8C => 0x000000a1,
837 0 : Arch::R32C => 0x000000a2,
838 0 : Arch::TRIMEDIA => 0x000000a3,
839 0 : Arch::HEXAGON => 0x000000a4,
840 0 : Arch::M8051 => 0x000000a5,
841 0 : Arch::STXP7X => 0x000000a6,
842 0 : Arch::NDS32 => 0x000000a7,
843 0 : Arch::ECOG1 => 0x000000a8,
844 : /*Arch::ECOG1X => 0x000000a8,*/
845 0 : Arch::MAXQ30 => 0x000000a9,
846 0 : Arch::XIMO16 => 0x000000aa,
847 0 : Arch::MANIK => 0x000000ab,
848 0 : Arch::CRAYNV2 => 0x000000ac,
849 0 : Arch::RX => 0x000000ad,
850 0 : Arch::METAG => 0x000000ae,
851 0 : Arch::MCST_ELBRUS => 0x000000af,
852 0 : Arch::ECOG16 => 0x000000b0,
853 0 : Arch::CR16 => 0x000000b1,
854 0 : Arch::ETPU => 0x000000b2,
855 0 : Arch::SLE9X => 0x000000b3,
856 0 : Arch::L10M => 0x000000b4,
857 0 : Arch::K10M => 0x000000b5,
858 0 : Arch::AARCH64 => 0x000000b7,
859 0 : Arch::AVR32 => 0x000000b9,
860 0 : Arch::STM8 => 0x000000ba,
861 0 : Arch::TILE64 => 0x000000bb,
862 0 : Arch::TILEPRO => 0x000000bc,
863 0 : Arch::CUDA => 0x000000be,
864 0 : Arch::TILEGX => 0x000000bf,
865 0 : Arch::CLOUDSHIELD => 0x000000c0,
866 0 : Arch::COREA_1ST => 0x000000c1,
867 0 : Arch::COREA_2ND => 0x000000c2,
868 0 : Arch::ARC_COMPACT2 => 0x000000c3,
869 0 : Arch::OPEN8 => 0x000000c4,
870 0 : Arch::RL78 => 0x000000c5,
871 0 : Arch::VIDEOCORE5 => 0x000000c6,
872 0 : Arch::M78KOR => 0x000000c7,
873 0 : Arch::M56800EX => 0x000000c8,
874 0 : Arch::BA1 => 0x000000c9,
875 0 : Arch::BA2 => 0x000000ca,
876 0 : Arch::XCORE => 0x000000cb,
877 0 : Arch::MCHP_PIC => 0x000000cc,
878 0 : Arch::INTEL205 => 0x000000cd,
879 0 : Arch::INTEL206 => 0x000000ce,
880 0 : Arch::INTEL207 => 0x000000cf,
881 0 : Arch::INTEL208 => 0x000000d0,
882 0 : Arch::INTEL209 => 0x000000d1,
883 0 : Arch::KM32 => 0x000000d2,
884 0 : Arch::KMX32 => 0x000000d3,
885 0 : Arch::KMX16 => 0x000000d4,
886 0 : Arch::KMX8 => 0x000000d5,
887 0 : Arch::KVARC => 0x000000d6,
888 0 : Arch::CDP => 0x000000d7,
889 0 : Arch::COGE => 0x000000d8,
890 0 : Arch::COOL => 0x000000d9,
891 0 : Arch::NORC => 0x000000da,
892 0 : Arch::CSR_KALIMBA => 0x000000db,
893 0 : Arch::AMDGPU => 0x000000e0,
894 0 : Arch::RISCV => 0x000000f3,
895 0 : Arch::BPF => 0x000000f7,
896 0 : Arch::CSKY => 0x000000fc,
897 0 : Arch::LOONGARCH => 0x00000102,
898 0 : Arch::UNKNOWN(value) => value,
899 :
900 : }
901 0 : }
902 : }
|