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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//! # LIEF
//!
//! 
//!
//! This package provides Rust bindings for [LIEF](https://lief.re). It exposes most of the
//! LIEF API to **read** these formats:
//! - ELF
//! - PE
//! - Mach-O
//!
//! The bindings require at least Rust version **1.85.0** with the 2024 edition and support:
//! - Windows x86-64 (support `/MT` and `/MD` linking)
//! - Windows arm64 (support `/MT` and `/MD` linking)
//! - Linux x86-64 (+gnu/musl): Ubuntu 21.10+, Debian 12+, Fedora 35+, CentOS/RHEL 9+
//! - Linux i686 (+gnu/musl): Ubuntu 19.10+, Debian 10+
//! - Linux aarch64 (+gnu/musl): Ubuntu 21.10+, Debian 12+
//! - Android: API 30+
//! - macOS (`x86-64` and `aarch64` with at least OSX Big Sur: 11.0)
//! - iOS (`aarch64`): 12+
//!
//! ## Getting Started
//!
//! ```toml
//! [package]
//! name = "my-awesome-project"
//! version = "0.0.1"
//! edition = "2024"
//!
//! [dependencies]
//! # For nightly
//! lief = { git = "https://github.com/lief-project/LIEF", branch = "main" }
//! # For releases
//! lief = 1.0.0
//! ```
//!
//! ```rust
//! fn main() {
//! let path = std::env::args().last().unwrap();
//! let mut file = std::fs::File::open(path).expect("Can't open the file");
//! match lief::Binary::from(&mut file) {
//! Some(lief::Binary::ELF(elf)) => {
//! // Process ELF file
//! },
//! Some(lief::Binary::PE(pe)) => {
//! // Process PE file
//! },
//! Some(lief::Binary::MachO(macho)) => {
//! // Process Mach-O file (including FatMachO)
//! },
//! Some(lief::Binary::COFF(coff)) => {
//! // Process coff file
//! },
//! None => {
//! // Parsing error
//! }
//! }
//! return;
//! }
//! ```
//!
//! Note that the [`generic`] module implements the different traits shared by different structure
//! of executable formats (symbols, relocations, ...)
//!
//! ## Additional Information
//!
//! For more details about the install procedure and the configuration, please check:
//! <https://lief.re/doc/latest/api/rust/index.html>
/// Executable formats generic traits (LIEF's abstract layer)
/// Module for LIEF's error
pub use Binary;
pub use ;
pub use Error;
pub use DebugInfo;
pub use Range;
pub use DebugLocation;
pub use DeclOpt;
/// Whether it is an extended version of LIEF
/// Return details about the extended version
/// Return the extended version
/// Return the current version
/// Try to demangle the given input.
///
/// This function requires the extended version of LIEF
/// Hexdump the provided buffer.
///
/// For instance:
///
/// ```text
/// +---------------------------------------------------------------------+
/// | 88 56 05 00 00 00 00 00 00 00 00 00 22 58 05 00 | .V.........."X.. |
/// | 10 71 02 00 78 55 05 00 00 00 00 00 00 00 00 00 | .q..xU.......... |
/// | 68 5c 05 00 00 70 02 00 00 00 00 00 00 00 00 00 | h\...p.......... |
/// | 00 00 00 00 00 00 00 00 00 00 00 00 | ............ |
/// +---------------------------------------------------------------------+
/// ```
/// Same as [`dump`] but with a limit on the number of bytes to dump