Skip to content

heap_base and data_end have to be local globals #3996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5924,6 +5924,13 @@ load_from_sections(WASMModule *module, WASMSection *sections,
for (i = 0; i < module->export_count; i++, export ++) {
if (export->kind == EXPORT_KIND_GLOBAL) {
if (!strcmp(export->name, "__heap_base")) {
if (export->index < module->import_global_count) {
LOG_DEBUG("Skip the process if __heap_base is imported "
"instead of being a local global");
continue;
}

/* only process linker-generated symbols */
global_index = export->index - module->import_global_count;
global = module->globals + global_index;
if (global->type.val_type == VALUE_TYPE_I32
Expand All @@ -5938,6 +5945,13 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
}
else if (!strcmp(export->name, "__data_end")) {
if (export->index < module->import_global_count) {
LOG_DEBUG("Skip the process if __data_end is imported "
"instead of being a local global");
continue;
}

/* only process linker-generated symbols */
global_index = export->index - module->import_global_count;
global = module->globals + global_index;
if (global->type.val_type == VALUE_TYPE_I32
Expand Down
12 changes: 12 additions & 0 deletions core/iwasm/interpreter/wasm_mini_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,12 @@ load_from_sections(WASMModule *module, WASMSection *sections,
for (i = 0; i < module->export_count; i++, export ++) {
if (export->kind == EXPORT_KIND_GLOBAL) {
if (!strcmp(export->name, "__heap_base")) {
if (export->index < module->import_global_count) {
LOG_DEBUG("Skip the process if __heap_base is imported "
"instead of being a local global");
continue;
}

global_index = export->index - module->import_global_count;
global = module->globals + global_index;
if (global->type.val_type == VALUE_TYPE_I32
Expand All @@ -2750,6 +2756,12 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
}
else if (!strcmp(export->name, "__data_end")) {
if (export->index < module->import_global_count) {
LOG_DEBUG("Skip the process if __data_end is imported "
"instead of being a local global");
continue;
}

global_index = export->index - module->import_global_count;
global = module->globals + global_index;
if (global->type.val_type == VALUE_TYPE_I32
Expand Down
Loading