@@ -324,6 +324,7 @@ static LoadedInterpreter load_interpreter(
324
324
325
325
// Create one big mapping for the entire interpreter with PROT_NONE permissions. We'll slice it up in a second.
326
326
void * base_address = mmap (0 , ALIGN (maxvaddr , page_sz ), 0 , MAP_PRIVATE | MAP_ANONYMOUS , -1 , 0 );
327
+ DBG ("mapped %08lx..%08lx" , (uintptr_t )base_address , (uintptr_t )base_address + maxvaddr );
327
328
328
329
// Compute the bias, the logical base address of the interpeter.
329
330
void * bias = base_address - minvaddr ;
@@ -357,7 +358,7 @@ static LoadedInterpreter load_interpreter(
357
358
358
359
// Compute the file size that we will map in.
359
360
uintptr_t filesz = ALIGN (itr -> p_filesz + misalignment , page_sz );
360
- uintptr_t memsz = ALIGN (itr -> p_memsz , page_sz );
361
+ uintptr_t memsz = ALIGN (itr -> p_memsz + misalignment , page_sz );
361
362
362
363
// If there's a non-zero number of bytes in the file, mmap it in.
363
364
size_t mapped = 0 ;
@@ -376,9 +377,12 @@ static LoadedInterpreter load_interpreter(
376
377
377
378
// If we need more memory than was mapped from the file, allocate it.
378
379
if (memsz > filesz ) {
380
+ uintptr_t start = (uintptr_t )segment_address + filesz ;
381
+ uintptr_t end = start + (memsz - filesz );
382
+ DBG ("mapping extra memory from %08lx .. %08lx" , start , end );
379
383
void * p = mmap (
380
- segment_address + filesz ,
381
- memsz - filesz ,
384
+ ( void * ) start ,
385
+ ( end - start ) ,
382
386
prot ,
383
387
MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE ,
384
388
-1 ,
0 commit comments