X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/74926d2db1d9f3228acdfca03013a8ba0ac1d8c0..313093773e81eb89ad3c44b048a79bbcd6e94099:/lunaix-os/includes/lunaix/elf.h diff --git a/lunaix-os/includes/lunaix/elf.h b/lunaix-os/includes/lunaix/elf.h index ec4196b..f61fa96 100644 --- a/lunaix-os/includes/lunaix/elf.h +++ b/lunaix-os/includes/lunaix/elf.h @@ -23,6 +23,7 @@ typedef unsigned int elf32_wrd_t; #define EV_CURRENT 1 +// [0x7f, 'E', 'L', 'F'] #define ELFMAGIC 0x464c457fU #define ELFCLASS32 1 #define ELFCLASS64 2 @@ -68,8 +69,9 @@ struct elf32_phdr static inline int elf_check_exec(struct elf32_ehdr* ehdr) { - return (*(u32_t*)(ehdr->e_ident) == ELFMAGIC) || - ehdr->e_ident[EI_CLASS] == ELFCLASS32 || - ehdr->e_ident[EI_DATA] == ELFDATA2LSB || ehdr->e_type == ET_EXEC; + 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; } #endif /* __LUNAIX_ELF_H */