diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2023-01-30 22:29:40 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2023-01-30 22:29:40 +0100 |
commit | 2b0d09a2c446765b8d952b648596585c456107ba (patch) | |
tree | efad9caf226f67611333f0fdb45b2213ad0afccb /examples | |
parent | 2b1165a8cfffe93519dc6ccfd3434b6db33ea101 (diff) | |
download | elfload-2b0d09a2c446765b8d952b648596585c456107ba.tar.gz elfload-2b0d09a2c446765b8d952b648596585c456107ba.zip |
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.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ls.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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 { '-' } ); } } |