+void
+__heap_copied(struct mm_region* region)
+{
+ mm_index((void**)®ion->proc_vms->heap, region);
+}
+
+int
+__exec_remap_heap(struct ld_param* param, struct proc_mm* pvms)
+{
+ if (pvms->heap) {
+ mem_unmap_region(param->vms_mnt, pvms->heap);
+ }
+
+ struct mmap_param map_param = { .pvms = pvms,
+ .vms_mnt = param->vms_mnt,
+ .flags = MAP_ANON | MAP_PRIVATE | MAP_FIXED,
+ .type = REGION_TYPE_HEAP,
+ .proct = PROT_READ | PROT_WRITE,
+ .mlen = DEFAULT_HEAP_PAGES * PG_SIZE };
+ int status = 0;
+ struct mm_region* heap;
+ if ((status = mem_map(NULL, &heap, param->info.end, NULL, &map_param))) {
+ param->status |= LD_STAT_FKUP;
+ return status;
+ }
+
+ heap->region_copied = __heap_copied;
+ mm_index((void**)&pvms->heap, heap);
+}
+