aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
Diffstat (limited to 'pk')
-rw-r--r--pk/elf.c1
-rw-r--r--pk/mmap.c9
2 files changed, 3 insertions, 7 deletions
diff --git a/pk/elf.c b/pk/elf.c
index bfc8daa..abc78e1 100644
--- a/pk/elf.c
+++ b/pk/elf.c
@@ -96,6 +96,7 @@ void load_elf(const char* fn, elf_info* info)
}
file_decref(file);
+ info->brk = ROUNDUP(info->brk_min, RISCV_PGSIZE);
return;
fail:
diff --git a/pk/mmap.c b/pk/mmap.c
index dd0fe59..8f9a281 100644
--- a/pk/mmap.c
+++ b/pk/mmap.c
@@ -433,13 +433,8 @@ uintptr_t do_mmap(uintptr_t addr, size_t length, int prot, int flags, int fd, of
uintptr_t __do_brk(size_t addr)
{
uintptr_t newbrk = addr;
- if (addr < current.brk_min)
- newbrk = current.brk_min;
- else if (addr > current.brk_max)
- newbrk = current.brk_max;
-
- if (current.brk == 0)
- current.brk = ROUNDUP(current.brk_min, RISCV_PGSIZE);
+ if (addr < current.brk_min || addr > current.brk_max)
+ return current.brk;
uintptr_t newbrk_page = ROUNDUP(newbrk, RISCV_PGSIZE);
if (current.brk > newbrk_page) {