From 8db6f5978bb5f20ab4ecc0d30c28d5af2229cc5f Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sat, 7 May 2022 09:41:53 +0900 Subject: [PATCH] aot_emit_aot_file.c: Convert switch lookup table relocation (#1149) Fix the symbol resolving failure with recent version of wamrc: ``` AOT module load failed: resolve symbol .Lswitch.table.aot _func#82.2 failed ``` Replace the relocations for such symbols with .rodata section. --- core/iwasm/compilation/aot_emit_aot_file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index bbe2c14b..f8e30f56 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -2401,13 +2401,15 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data, relocation->relocation_type = (uint32)type; relocation->symbol_name = (char *)LLVMGetSymbolName(rel_sym); - /* for ".LCPIxxx", ".LJTIxxx" and ".LBBxxx" relocation, - * transform the symbol name to real section name and set + /* for ".LCPIxxx", ".LJTIxxx", ".LBBxxx" and switch lookup table + * relocation, transform the symbol name to real section name and set * addend to the offset of the symbol in the real section */ if (relocation->symbol_name && (str_starts_with(relocation->symbol_name, ".LCPI") || str_starts_with(relocation->symbol_name, ".LJTI") - || str_starts_with(relocation->symbol_name, ".LBB"))) { + || str_starts_with(relocation->symbol_name, ".LBB") + || str_starts_with(relocation->symbol_name, + ".Lswitch.table."))) { /* change relocation->relocation_addend and relocation->symbol_name */ LLVMSectionIteratorRef contain_section;