extern crate elf;
use std::path::Path;
pub type File = elf::File;
pub fn open<P>(path: P) -> File
where P: AsRef<Path>
{
let path = path.as_ref();
elf::File::open_path(path).expect("Could not open file")
}
pub fn get_section<'a>(file: &'a File, section_name: &str) -> Option<&'a [u8]> {
file.sections
.iter()
.find(|s| s.shdr.name == section_name)
.map(|s| &s.data[..])
}
pub fn is_little_endian(file: &File) -> bool {
match file.ehdr.data {
elf::types::ELFDATA2LSB => true,
elf::types::ELFDATA2MSB => false,
otherwise => panic!("Unknown endianity: {}", otherwise),
}
}