Skip to content

Commit

Permalink
wip dyld
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jul 16, 2023
1 parent 8d24b83 commit 945ca60
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/dyld.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,33 @@ dyld_allocate_table(struct dyld *d)
return 0;
}

int
dyld_commit_allocation(struct dyld *d)
{
int ret;

struct tabletype *tt = &d->tt;
tt->et = TYPE_funcref;
tt->lim.min = d->table_base;
tt->lim.max = d->table_base;
ret = table_instance_create(&d->tableinst, tt);
if (ret != 0) {
goto fail;
}

struct memtype *mt = &d->mt;
d->memory_base = align_up(d->memory_base, WASM_PAGE_SIZE);
mt->lim.min = d->memory_base / WASM_PAGE_SIZE;
mt->lim.max = WASM_MAX_PAGES;
mt->flags = 0;
ret = memory_instance_create(&d->meminst, mt);
if (ret != 0) {
goto fail;
}
fail:
return ret;
}

int
dyld_load_main_object_from_file(struct dyld *d, const char *name)
{
Expand All @@ -311,6 +338,7 @@ dyld_load_main_object_from_file(struct dyld *d, const char *name)
if (ret != 0) {
goto fail;
}
ret = dyld_commit_allocation(d);
fail:
return ret;
}

0 comments on commit 945ca60

Please sign in to comment.