Forráskód Böngészése

Fix fail to get builtin functions in indirect call (XIP) mode (#829)

Fix fail to get builtin functions in indirect call (XIP) mode, e.g.
function aot_alloc_frame, aot_memory_init, aot_table_init and so on.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Huang Qi 4 éve
szülő
commit
0af7522e3e
1 módosított fájl, 17 hozzáadás és 0 törlés
  1. 17 0
      core/iwasm/compilation/aot_compiler.h

+ 17 - 0
core/iwasm/compilation/aot_compiler.h

@@ -325,6 +325,23 @@ check_type_compatible(uint8 src_type, uint8 dst_type)
                 return false;                                               \
             }                                                               \
         }                                                                   \
+        else if (comp_ctx->is_indirect_mode) {                              \
+            int32 func_index;                                               \
+            if (!(func_ptr_type = LLVMPointerType(func_type, 0))) {         \
+                aot_set_last_error("create LLVM function type failed.");    \
+                return false;                                               \
+            }                                                               \
+                                                                            \
+            func_index = aot_get_native_symbol_index(comp_ctx, #name);      \
+            if (func_index < 0) {                                           \
+                return false;                                               \
+            }                                                               \
+            if (!(func = aot_get_func_from_table(                           \
+                      comp_ctx, func_ctx->native_symbol, func_ptr_type,     \
+                      func_index))) {                                       \
+                return false;                                               \
+            }                                                               \
+        }                                                                   \
         else {                                                              \
             char *func_name = #name;                                        \
             /* AOT mode, delcare the function */                            \