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
pub mod file;
pub mod header;
pub mod relocation;
pub mod section;
pub mod symbol;
pub mod segment;
#[allow(unused)]
pub type Elf32Half = u16;
pub type Elf64Half = u16;
pub type Elf32Word = u32;
pub type Elf64Word = u32;
pub type Elf32Sword = i32;
pub type Elf64Sword = i32;
pub type Elf32Xword = u64;
pub type Elf64Xword = u64;
pub type Elf32Sxword = i64;
pub type Elf64Sxword = i64;
pub type Elf32Addr = u32;
pub type Elf64Addr = u64;
pub type Elf32Off = u32;
pub type Elf64Off = u64;
pub type Elf32Section = u16;
pub type Elf64Section = u16;
pub type Elf32Versym = Elf32Half;
pub type Elf64Versym = Elf64Half;
#[cfg(test)]
mod file_tests {
use super::*;
#[test]
fn construct_file_test() {
let ehdr: header::Ehdr64 = Default::default();
let elf_file = file::ELF64::new(ehdr);
assert_eq!(elf_file.section_number(), 0);
}
}
#[cfg(test)]
mod elf_header_tests {
use super::*;
#[test]
fn construct_identification_test() {
let mut ehdr: header::Ehdr64 = Default::default();
ehdr.set_class(header::ELFCLASS::CLASS64);
ehdr.set_data(header::ELFDATA::DATA2LSB);
ehdr.set_version(header::ELFVERSION::VERSIONCURRENT);
ehdr.set_osabi(header::ELFOSABI::SYSV);
assert_eq!(
ehdr.get_identification(),
0x7f454c46020101000000000000000000
);
ehdr.set_elf_type(header::ELFTYPE::EXEC);
assert_eq!(ehdr.get_elf_type(), header::ELFTYPE::EXEC);
}
#[test]
fn set_elf_machine_architecture_test() {
let mut ehdr: header::Ehdr64 = Default::default();
ehdr.set_machine(header::ELFMACHINE::EMX8664);
assert_eq!(ehdr.get_machine(), header::ELFMACHINE::EMX8664);
}
}