pub struct RelocationSectionAccessor<'a> { /* private fields */ }
Expand description
A section data accessor intended to relocation 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_64")?;
let mut reader = BufReader::new(elf_file);
let mut elf = Elfio::new();
elf.load(&mut reader)?;
let section = match elf.get_section_by_name(&".rela.plt") {
Some(s) => s,
None => return Err(Error::new(io::ErrorKind::Other, "section not found")),
};
let relocs = elfio::RelocationSectionAccessor::new(&elf, section);
assert_eq!(relocs.get_entries_num(), 2);
// 000000600850 000300000007 R_X86_64_JUMP_SLO 0000000000000000 __libc_start_main@GLIBC_2.2.5 + 0
let rel = relocs.get_entry(1).unwrap();
assert_eq!(rel.offset, 0x000000600850);
assert_eq!(rel.symbol, 3);
assert_eq!(rel.rtype, 7);
assert_eq!(rel.addend, Some(0));
Ok(())
}
Implementations§
Source§impl<'a> RelocationSectionAccessor<'a>
impl<'a> RelocationSectionAccessor<'a>
Sourcepub fn new(
elfio: &'a Elfio,
section: &'a dyn ElfSectionTrait,
) -> RelocationSectionAccessor<'a>
pub fn new( elfio: &'a Elfio, section: &'a dyn ElfSectionTrait, ) -> RelocationSectionAccessor<'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
Sourcepub fn get_entry(&self, index: ElfXword) -> Option<Relocation>
pub fn get_entry(&self, index: ElfXword) -> Option<Relocation>
Get a relocation entry by its index
Auto Trait Implementations§
impl<'a> Freeze for RelocationSectionAccessor<'a>
impl<'a> !RefUnwindSafe for RelocationSectionAccessor<'a>
impl<'a> !Send for RelocationSectionAccessor<'a>
impl<'a> !Sync for RelocationSectionAccessor<'a>
impl<'a> Unpin for RelocationSectionAccessor<'a>
impl<'a> !UnwindSafe for RelocationSectionAccessor<'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