diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index ae390dfc3..bebae5506 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -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) { @@ -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);