diff options
Diffstat (limited to 'src/kernel/linker')
-rw-r--r-- | src/kernel/linker/elf.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/kernel/linker/elf.c b/src/kernel/linker/elf.c index 7eaae94..af6d057 100644 --- a/src/kernel/linker/elf.c +++ b/src/kernel/linker/elf.c @@ -1,7 +1,7 @@ #include "elf.h" #include <mem/paging.h> #include <mem/seg.h> -#include <stdlib.h> +#include <stdlib_common.h> #include <core/sys.h> int elf_check(uint8_t *data) { @@ -14,6 +14,7 @@ thread_entry elf_load(uint8_t *data, struct process* process) { struct elf_ehdr *ehdr = (struct elf_ehdr*)data; struct elf_phdr *phdr; int i; + size_t dataseg = 0; if (elf_check(data)) return 0; struct page_directory *r = current_pagedir; @@ -28,9 +29,15 @@ thread_entry elf_load(uint8_t *data, struct process* process) { if (phdr[i].p_memsz > phdr[i].p_filesz) { memset((uint8_t*)phdr[i].p_vaddr + phdr[i].p_memsz, 0, phdr[i].p_memsz - phdr[i].p_filesz); } + if (phdr[i].p_vaddr + phdr[i].p_memsz > dataseg) { + dataseg = phdr[i].p_vaddr + phdr[i].p_memsz; + dataseg = (dataseg & 0xFFFFF000) + 0x1000; + } } } + process->data = dataseg; + pagedir_switch(r); sti(); |