From 2b0d09a2c446765b8d952b648596585c456107ba Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Mon, 30 Jan 2023 22:29:40 +0100 Subject: move from const generic to iterator approach This implies that we parse the phdr every time when we iterator over them however it also gives the flexibility of not providing an upper bound of supported load segments during compile time. Trading flexibility vs potential repetitive work is totally fine as in use cases this crate is used, the phdrs are usually iterated once or twice. --- examples/ls.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/ls.rs b/examples/ls.rs index 0409ae2..d2cd0a2 100644 --- a/examples/ls.rs +++ b/examples/ls.rs @@ -3,7 +3,7 @@ use elfload::Elf; fn main() { let ls_bytes = include_bytes!("/bin/ls"); - match Elf::<4>::parse(ls_bytes) { + match Elf::parse(ls_bytes) { Ok(elf) => { println!( "ELF machine: {:?} entry: 0x{:08x}", @@ -13,11 +13,11 @@ fn main() { 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 { '-' } + l.vaddr(), + l.zero_padding(), + if l.exec() { 'X' } else { '-' }, + if l.write() { 'W' } else { '-' }, + if l.read() { 'R' } else { '-' } ); } } -- cgit v1.2.3