X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/b6ff3c7dbab3f40d03389808d95ac27d416c35e3..7c7b5f05d39b7739d990f71256a2267ec67a6913:/lunaix-os/kernel/exe/elf32/elf32bfmt.c diff --git a/lunaix-os/kernel/exe/elf32/elf32bfmt.c b/lunaix-os/kernel/exe/elf32/elf32bfmt.c index 1079b06..3fb671c 100644 --- a/lunaix-os/kernel/exe/elf32/elf32bfmt.c +++ b/lunaix-os/kernel/exe/elf32/elf32bfmt.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -32,7 +31,7 @@ elf32_open(struct elf32* elf, const char* path) } int -elf32_openat(struct elf32* elf, void* elf_vfile) +elf32_openat(struct elf32* elf, const void* elf_vfile) { int status = 0; elf->pheaders = NULL; @@ -164,12 +163,19 @@ elf32_read_phdr(struct elf32* elf) } int -elf32_check_exec(const struct elf32* elf) +elf32_check_exec(const struct elf32* elf, int type) { - struct elf32_ehdr* ehdr = &elf->eheader; + const struct elf32_ehdr* ehdr = &elf->eheader; + + return (ehdr->e_entry) && ehdr->e_type == type; +} + +int +elf32_check_arch(const struct elf32* elf) +{ + const struct elf32_ehdr* ehdr = &elf->eheader; 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; -} + ehdr->e_ident[EI_DATA] == ELFDATA2LSB && ehdr->e_machine == EM_386; +} \ No newline at end of file