git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix dependency check logic cause config always disabled
[lunaix-os.git]
/
lunaix-os
/
kernel
/
exe
/
elf-generic
/
elfbfmt.c
diff --git
a/lunaix-os/kernel/exe/elf-generic/elfbfmt.c
b/lunaix-os/kernel/exe/elf-generic/elfbfmt.c
index d7b09f1d7ccd76e20b2f44791d90f2db95a5217e..575ff3f8acf60b7445933c2aeb6e1e2420a6652f 100644
(file)
--- a/
lunaix-os/kernel/exe/elf-generic/elfbfmt.c
+++ b/
lunaix-os/kernel/exe/elf-generic/elfbfmt.c
@@
-24,6
+24,10
@@
elf_do_open(struct elf* elf, struct v_file* elf_file)
return status;
}
return status;
}
+ if (!elf_check_arch(elf)) {
+ return EINVAL;
+ }
+
if ((status = elf_read_phdr(elf)) < 0) {
elf_close(elf);
return status;
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;
}
return 0;
}
-
defua
lt int
+
_defau
lt int
elf_open(struct elf* elf, const char* path)
{
struct v_dnode* elfdn;
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);
}
return elf_do_open(elf, elffile);
}
-
defua
lt int
+
_defau
lt int
elf_openat(struct elf* elf, void* elf_vfile)
{
// so the ref count kept in sync
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);
}
return elf_do_open(elf, elf_vfile);
}
-
defua
lt int
+
_defau
lt int
elf_close(struct elf* elf)
{
if (elf->pheaders) {
elf_close(struct elf* elf)
{
if (elf->pheaders) {
@@
-74,7
+78,7
@@
elf_close(struct elf* elf)
return 0;
}
return 0;
}
-
defua
lt int
+
_defau
lt int
elf_static_linked(const struct elf* elf)
{
for (size_t i = 0; i < elf->eheader.e_phnum; i++) {
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;
}
return 1;
}
-
defua
lt size_t
+
_defau
lt 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
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;
}
return sz;
}
-
defua
lt int
+
_defau
lt int
elf_find_loader(const struct elf* elf, char* path_out, size_t len)
{
int retval = NO_LOADER;
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;
}
return retval;
}
-
defua
lt int
+
_defau
lt int
elf_read_ehdr(struct elf* elf)
{
struct v_file* elfile = (struct v_file*)elf->elf_file;
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);
}
return elf_read(elfile, (void*)&elf->eheader, 0, SIZE_EHDR);
}
-
defua
lt int
+
_defau
lt int
elf_read_phdr(struct elf* elf)
{
int status = 0;
elf_read_phdr(struct elf* elf)
{
int status = 0;
@@
-170,7
+174,7
@@
elf_read_phdr(struct elf* elf)
return entries;
}
return entries;
}
-
defua
lt int
+
_defau
lt int
elf_check_exec(const struct elf* elf, int type)
{
const struct elf_ehdr* ehdr = &elf->eheader;
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;
}
return (ehdr->e_entry) && ehdr->e_type == type;
}
-
defua
lt int
+
_defau
lt int
elf_check_arch(const struct elf* elf)
{
const struct elf_ehdr* ehdr = &elf->eheader;
elf_check_arch(const struct elf* elf)
{
const struct elf_ehdr* ehdr = &elf->eheader;