Skip to main content

elf_machine

Function elf_machine 

Source
pub fn elf_machine(bytes: &[u8]) -> Option<u16>
Expand description

The e_machine field of an ELF header, or None if bytes does not start with one.

Twenty bytes: the four-byte magic, EI_DATA at offset 5 deciding the byte order, then the two-byte e_machine at 18. Reading the byte order rather than assuming little is not pedantry: a big-endian binary would otherwise report machine 0xB700 and be rejected with a number nobody can look up.