Module note

Source
Expand description

Parsing ELF notes: .note.*, SHT_NOTE, PT_NOTE

Example for getting the GNU ABI-tag note:

use elf::ElfBytes;
use elf::endian::AnyEndian;
use elf::note::Note;
use elf::note::NoteGnuAbiTag;

let path = std::path::PathBuf::from("sample-objects/basic.x86_64");
let file_data = std::fs::read(path).expect("Could not read file.");
let slice = file_data.as_slice();
let file = ElfBytes::<AnyEndian>::minimal_parse(slice).expect("Open test1");

let shdr = file
    .section_header_by_name(".note.ABI-tag")
    .expect("section table should be parseable")
    .expect("file should have a .note.ABI-tag section");

let notes: Vec<_> = file
    .section_data_as_notes(&shdr)
    .expect("Should be able to get note section data")
    .collect();
assert_eq!(
    notes[0],
    Note::GnuAbiTag(NoteGnuAbiTag {
        os: 0,
        major: 2,
        minor: 6,
        subminor: 32
    })
);

Structs§

NoteAny
Contains the raw fields found in any ELF note. Used for notes that we don’t know how to parse into more specific types.
NoteGnuAbiTag
Contains four 4-byte integers. The first 4-byte integer specifies the os. The second, third, and fourth 4-byte integers contain the earliest compatible kernel version. For example, if the 3 integers are 6, 0, and 7, this signifies a 6.0.7 kernel.
NoteGnuBuildId
Contains a build ID note which is unique among the set of meaningful contents for ELF files and identical when the output file would otherwise have been identical. This is a zero-copy type which merely contains a slice of the note data from which it was parsed.
NoteIterator

Enums§

Note
This enum contains parsed Note variants which can be matched on