ELF & ABI
ELF parsing and the OS/ABI detection that selects a process personality during exec().
src/elf.rs
ELF executables
A minimal, zero-copy ELF reader used by the kernel loader. It validates the ELF magic, class (32- vs 64-bit) and architecture, then exposes iterators over sections, program-header segments, and the symbol table.
The reader borrows the raw image (&[u8]) and reinterprets header records in place — no parsing into owned structures, no allocation beyond error strings. This keeps it usable very early in boot.
Relationship to personalities
The byte e_ident[EI_OSABI] in the ELF header is the primary signal used to pick a process [crate::syscall_handler::Personality] during exec() (see the Zig helper personality.fromElfOsAbi). ELFOSABI_NONE (0) and ELFOSABI_LINUX (3) map to the Linux personality; the various BSD OS/ABI values map to their respective personalities; anything unknown falls back to the native kernel ABI.
Elf struct
struct Elf { /* … */ }An ELF executable
Elf<'a>::from fn
fn from(data : &'a [u8]) -> Result<Elf<'a>, String>Create a ELF executable from data
Elf<'a>::sections fn
fn sections(&'a self) -> ElfSections<'a>Iterate the ELF section headers (e_shnum entries at e_shoff).
Elf<'a>::symbols fn
fn symbols(&'a self) -> Option<ElfSymbols<'a>>Return an iterator over the symbol table (SHT_SYMTAB), if present.
ElfSections struct
struct ElfSections { /* … */ }Iterator over an ELF image's section headers.
ElfSegments struct
struct ElfSegments { /* … */ }Iterator over an ELF image's program-header segments (the load map).
ElfSymbols struct
struct ElfSymbols { /* … */ }Iterator over the entries of an ELF symbol table section.