pub struct StringSectionAccessor<'a> { /* private fields */ }
Expand description
A section data accessor intended to string tables
For example:
use std::fs::File;
use std::io;
use std::io::{BufReader, Error};
use elfio::{Elfio, StringSectionAccessor}; // Uncomment in the real code
fn main() -> io::Result<()> {
let elf_file = File::open("tests/files/hello_64")?;
let mut file_reader = BufReader::new(elf_file);
let mut elf = elfio::Elfio::new();
elf.load(&mut file_reader)?;
let section = elf.get_section_by_name(".strtab");
match section {
Some(s) => {
let strtab = StringSectionAccessor::new(&elf, s);
println!("{}", strtab.get_string(1));
}
None => return Err(Error::new(io::ErrorKind::Other, "section not found")),
}
Ok(())
}
Implementations§
Source§impl<'a> StringSectionAccessor<'a>
impl<'a> StringSectionAccessor<'a>
Sourcepub fn new(
elfio: &'a Elfio,
section: &'a dyn ElfSectionTrait,
) -> StringSectionAccessor<'a>
pub fn new( elfio: &'a Elfio, section: &'a dyn ElfSectionTrait, ) -> StringSectionAccessor<'a>
Creates a new instance of the string table accessor
Sourcepub fn get_string(&self, index: ElfWord) -> String
pub fn get_string(&self, index: ElfWord) -> String
Returns a string from string table by its index
Auto Trait Implementations§
impl<'a> Freeze for StringSectionAccessor<'a>
impl<'a> !RefUnwindSafe for StringSectionAccessor<'a>
impl<'a> !Send for StringSectionAccessor<'a>
impl<'a> !Sync for StringSectionAccessor<'a>
impl<'a> Unpin for StringSectionAccessor<'a>
impl<'a> !UnwindSafe for StringSectionAccessor<'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