pub struct DynamicSectionAccessor<'a> { /* private fields */ }
Expand description
A section data accessor intended to dynamic tables
For example:
use std::fs::File;
use std::io;
use std::io::{BufReader, Error};
use elfio::Elfio;
fn main() -> io::Result<()> {
let elf_file = File::open("tests/files/hello_32")?;
let mut reader = BufReader::new(elf_file);
let mut elf = Elfio::new();
elf.load(&mut reader)?;
let section = match elf.get_section_by_name(&".dynamic") {
Some(s) => s,
None => return Err(Error::new(io::ErrorKind::Other, "section not found")),
};
let dyns = elfio::DynamicSectionAccessor::new(&elf, section);
assert_eq!(dyns.get_entries_num(), 20);
// Dynamic section at offset 0x4a0 contains 20 entries:
// Tag Type Name/Value
// 0x00000001 (NEEDED) Shared library: [libc.so.6]
// 0x0000000c (INIT) 0x804824c
// 0x0000000d (FINI) 0x8048458
// 0x6ffffef5 (GNU_HASH) 0x8048148
let dynamic = dyns.get_entry(3).unwrap();
assert_eq!(dynamic.tag, 0x6ffffef5);
assert_eq!(dynamic.value, 0x8048148);
Ok(())
}
Implementations§
Source§impl<'a> DynamicSectionAccessor<'a>
impl<'a> DynamicSectionAccessor<'a>
Sourcepub fn new(
elfio: &'a Elfio,
section: &'a dyn ElfSectionTrait,
) -> DynamicSectionAccessor<'a>
pub fn new( elfio: &'a Elfio, section: &'a dyn ElfSectionTrait, ) -> DynamicSectionAccessor<'a>
Creates a new instance of the relocation table accessor
Sourcepub fn get_entries_num(&self) -> ElfXword
pub fn get_entries_num(&self) -> ElfXword
Returns number of symbols
Auto Trait Implementations§
impl<'a> Freeze for DynamicSectionAccessor<'a>
impl<'a> !RefUnwindSafe for DynamicSectionAccessor<'a>
impl<'a> !Send for DynamicSectionAccessor<'a>
impl<'a> !Sync for DynamicSectionAccessor<'a>
impl<'a> Unpin for DynamicSectionAccessor<'a>
impl<'a> !UnwindSafe for DynamicSectionAccessor<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more