- mySpace = create_mspace( numheappages*PAGESIZE, 1 );
- addMemoryRegionToSnapShot(mySpace, numheappages);
+
+ // EVIL HACK: We need to make sure that calls into the HandlePF method don't cause dynamic links
+ // The problem is that we end up protecting state in the dynamic linker...
+ // Solution is to call our signal handler before we start protecting stuff...
+
+ siginfo_t si;
+ memset(&si, 0, sizeof(si));
+ si.si_addr = ss.ss_sp;
+ HandlePF(SIGSEGV, &si, NULL);
+ snapshotrecord->lastBackingPage--; //remove the fake page we copied
+
+ void *basemySpace = model_malloc((numheappages + 1) * PAGESIZE);
+ void *pagealignedbase = PageAlignAddressUpward(basemySpace);
+ user_snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1);
+ addMemoryRegionToSnapShot(pagealignedbase, numheappages);
+
+ void *base_model_snapshot_space = model_malloc((numheappages + 1) * PAGESIZE);
+ pagealignedbase = PageAlignAddressUpward(base_model_snapshot_space);
+ model_snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1);
+ addMemoryRegionToSnapShot(pagealignedbase, numheappages);
+