fix dependency check logic cause config always disabled
[lunaix-os.git] / lunaix-os / kernel / exe / elf-generic / elfbfmt.c
index d7b09f1d7ccd76e20b2f44791d90f2db95a5217e..575ff3f8acf60b7445933c2aeb6e1e2420a6652f 100644 (file)
@@ -24,6 +24,10 @@ elf_do_open(struct elf* elf, struct v_file* elf_file)
         return status;
     }
 
+    if (!elf_check_arch(elf)) {
+        return EINVAL;
+    }
+
     if ((status = elf_read_phdr(elf)) < 0) {
         elf_close(elf);
         return status;
@@ -32,7 +36,7 @@ elf_do_open(struct elf* elf, struct v_file* elf_file)
     return 0;
 }
 
-defualt int
+_default int
 elf_open(struct elf* elf, const char* path)
 {
     struct v_dnode* elfdn;
@@ -50,7 +54,7 @@ elf_open(struct elf* elf, const char* path)
     return elf_do_open(elf, elffile);
 }
 
-defualt int
+_default int
 elf_openat(struct elf* elf, void* elf_vfile)
 {
     // so the ref count kept in sync
@@ -58,7 +62,7 @@ elf_openat(struct elf* elf, void* elf_vfile)
     return elf_do_open(elf, elf_vfile);
 }
 
-defualt int
+_default int
 elf_close(struct elf* elf)
 {
     if (elf->pheaders) {
@@ -74,7 +78,7 @@ elf_close(struct elf* elf)
     return 0;
 }
 
-defualt int
+_default int
 elf_static_linked(const struct elf* elf)
 {
     for (size_t i = 0; i < elf->eheader.e_phnum; i++) {
@@ -86,7 +90,7 @@ elf_static_linked(const struct elf* elf)
     return 1;
 }
 
-defualt size_t
+_default size_t
 elf_loadable_memsz(const struct elf* elf)
 {
     // XXX: Hmmmm, I am not sure if we need this. This is designed to be handy
@@ -105,7 +109,7 @@ elf_loadable_memsz(const struct elf* elf)
     return sz;
 }
 
-defualt int
+_default int
 elf_find_loader(const struct elf* elf, char* path_out, size_t len)
 {
     int retval = NO_LOADER;
@@ -135,7 +139,7 @@ elf_find_loader(const struct elf* elf, char* path_out, size_t len)
     return retval;
 }
 
-defualt int
+_default int
 elf_read_ehdr(struct elf* elf)
 {
     struct v_file* elfile = (struct v_file*)elf->elf_file;
@@ -143,7 +147,7 @@ elf_read_ehdr(struct elf* elf)
     return elf_read(elfile, (void*)&elf->eheader, 0, SIZE_EHDR);
 }
 
-defualt int
+_default int
 elf_read_phdr(struct elf* elf)
 {
     int status = 0;
@@ -170,7 +174,7 @@ elf_read_phdr(struct elf* elf)
     return entries;
 }
 
-defualt int
+_default int
 elf_check_exec(const struct elf* elf, int type)
 {
     const struct elf_ehdr* ehdr = &elf->eheader;
@@ -178,7 +182,7 @@ elf_check_exec(const struct elf* elf, int type)
     return (ehdr->e_entry) && ehdr->e_type == type;
 }
 
-defualt int
+_default int
 elf_check_arch(const struct elf* elf)
 {
     const struct elf_ehdr* ehdr = &elf->eheader;