Skip to content

Commit

Permalink
wamrc: Warn on text relocations for XIP (bytecodealliance#2340)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt authored Jul 5, 2023
1 parent 8ad78a8 commit a6b2d54
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/iwasm/compilation/aot_emit_aot_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3087,6 +3087,13 @@ is_relocation_section(AOTObjectData *obj_data, LLVMSectionIteratorRef sec_itr)
return false;
}

static bool
is_readonly_section(const char *name)
{
return !strcmp(name, ".rel.text") || !strcmp(name, ".rela.text")
|| !strcmp(name, ".rela.literal") || !strcmp(name, ".text");
}

static bool
get_relocation_groups_count(AOTObjectData *obj_data, uint32 *p_count)
{
Expand Down Expand Up @@ -3184,6 +3191,19 @@ aot_resolve_object_relocation_groups(AOTObjectData *obj_data)
relocation_group->section_name = ".rel.text";
}

/*
* Relocations in read-only sections are problematic,
* especially for XIP on platforms which don't have
* copy-on-write mappings.
*/
if (obj_data->comp_ctx->is_indirect_mode
&& is_readonly_section(relocation_group->section_name)) {
LOG_WARNING("%" PRIu32
" text relocations in %s section for indirect mode",
relocation_group->relocation_count,
relocation_group->section_name);
}

relocation_group++;
}
LLVMMoveToNextSection(sec_itr);
Expand Down

0 comments on commit a6b2d54

Please sign in to comment.