blob: 0409ae2e874eb9fe3853da5c3338486a0780390a (
plain) (
blame)
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
|
use elfload::Elf;
fn main() {
let ls_bytes = include_bytes!("/bin/ls");
match Elf::<4>::parse(ls_bytes) {
Ok(elf) => {
println!(
"ELF machine: {:?} entry: 0x{:08x}",
elf.machine(),
elf.entry()
);
for l in elf.load_segments() {
println!(
"LOAD: vaddr: 0x{:08x} zero_pad: {:8} {}{}{}",
l.vaddr,
l.zero_pad,
if l.x { 'X' } else { '-' },
if l.w { 'W' } else { '-' },
if l.r { 'R' } else { '-' }
);
}
}
Err(e) => {
eprintln!("Parsing /bin/ls ELF file failed with {:?}.", e);
}
}
}
|