mod structs; use crate::structs::ElfHeader; #[repr(C)] #[derive(Debug)] struct Elf { header: &'static ElfHeader, } impl Elf { pub fn new(bytes: &[u8]) -> Elf { let header = unsafe { &*(bytes.as_ptr() as *const ElfHeader) }; assert_eq!(&header.ident.magic, b"\x7fELF"); Elf { header } } } fn main() { let data = include_bytes!("../elf"); let elf = Elf::new(&data[..]); println!("{:?}", elf); }