Struct elfio::ArraySectionAccessor[][src]

pub struct ArraySectionAccessor<'a> { /* fields omitted */ }
Expand description

A section data accessor intended to array tables. The accessor is useful for manipulation of such sections as .ctors, .dtors, .init_array and .fini_array

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(&".ctors") {
        Some(s) => s,
        None => return Err(Error::new(io::ErrorKind::Other, "section not found")),
    };

    let array = elfio::ArraySectionAccessor::new(&elf, section);

    assert_eq!(array.get_entries_num(), 2);

    let element = array.get_entry(0).unwrap();
    assert_eq!(element.value, 0xFFFFFFFF);
    let element = array.get_entry(1).unwrap();
    assert_eq!(element.value, 0x00000000);

    Ok(())
}

Implementations

Creates a new instance of the relocation table accessor

Returns number of symbols

pub fn get_entry(&self, index: ElfXword) -> Option<Array>

Get a relocation entry by its index

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.