Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / arch / x86 / exec / elf32.c
diff --git a/lunaix-os/arch/x86/exec/elf32.c b/lunaix-os/arch/x86/exec/elf32.c
new file mode 100644 (file)
index 0000000..f3bd47f
--- /dev/null
@@ -0,0 +1,13 @@
+#include <lunaix/exebi/elf.h>
+
+#define EM_386 3
+
+int
+elf_check_arch(const struct elf* elf)
+{
+    const struct elf_ehdr* ehdr = &elf->eheader;
+
+    return *(u32_t*)(ehdr->e_ident) == ELFMAGIC_LE &&
+           ehdr->e_ident[EI_CLASS] == ELFCLASS32 &&
+           ehdr->e_ident[EI_DATA] == ELFDATA2LSB && ehdr->e_machine == EM_386;
+}
\ No newline at end of file