aboutsummaryrefslogtreecommitdiff
path: root/pk/elf.c
diff options
context:
space:
mode:
Diffstat (limited to 'pk/elf.c')
-rw-r--r--pk/elf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/pk/elf.c b/pk/elf.c
index b520609..c900a2d 100644
--- a/pk/elf.c
+++ b/pk/elf.c
@@ -89,13 +89,13 @@ void load_elf(const char* fn, elf_info* info)
goto fail;
}
memset_user((void*)vaddr - prepad, 0, prepad);
- if (!(prot & PROT_WRITE))
- if (do_mprotect(vaddr - prepad, ph[i].p_filesz + prepad, prot))
- goto fail;
size_t mapped = ROUNDUP(ph[i].p_filesz + prepad, RISCV_PGSIZE) - prepad;
if (ph[i].p_memsz > mapped)
if (__do_mmap(vaddr + mapped, ph[i].p_memsz - mapped, prot, flags|MAP_ANONYMOUS, 0, 0) != vaddr + mapped)
goto fail;
+ if (!(prot & PROT_WRITE))
+ if (do_mprotect(vaddr - prepad, ph[i].p_memsz + prepad, prot))
+ goto fail;
}
}