wamrc: Warn on text relocations for XIP (#2340)

This commit is contained in:
YAMAMOTO Takashi 2023-07-05 11:49:45 +09:00 committed by GitHub
parent a9b76228b0
commit 3bbf59ad45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);