Struct elfio::NoteSectionAccessor[][src]

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

A section data accessor intended to note sections

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

    let notes = elfio::NoteSectionAccessor::new(&elf, section);

    assert_eq!(notes.get_notes_num(), 1);

    let note = notes.get_note(0).unwrap();
    assert_eq!(note.ntype, 1);
    assert_eq!(note.name, "GNU");
    assert_eq!(
        note.description,
        vec![0u8, 0u8, 0u8, 0u8, 2u8, 0u8, 0u8, 0u8, 6u8, 0u8, 0u8, 0u8, 9u8, 0u8, 0u8, 0u8]
    );

    Ok(())
}

Implementations

Creates a new instance of the symbol table accessor

Returns number of notes in the section

Returns a note by its ordinal number

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.