@@ -634,73 +634,6 @@ str2uint32(const char *buf, uint32 *p_res);
634
634
static bool
635
635
str2uint64 (const char * buf , uint64 * p_res );
636
636
637
- #if WASM_ENABLE_MULTI_MODULE != 0
638
- static void *
639
- aot_loader_resolve_function (const AOTModule * module , const char * function_name ,
640
- const AOTFuncType * expected_function_type ,
641
- char * error_buf , uint32 error_buf_size );
642
-
643
- static void *
644
- aot_loader_resolve_function_ex (const char * module_name ,
645
- const char * function_name ,
646
- const AOTFuncType * expected_function_type ,
647
- char * error_buf , uint32 error_buf_size )
648
- {
649
- WASMModuleCommon * module_reg ;
650
-
651
- module_reg = wasm_runtime_find_module_registered (module_name );
652
- if (!module_reg || module_reg -> module_type != Wasm_Module_AoT ) {
653
- LOG_DEBUG ("can not find a module named %s for function %s" , module_name ,
654
- function_name );
655
- set_error_buf (error_buf , error_buf_size , "unknown import" );
656
- return NULL ;
657
- }
658
- return aot_loader_resolve_function ((AOTModule * )module_reg , function_name ,
659
- expected_function_type , error_buf ,
660
- error_buf_size );
661
- }
662
-
663
- static void *
664
- aot_loader_resolve_function (const AOTModule * module , const char * function_name ,
665
- const AOTFuncType * expected_function_type ,
666
- char * error_buf , uint32 error_buf_size )
667
- {
668
- void * function = NULL ;
669
- AOTExport * export = NULL ;
670
- AOTFuncType * target_function_type = NULL ;
671
-
672
- export = loader_find_export ((WASMModuleCommon * )module , module -> name ,
673
- function_name , EXPORT_KIND_FUNC , error_buf ,
674
- error_buf_size );
675
- if (!export ) {
676
- return NULL ;
677
- }
678
-
679
- /* resolve function type and function */
680
- if (export -> index < module -> import_func_count ) {
681
- target_function_type = module -> import_funcs [export -> index ].func_type ;
682
- function = module -> import_funcs [export -> index ].func_ptr_linked ;
683
- }
684
- else {
685
- target_function_type =
686
- (AOTFuncType * )module
687
- -> types [module -> func_type_indexes [export -> index
688
- - module -> import_func_count ]];
689
- function =
690
- (module -> func_ptrs [export -> index - module -> import_func_count ]);
691
- }
692
- /* check function type */
693
- if (!wasm_type_equal ((WASMType * )expected_function_type ,
694
- (WASMType * )target_function_type , module -> types ,
695
- module -> type_count )) {
696
- LOG_DEBUG ("%s.%s failed the type check" , module -> name , function_name );
697
- set_error_buf (error_buf , error_buf_size , "incompatible import type" );
698
- return NULL ;
699
- }
700
- return function ;
701
- }
702
- #endif /* end of WASM_ENABLE_MULTI_MODULE */
703
-
704
637
static bool
705
638
load_native_symbol_section (const uint8 * buf , const uint8 * buf_end ,
706
639
AOTModule * module , bool is_load_from_file_buf ,
@@ -2285,19 +2218,13 @@ destroy_import_funcs(AOTImportFunc *import_funcs)
2285
2218
2286
2219
static bool
2287
2220
load_import_funcs (const uint8 * * p_buf , const uint8 * buf_end , AOTModule * module ,
2288
- bool is_load_from_file_buf , char * error_buf ,
2221
+ bool is_load_from_file_buf , bool no_resolve , char * error_buf ,
2289
2222
uint32 error_buf_size )
2290
2223
{
2291
- char * module_name , * field_name ;
2292
2224
const uint8 * buf = * p_buf ;
2293
2225
AOTImportFunc * import_funcs ;
2294
2226
uint64 size ;
2295
2227
uint32 i ;
2296
- #if WASM_ENABLE_MULTI_MODULE != 0
2297
- AOTModule * sub_module = NULL ;
2298
- AOTFunc * linked_func = NULL ;
2299
- AOTFuncType * declare_func_type = NULL ;
2300
- #endif
2301
2228
2302
2229
/* Allocate memory */
2303
2230
size = sizeof (AOTImportFunc ) * (uint64 )module -> import_func_count ;
@@ -2314,53 +2241,17 @@ load_import_funcs(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
2314
2241
return false;
2315
2242
}
2316
2243
2317
- #if WASM_ENABLE_MULTI_MODULE != 0
2318
- declare_func_type =
2319
- (AOTFuncType * )module -> types [import_funcs [i ].func_type_index ];
2320
- read_string (buf , buf_end , module_name );
2321
- read_string (buf , buf_end , field_name );
2322
-
2323
- import_funcs [i ].module_name = module_name ;
2324
- import_funcs [i ].func_name = field_name ;
2325
- linked_func = wasm_native_resolve_symbol (
2326
- module_name , field_name , declare_func_type ,
2327
- & import_funcs [i ].signature , & import_funcs [i ].attachment ,
2328
- & import_funcs [i ].call_conv_raw );
2329
- if (!linked_func ) {
2330
- sub_module = NULL ;
2331
- if (!wasm_runtime_is_built_in_module (module_name )) {
2332
- sub_module = (AOTModule * )wasm_runtime_load_depended_module (
2333
- (WASMModuleCommon * )module , module_name , error_buf ,
2334
- error_buf_size );
2335
- if (!sub_module ) {
2336
- LOG_ERROR ("failed to load sub module: %s" , error_buf );
2337
- return false;
2338
- }
2339
- }
2340
- if (!sub_module )
2341
- linked_func = aot_loader_resolve_function_ex (
2342
- module_name , field_name , declare_func_type , error_buf ,
2343
- error_buf_size );
2344
- else
2345
- linked_func = aot_loader_resolve_function (
2346
- sub_module , field_name , declare_func_type , error_buf ,
2347
- error_buf_size );
2348
- }
2349
- import_funcs [i ].func_ptr_linked = linked_func ;
2350
- import_funcs [i ].func_type = declare_func_type ;
2351
-
2352
- #else
2353
2244
import_funcs [i ].func_type =
2354
2245
(AOTFuncType * )module -> types [import_funcs [i ].func_type_index ];
2355
2246
read_string (buf , buf_end , import_funcs [i ].module_name );
2356
2247
read_string (buf , buf_end , import_funcs [i ].func_name );
2357
- module_name = import_funcs [i ].module_name ;
2358
- field_name = import_funcs [i ].func_name ;
2359
- import_funcs [i ].func_ptr_linked = wasm_native_resolve_symbol (
2360
- module_name , field_name , import_funcs [ i ]. func_type ,
2361
- & import_funcs [ i ]. signature , & import_funcs [ i ]. attachment ,
2362
- & import_funcs [i ]. call_conv_raw );
2363
- #endif
2248
+ import_funcs [i ].attachment = NULL ;
2249
+ import_funcs [i ].signature = NULL ;
2250
+ import_funcs [i ].call_conv_raw = false;
2251
+
2252
+ if (! no_resolve ) {
2253
+ aot_resolve_import_func ( module , & import_funcs [i ]);
2254
+ }
2364
2255
2365
2256
#if WASM_ENABLE_LIBC_WASI != 0
2366
2257
if (!strcmp (import_funcs [i ].module_name , "wasi_unstable" )
@@ -2378,7 +2269,7 @@ load_import_funcs(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
2378
2269
static bool
2379
2270
load_import_func_info (const uint8 * * p_buf , const uint8 * buf_end ,
2380
2271
AOTModule * module , bool is_load_from_file_buf ,
2381
- char * error_buf , uint32 error_buf_size )
2272
+ bool no_resolve , char * error_buf , uint32 error_buf_size )
2382
2273
{
2383
2274
const uint8 * buf = * p_buf ;
2384
2275
@@ -2387,7 +2278,7 @@ load_import_func_info(const uint8 **p_buf, const uint8 *buf_end,
2387
2278
/* load import funcs */
2388
2279
if (module -> import_func_count > 0
2389
2280
&& !load_import_funcs (& buf , buf_end , module , is_load_from_file_buf ,
2390
- error_buf , error_buf_size ))
2281
+ no_resolve , error_buf , error_buf_size ))
2391
2282
return false;
2392
2283
2393
2284
* p_buf = buf ;
@@ -2514,7 +2405,7 @@ load_object_data_sections_info(const uint8 **p_buf, const uint8 *buf_end,
2514
2405
static bool
2515
2406
load_init_data_section (const uint8 * buf , const uint8 * buf_end ,
2516
2407
AOTModule * module , bool is_load_from_file_buf ,
2517
- char * error_buf , uint32 error_buf_size )
2408
+ bool no_resolve , char * error_buf , uint32 error_buf_size )
2518
2409
{
2519
2410
const uint8 * p = buf , * p_end = buf_end ;
2520
2411
@@ -2525,7 +2416,7 @@ load_init_data_section(const uint8 *buf, const uint8 *buf_end,
2525
2416
error_buf , error_buf_size )
2526
2417
|| !load_global_info (& p , p_end , module , error_buf , error_buf_size )
2527
2418
|| !load_import_func_info (& p , p_end , module , is_load_from_file_buf ,
2528
- error_buf , error_buf_size ))
2419
+ no_resolve , error_buf , error_buf_size ))
2529
2420
return false;
2530
2421
2531
2422
/* load function count and start function index */
@@ -3819,7 +3710,7 @@ has_module_memory64(AOTModule *module)
3819
3710
3820
3711
static bool
3821
3712
load_from_sections (AOTModule * module , AOTSection * sections ,
3822
- bool is_load_from_file_buf , char * error_buf ,
3713
+ bool is_load_from_file_buf , bool no_resolve , char * error_buf ,
3823
3714
uint32 error_buf_size )
3824
3715
{
3825
3716
AOTSection * section = sections ;
@@ -3852,8 +3743,8 @@ load_from_sections(AOTModule *module, AOTSection *sections,
3852
3743
break ;
3853
3744
case AOT_SECTION_TYPE_INIT_DATA :
3854
3745
if (!load_init_data_section (buf , buf_end , module ,
3855
- is_load_from_file_buf , error_buf ,
3856
- error_buf_size ))
3746
+ is_load_from_file_buf , no_resolve ,
3747
+ error_buf , error_buf_size ))
3857
3748
return false;
3858
3749
break ;
3859
3750
case AOT_SECTION_TYPE_TEXT :
@@ -4076,7 +3967,7 @@ aot_load_from_sections(AOTSection *section_list, char *error_buf,
4076
3967
if (!module )
4077
3968
return NULL ;
4078
3969
4079
- if (!load_from_sections (module , section_list , false, error_buf ,
3970
+ if (!load_from_sections (module , section_list , false, false, error_buf ,
4080
3971
error_buf_size )) {
4081
3972
aot_unload (module );
4082
3973
return NULL ;
@@ -4246,7 +4137,8 @@ create_sections(AOTModule *module, const uint8 *buf, uint32 size,
4246
4137
4247
4138
static bool
4248
4139
load (const uint8 * buf , uint32 size , AOTModule * module ,
4249
- bool wasm_binary_freeable , char * error_buf , uint32 error_buf_size )
4140
+ bool wasm_binary_freeable , bool no_resolve , char * error_buf ,
4141
+ uint32 error_buf_size )
4250
4142
{
4251
4143
const uint8 * buf_end = buf + size ;
4252
4144
const uint8 * p = buf , * p_end = buf_end ;
@@ -4273,7 +4165,7 @@ load(const uint8 *buf, uint32 size, AOTModule *module,
4273
4165
return false;
4274
4166
4275
4167
ret = load_from_sections (module , section_list , !wasm_binary_freeable ,
4276
- error_buf , error_buf_size );
4168
+ no_resolve , error_buf , error_buf_size );
4277
4169
if (!ret ) {
4278
4170
/* If load_from_sections() fails, then aot text is destroyed
4279
4171
in destroy_sections() */
@@ -4321,8 +4213,8 @@ aot_load_from_aot_file(const uint8 *buf, uint32 size, const LoadArgs *args,
4321
4213
return NULL ;
4322
4214
4323
4215
os_thread_jit_write_protect_np (false); /* Make memory writable */
4324
- if (!load (buf , size , module , args -> wasm_binary_freeable , error_buf ,
4325
- error_buf_size )) {
4216
+ if (!load (buf , size , module , args -> wasm_binary_freeable , args -> no_resolve ,
4217
+ error_buf , error_buf_size )) {
4326
4218
aot_unload (module );
4327
4219
return NULL ;
4328
4220
}
0 commit comments