aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
Diffstat (limited to 'pk')
-rw-r--r--pk/elf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/pk/elf.c b/pk/elf.c
index ad52bf6..b520609 100644
--- a/pk/elf.c
+++ b/pk/elf.c
@@ -84,8 +84,10 @@ void load_elf(const char* fn, elf_info* info)
info->brk_min = vaddr + ph[i].p_memsz;
int flags2 = flags | (prepad ? MAP_POPULATE : 0);
int prot = get_prot(ph[i].p_flags);
- if (__do_mmap(vaddr - prepad, ph[i].p_filesz + prepad, prot | PROT_WRITE, flags2, file, ph[i].p_offset - prepad) != vaddr - prepad)
- goto fail;
+ if (ph[i].p_filesz != 0) {
+ if (__do_mmap(vaddr - prepad, ph[i].p_filesz + prepad, prot | PROT_WRITE, flags2, file, ph[i].p_offset - prepad) != vaddr - prepad)
+ goto fail;
+ }
memset_user((void*)vaddr - prepad, 0, prepad);
if (!(prot & PROT_WRITE))
if (do_mprotect(vaddr - prepad, ph[i].p_filesz + prepad, prot))