+ elf->pheaders = phdrs;
+ return entries;
+}
+
+int
+elf32_check_exec(const struct elf32* elf)
+{
+ struct elf32_ehdr* ehdr = elf->pheaders;
+
+ return *(u32_t*)(ehdr->e_ident) == ELFMAGIC &&
+ ehdr->e_ident[EI_CLASS] == ELFCLASS32 &&
+ ehdr->e_ident[EI_DATA] == ELFDATA2LSB && ehdr->e_type == ET_EXEC &&
+ ehdr->e_machine == EM_386;
+}
+
+int
+elf32_load(struct load_context* ldctx, const struct elf32* elf)
+{
+ int err = 0;
+
+ struct v_file* elfile = (struct v_file*)elf->elf_file;
+
+ for (size_t i = 0; i < elf->eheader.e_phnum && !err; i++) {
+ struct elf32_phdr* phdr = &elf->pheaders[i];
+
+ if (phdr->p_type == PT_LOAD) {
+ if (phdr->p_align != PG_SIZE) {
+ // surprising alignment!
+ err = ENOEXEC;
+ continue;
+ }
+
+ err = elf_map_segment(ldctx, elf, phdr);
+ }
+ // TODO Handle relocation
+ }