int auxc, elf_aux_t auxv[])
{
/* Map in pages for p's stack. */
- int flags = MAP_FIXED | MAP_ANONYMOUS;
+ int flags = MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE;
uintptr_t stacksz = USTACK_NUM_PAGES*PGSIZE;
if (do_mmap(p, USTACKTOP-stacksz, stacksz, PROT_READ | PROT_WRITE,
flags, NULL, 0) == MAP_FAILED)
ei->highest_addr = 0;
off64_t f_off = 0;
void* phdrs = 0;
- int mm_perms, mm_flags = MAP_FIXED;
-
+ int mm_perms, mm_flags;
+
/* When reading on behalf of the kernel, we need to switch to a ktask so
* the VFS (and maybe other places) know. (TODO: KFOP) */
uintptr_t old_ret = switch_to_ktask();
p_flags |= (writable ? ELF_PROT_WRITE : 0);
/* All mmaps need to be fixed to their VAs. If the program wants it to
* be a writable region, we also need the region to be private. */
- mm_flags = MAP_FIXED | (p_flags & ELF_PROT_WRITE ? MAP_PRIVATE : 0);
+ mm_flags = MAP_FIXED |
+ (p_flags & ELF_PROT_WRITE ? MAP_PRIVATE : MAP_SHARED);
if (p_type == ELF_PROG_PHDR)
ei->phdr = p_va;
/* Need our own populated, private copy of the page so that
* we can zero the remainder - and not zero chunks of the
* real file in the page cache. */
+ mm_flags &= ~MAP_SHARED;
mm_flags |= MAP_PRIVATE | MAP_POPULATE;
/* Map the final partial page. */
uintptr_t core0_entry = ei.dynamic ? interp_ei.entry : ei.entry;
proc_init_ctx(&p->scp_ctx, 0, core0_entry, stack_top, 0);
- /* Set the heap bottom and top to just past where the text region has been
- * loaded. */
- p->heap_top = (void*)ei.highest_addr;
- p->procinfo->heap_bottom = p->heap_top;
+ p->procinfo->program_end = ei.highest_addr;
p->args_base = (void *) stack_top;
return 0;