aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-11-02 19:28:42 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2024-11-02 19:28:42 +0200
commit227374239ce397eb6b471bd8a058538ffc326756 (patch)
tree550e42674ed97e96867e68ed82c0d8e96b7f7dc5 /src
parent30379c499745c083e7621f88e5fbaaa7a8215bc4 (diff)
downloadkmi-227374239ce397eb6b471bd8a058538ffc326756.tar.gz
kmi-227374239ce397eb6b471bd8a058538ffc326756.zip
make it more obvious dynamic elf isn't supported
+ also cleans up a few warnings I've been annoyed by
Diffstat (limited to 'src')
-rw-r--r--src/elf.c50
1 files changed, 19 insertions, 31 deletions
diff --git a/src/elf.c b/src/elf.c
index d101d1e..d590109 100644
--- a/src/elf.c
+++ b/src/elf.c
@@ -162,24 +162,17 @@ static stat_t __map_exec(struct tcb *t,
return OK;
}
-/**
- * Map ELF dynamic object.
- *
- * @param t Thread space to work in.
- * @param bin Address of binary to map.
- * @param ei_c ELF identity class.
- * @param phstart Program header start.
- * @param phnum Number of program header entries.
- * @param phsize Size of page header entry.
- * @return Base of dynamic mapping.
- */
-static vm_t __map_dyn(struct tcb *t, vm_t bin, uint8_t ei_c, vm_t phstart,
- size_t phnum, size_t phsize)
+static vm_t __prepare_exec(struct tcb *t, uint8_t ei_c, vm_t elf)
{
- /** \todo this path should only be taken when no PT_INTERP is defined, as
- * making sure ld is loaded should be done in userspace. Maybe a bit
- * hacky, I know.*/
- return 0;
+ vm_t phstart = ptradd(elf, elf_header_prop(ei_c, elf, e_phoff));
+ size_t phnum = elf_header_prop(ei_c, elf, e_phnum);
+ size_t phsize = elf_header_prop(ei_c, elf, e_phentsize);
+
+ vm_t entry = elf_header_prop(ei_c, elf, e_entry);
+ if (__map_exec(t, elf, ei_c, phstart, phnum, phsize))
+ return 0;
+
+ return entry;
}
/**
@@ -195,24 +188,19 @@ static vm_t __map_dyn(struct tcb *t, vm_t bin, uint8_t ei_c, vm_t phstart,
*/
static vm_t __prepare_proc(struct tcb *t, uint8_t ei_c, vm_t elf, vm_t interp)
{
- short e_type = elf_header_prop(ei_c, elf, e_type);
- if (e_type != ET_DYN && e_type != ET_EXEC)
- return 0;
+ UNUSED(interp);
- vm_t phstart = ptradd(elf, elf_header_prop(ei_c, elf, e_phoff));
- size_t phnum = elf_header_prop(ei_c, elf, e_phnum);
- size_t phsize = elf_header_prop(ei_c, elf, e_phentsize);
+ short e_type = elf_header_prop(ei_c, elf, e_type);
- vm_t entry = elf_header_prop(ei_c, elf, e_entry);
- if (e_type == ET_EXEC) {
- if (__map_exec(t, elf, ei_c, phstart, phnum, phsize))
- return 0;
+ if (e_type == ET_EXEC)
+ return __prepare_exec(t, ei_c, elf);
- return entry;
- } else {
- vm_t o = __map_dyn(t, elf, ei_c, phstart, phnum, phsize);
- return o + entry;
+ if (e_type == ET_DYN) {
+ bug("dynamic elf not currently implemented\n");
+ return 0;
}
+
+ return 0;
}
/* sets up all memory regions etc, returns the entry address */