@@ -31,6 +31,10 @@ LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
3131 AOTCompOption option = { 0 };
3232 aot_comp_data_t comp_data = NULL ;
3333 aot_comp_context_t comp_ctx = NULL ;
34+ uint8 *aot_file_buf = NULL ;
35+ uint32 aot_file_size = 0 ;
36+ wasm_module_t aot_module = NULL ;
37+ wasm_module_inst_t inst = NULL ;
3438
3539 /* libfuzzer don't allow to modify the given Data, so make a copy here */
3640 std::vector<uint8_t > myData (Data, Data + Size);
@@ -78,6 +82,31 @@ LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
7882 goto DESTROY_COMP_CTX;
7983 }
8084
85+ aot_file_buf = aot_emit_aot_file_buf (comp_ctx, comp_data, &aot_file_size);
86+ if (!aot_file_buf) {
87+ handle_aot_recent_error (" [EMITTING AOT FILE]" );
88+ goto DESTROY_COMP_CTX;
89+ }
90+
91+ aot_module =
92+ wasm_runtime_load (aot_file_buf, aot_file_size, error_buf, 128 );
93+ if (!aot_module) {
94+ std::cout << " [LOADING AOT MODULE] " << error_buf << std::endl;
95+ goto RELEASE_AOT_FILE_BUF;
96+ }
97+
98+ inst = wasm_runtime_instantiate (aot_module, 1024 *8 , 0 , error_buf, 128 );
99+ if (!inst) {
100+ std::cout << " [INSTANTIATING AOT MODULE] " << error_buf << std::endl;
101+ goto UNLOAD_AOT_MODULE;
102+ }
103+
104+ DEINSTANTIZE_AOT_MODULE:
105+ wasm_runtime_deinstantiate (inst);
106+ UNLOAD_AOT_MODULE:
107+ wasm_runtime_unload (aot_module);
108+ RELEASE_AOT_FILE_BUF:
109+ wasm_runtime_free (aot_file_buf);
81110DESTROY_COMP_CTX:
82111 aot_destroy_comp_context (comp_ctx);
83112DESTROY_COMP_DATA:
0 commit comments