Skip to content

Commit 6454ddb

Browse files
committed
wip
1 parent 6f1adf3 commit 6454ddb

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/std/packages/std/manifest.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use std::{
55
str::FromStr as _,
66
sync::LazyLock,
77
};
8-
use bytes::Bytes;
9-
use futures::io::Cursor;
108
use tangram_client as tg;
119

1210
/// The magic number used to indicate an executable has a manifest.

packages/std/packages/stub/src/stub.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ static LoadedInterpreter load_interpreter(
324324

325325
// Create one big mapping for the entire interpreter with PROT_NONE permissions. We'll slice it up in a second.
326326
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);
327328

328329
// Compute the bias, the logical base address of the interpeter.
329330
void* bias = base_address - minvaddr;
@@ -357,7 +358,7 @@ static LoadedInterpreter load_interpreter(
357358

358359
// Compute the file size that we will map in.
359360
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);
361362

362363
// If there's a non-zero number of bytes in the file, mmap it in.
363364
size_t mapped = 0;
@@ -376,9 +377,12 @@ static LoadedInterpreter load_interpreter(
376377

377378
// If we need more memory than was mapped from the file, allocate it.
378379
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);
379383
void* p = mmap(
380-
segment_address + filesz,
381-
memsz - filesz,
384+
(void*)start,
385+
(end - start),
382386
prot,
383387
MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE,
384388
-1,

0 commit comments

Comments
 (0)