1// Derived from code in LLVM, which is:
2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3// See https://llvm.org/LICENSE.txt for license information.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
6#[derive(PartialEq, Eq, Copy, Clone, Debug)]
7#[repr(u16)]
8#[allow(clippy::upper_case_acronyms)]
9pub enum MachineTypes {
10 AMD64 = 0x8664,
11 ARMNT = 0x1C4,
12 ARM64 = 0xAA64,
13 ARM64EC = 0xA641,
14 ARM64X = 0xA64E,
15 I386 = 0x14C,
16}
17
18impl From<MachineTypes> for u16 {
19 fn from(val: MachineTypes) -> Self {
20 val as u16
21 }
22}
23
24pub fn is_arm64ec(machine: MachineTypes) -> bool {
25 machine == MachineTypes::ARM64EC || machine == MachineTypes::ARM64X
26}
27
28pub fn is_any_arm64(machine: MachineTypes) -> bool {
29 machine == MachineTypes::ARM64 || is_arm64ec(machine)
30}
31
32pub fn is_64_bit(machine: MachineTypes) -> bool {
33 machine == MachineTypes::AMD64 || is_any_arm64(machine)
34}
35
36#[derive(PartialEq, Eq, Copy, Clone)]
37#[repr(u16)]
38pub enum ImportType {
39 /// An executable code symbol.
40 Code = 0,
41 /// A data symbol.
42 Data = 1,
43 /// A constant value.
44 Const = 2,
45}
46
47impl From<ImportType> for u16 {
48 fn from(val: ImportType) -> Self {
49 val as u16
50 }
51}
52
53#[derive(PartialEq, Eq, Copy, Clone)]
54#[repr(u16)]
55pub enum ImportNameType {
56 /// Import is by ordinal. This indicates that the value in the Ordinal/Hint
57 /// field of the import header is the import's ordinal. If this constant is
58 /// not specified, then the Ordinal/Hint field should always be interpreted
59 /// as the import's hint.
60 Ordinal = 0,
61 /// The import name is identical to the public symbol name
62 Name = 1,
63 /// The import name is the public symbol name, but skipping the leading ?,
64 /// @, or optionally _.
65 NameNoprefix = 2,
66 /// The import name is the public symbol name, but skipping the leading ?,
67 /// @, or optionally _, and truncating at the first @.
68 NameUndecorate = 3,
69 /// The import name is specified as a separate string in the import library
70 /// object file.
71 NameExportas = 4,
72}
73
74impl From<ImportNameType> for u16 {
75 fn from(val: ImportNameType) -> Self {
76 val as u16
77 }
78}
79

Provided by KDAB

Privacy Policy
Learn Rust with the experts
Find out more