summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/elf.c
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2024-05-22 13:00:41 -0400
committerJon Santmyer <jon@jonsantmyer.com>2024-05-22 13:00:41 -0400
commitace65b453151845bc361f21f3e5b651c35f9f126 (patch)
tree262ebd29b0ca1d8584f0b6f1efa7a00d9f4f3e43 /arch/x86_64/elf.c
parentf004c1ade8d617a82cea2fe249434cccb47a2358 (diff)
downloadjove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.gz
jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.bz2
jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.zip
massive refactor for mp and organizationHEADmaster
Diffstat (limited to 'arch/x86_64/elf.c')
-rw-r--r--arch/x86_64/elf.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/arch/x86_64/elf.c b/arch/x86_64/elf.c
deleted file mode 100644
index 969cbf0..0000000
--- a/arch/x86_64/elf.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "elf.h"
-#include "lib/string.h"
-#include "usr/elf.h"
-#include "io/log.h"
-#include "mem/memory.h"
-
-void*
-elf_load(const void *data, size_t len)
-{
- if(data == NULL) return NULL;
- if(len < 4) return NULL;
-
- struct ELF_header *ehdr = (struct ELF_header*)data;
- if(ehdr->e_ident[EI_MAG0] != E_IDENT_MAG0 &&
- ehdr->e_ident[EI_MAG1] != E_IDENT_MAG1 &&
- ehdr->e_ident[EI_MAG2] != E_IDENT_MAG2 &&
- ehdr->e_ident[EI_MAG3] != E_IDENT_MAG3)
- return NULL;
-
- if(ehdr->e_ident[EI_CLASS] != E_IDENT_CLASS64) {
- klogf("Jove does not support ELF files of class CLASS32\n");
- return NULL;
- }
-
- if(ehdr->e_type != ET_EXEC) {
- klogf("Jove does not support ELF files other than ET_EXEC\n");
- return NULL;
- }
-
- uint64_t entry = ehdr->e_entry;
-
- size_t phdrc = ehdr->e_phnum;
- struct ELF_phdr *phdrs = (struct ELF_phdr*)((uintptr_t)data + ehdr->e_phoff);
-
- for(size_t phdri = 0; phdri < phdrc; phdri++)
- {
- struct ELF_phdr *phdr = &phdrs[phdri];
- void *pdata = (void*)phdr->p_vaddr;
-
- mem_ensure_range(
- phdr->p_vaddr,
- phdr->p_vaddr + phdr->p_memsz,
- (page_flags_t) {
- .present = true,
- .writeable = true,
- .useraccess = true,
- .executable = true
- });
- if(phdr->p_type == PT_LOAD)
- {
- memcpy(pdata, (void*)((uintptr_t)data + phdr->p_offset), phdr->p_filesz);
- }
- }
- return (void*)entry;
-}