diff --git a/.gitignore b/.gitignore index 5f55306f4..1f58acf12 100644 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,5 @@ CMakeUserPresets.json bld.rippled/ generated +guard_checker +guard_checker.dSYM diff --git a/src/ripple/app/hook/Guard.h b/src/ripple/app/hook/Guard.h index f395af448..1d0fd573c 100644 --- a/src/ripple/app/hook/Guard.h +++ b/src/ripple/app/hook/Guard.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -282,7 +283,8 @@ check_guard( * might have unforeseen consequences, without also rolling back further * changes that are fine. */ - uint64_t rulesVersion = 0 + uint64_t rulesVersion = 0, + std::set* out_callees = nullptr ) { @@ -492,17 +494,27 @@ check_guard( { REQUIRE(1); uint64_t callee_idx = LEB(); - // disallow calling of user defined functions inside a hook + + // record user-defined function calls if tracking is enabled if (callee_idx > last_import_idx) { - GUARDLOG(hook::log::CALL_ILLEGAL) - << "GuardCheck " - << "Hook calls a function outside of the whitelisted " - "imports " - << "codesec: " << codesec << " hook byte offset: " << i - << "\n"; + if (out_callees != nullptr) + { + // record the callee for call graph analysis + out_callees->insert(callee_idx); + } + else + { + // if not tracking, maintain original behavior: reject + GUARDLOG(hook::log::CALL_ILLEGAL) + << "GuardCheck " + << "Hook calls a function outside of the whitelisted " + "imports " + << "codesec: " << codesec << " hook byte offset: " << i + << "\n"; - return {}; + return {}; + } } // enforce guard call limit @@ -837,6 +849,42 @@ validateGuards( */ uint64_t rulesVersion = 0) { + // Structure to track function call graph information + struct FunctionInfo + { + int func_idx; + std::set callees; // functions this function calls + std::set callers; // functions that call this function + bool has_loops; // whether this function contains loops + uint64_t local_wce; // local worst-case execution count + uint64_t total_wce; // total WCE including callees + bool wce_calculated; // whether total_wce has been computed + bool in_calculation; // for cycle detection in WCE calculation + + FunctionInfo() + : func_idx(-1) + , has_loops(false) + , local_wce(0) + , total_wce(0) + , wce_calculated(false) + , in_calculation(false) + { + } + + FunctionInfo(int idx, uint64_t local_wce_val, bool has_loops_val) + : func_idx(idx) + , has_loops(has_loops_val) + , local_wce(local_wce_val) + , total_wce(0) + , wce_calculated(false) + , in_calculation(false) + { + } + }; + + // Call graph: maps function index to its information + std::map call_graph; + uint64_t byteCount = wasm.size(); // 63 bytes is the smallest possible valid hook wasm @@ -1176,6 +1224,12 @@ validateGuards( if (DEBUG_GUARD) printf("Function map: func %d -> type %d\n", j, type_idx); func_type_map[j] = type_idx; + + // Step 4: Initialize FunctionInfo for each user-defined + // function func_idx starts from last_import_number + 1 + int actual_func_idx = last_import_number + 1 + j; + call_graph[actual_func_idx] = FunctionInfo(); + call_graph[actual_func_idx].func_idx = actual_func_idx; } } @@ -1217,9 +1271,6 @@ validateGuards( return {}; } - int64_t maxInstrCountHook = 0; - int64_t maxInstrCountCbak = 0; - // second pass... where we check all the guard function calls follow the // guard rules minimal other validation in this pass because first pass // caught most of it @@ -1253,6 +1304,7 @@ validateGuards( std::optional< std::reference_wrapper const>> first_signature; + bool helper_function = false; if (auto const& usage = import_type_map.find(j); usage != import_type_map.end()) { @@ -1288,7 +1340,7 @@ validateGuards( } } } - else if (j == hook_type_idx) + else if (j == hook_type_idx) // hook() or cbak() function type { // pass } @@ -1301,7 +1353,8 @@ validateGuards( << "Codesec: " << section_type << " " << "Local: " << j << " " << "Offset: " << i << "\n"; - return {}; + // return {}; + helper_function = true; } int param_count = parseLeb128(wasm, i, &i); @@ -1318,12 +1371,19 @@ validateGuards( return {}; } } + else if (helper_function) + { + // pass + } else if (param_count != (*first_signature).get().size() - 1) { GUARDLOG(hook::log::FUNC_TYPE_INVALID) << "Malformed transaction. " << "Hook API: " << *first_name - << " has the wrong number of parameters.\n"; + << " has the wrong number of parameters.\n" + << "param_count: " << param_count << " " + << "first_signature: " + << (*first_signature).get().size() - 1 << "\n"; return {}; } @@ -1370,6 +1430,10 @@ validateGuards( return {}; } } + else if (helper_function) + { + // pass + } else if ((*first_signature).get()[k + 1] != param_type) { GUARDLOG(hook::log::FUNC_PARAM_INVALID) @@ -1446,6 +1510,10 @@ validateGuards( return {}; } } + else if (helper_function) + { + // pass + } else if ((*first_signature).get()[0] != result_type) { GUARDLOG(hook::log::FUNC_RETURN_INVALID) @@ -1497,6 +1565,17 @@ validateGuards( // execution to here means we are up to the actual expr for the // codesec/function + // Step 5: Calculate actual function index and prepare callees + // tracking + int actual_func_idx = last_import_number + 1 + j; + std::set* out_callees_ptr = nullptr; + + // Only track callees if this function is in the call_graph + if (call_graph.find(actual_func_idx) != call_graph.end()) + { + out_callees_ptr = &call_graph[actual_func_idx].callees; + } + auto valid = check_guard( wasm, j, @@ -1506,33 +1585,188 @@ validateGuards( last_import_number, guardLog, guardLogAccStr, - rulesVersion); + rulesVersion, + out_callees_ptr); if (!valid) return {}; - if (hook_func_idx && *hook_func_idx == j) - maxInstrCountHook = *valid; - else if (cbak_func_idx && *cbak_func_idx == j) - maxInstrCountCbak = *valid; - else + // Step 5: Store local WCE and build bidirectional call + // relationships + if (call_graph.find(actual_func_idx) != call_graph.end()) { - if (DEBUG_GUARD) - printf( - "code section: %d not hook_func_idx: %d or " - "cbak_func_idx: %d\n", - j, - *hook_func_idx, - (cbak_func_idx ? *cbak_func_idx : -1)); - // assert(false); + call_graph[actual_func_idx].local_wce = *valid; + + // Build bidirectional relationships: for each callee, add + // this function as a caller + for (int callee_idx : call_graph[actual_func_idx].callees) + { + if (call_graph.find(callee_idx) != call_graph.end()) + { + call_graph[callee_idx].callers.insert( + actual_func_idx); + } + } } + + // Note: We will calculate total WCE later after processing all + // functions i = code_end; } } i = next_section; } - // execution to here means guards are installed correctly + // Step 6: Cycle detection using DFS + // Lambda function for DFS-based cycle detection + std::set visited; + std::set rec_stack; + std::function detect_cycles_dfs = [&](int func_idx) -> bool { + if (rec_stack.find(func_idx) != rec_stack.end()) + { + // Found a cycle: func_idx is already in the recursion stack + return true; + } - return std::pair{maxInstrCountHook, maxInstrCountCbak}; + if (visited.find(func_idx) != visited.end()) + { + // Already visited and no cycle found from this node + return false; + } + + visited.insert(func_idx); + rec_stack.insert(func_idx); + + // Check all callees + if (call_graph.find(func_idx) != call_graph.end()) + { + for (int callee_idx : call_graph[func_idx].callees) + { + if (detect_cycles_dfs(callee_idx)) + { + return true; + } + } + } + + rec_stack.erase(func_idx); + return false; + }; + + // Run cycle detection on all user-defined functions + for (const auto& [func_idx, func_info] : call_graph) + { + if (detect_cycles_dfs(func_idx)) + { + GUARDLOG(hook::log::CALL_ILLEGAL) + << "GuardCheck: Recursive function calls detected. " + << "Hooks cannot contain recursive or mutually recursive " + "functions.\n"; + return {}; + } + } + + // Step 7: Calculate total WCE for each function using bottom-up approach + // Lambda function for recursive WCE calculation with memoization + std::function calculate_function_wce = + [&](int func_idx) -> uint64_t { + // Check if function exists in call graph + if (call_graph.find(func_idx) == call_graph.end()) + { + // This is an imported function, WCE = 0 (already accounted for) + return 0; + } + + FunctionInfo& func_info = call_graph[func_idx]; + + // If already calculated, return cached result + if (func_info.wce_calculated) + { + return func_info.total_wce; + } + + // Detect circular dependency in WCE calculation (should not happen + // after cycle detection) + if (func_info.in_calculation) + { + GUARDLOG(hook::log::CALL_ILLEGAL) + << "GuardCheck: Internal error - circular dependency detected " + "during WCE calculation.\n"; + return 0xFFFFFFFFU; // Return large value to trigger overflow error + } + + func_info.in_calculation = true; + + // Start with local WCE + uint64_t total = func_info.local_wce; + + // Add WCE of all callees + for (int callee_idx : func_info.callees) + { + uint64_t callee_wce = calculate_function_wce(callee_idx); + + // Check for overflow + if (total > 0xFFFFU || callee_wce > 0xFFFFU || + (total + callee_wce) > 0xFFFFU) + { + func_info.in_calculation = false; + return 0xFFFFFFFFU; // Signal overflow + } + + total += callee_wce; + } + + func_info.total_wce = total; + func_info.wce_calculated = true; + func_info.in_calculation = false; + + return total; + }; + + // Calculate WCE for hook and cbak functions + int64_t hook_wce_actual = 0; + int64_t cbak_wce_actual = 0; + + if (hook_func_idx) + { + int actual_hook_idx = last_import_number + 1 + *hook_func_idx; + hook_wce_actual = calculate_function_wce(actual_hook_idx); + + if (hook_wce_actual >= 0xFFFFU) + { + GUARDLOG(hook::log::INSTRUCTION_EXCESS) + << "GuardCheck: hook() function exceeds maximum instruction " + "count (65535). " + << "Total WCE including called functions: " << hook_wce_actual + << "\n"; + return {}; + } + + if (DEBUG_GUARD) + printf("hook() total WCE: %ld\n", hook_wce_actual); + } + + if (cbak_func_idx) + { + int actual_cbak_idx = last_import_number + 1 + *cbak_func_idx; + cbak_wce_actual = calculate_function_wce(actual_cbak_idx); + + if (cbak_wce_actual >= 0xFFFFU) + { + GUARDLOG(hook::log::INSTRUCTION_EXCESS) + << "GuardCheck: cbak() function exceeds maximum instruction " + "count (65535). " + << "Total WCE including called functions: " << cbak_wce_actual + << "\n"; + return {}; + } + + if (DEBUG_GUARD) + printf("cbak() total WCE: %ld\n", cbak_wce_actual); + } + + // execution to here means guards are installed correctly and WCE is within + // limits + + return std::pair{hook_wce_actual, cbak_wce_actual}; } diff --git a/src/test/app/SetHook_test.cpp b/src/test/app/SetHook_test.cpp index 0c7be29e8..e6a4d589f 100644 --- a/src/test/app/SetHook_test.cpp +++ b/src/test/app/SetHook_test.cpp @@ -2570,6 +2570,255 @@ public: } } + void + testHelperFunctions(FeatureBitset features) + { + testcase("Test helper functions and recursion detection"); + using namespace jtx; + Env env{*this, features}; + + auto const alice = Account{"alice"}; + auto const bob = Account{"bob"}; + env.fund(XRP(10000), alice); + env.fund(XRP(10000), bob); + + // Test 1: Valid helper function without loops - should pass + { + TestHook hook = wasm[R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t simple_helper(int64_t x) { + return x + 1; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = simple_helper(5); + return accept(0, 0, result); + } + )[test.hook]"]; + + env(ripple::test::jtx::hook(alice, {{hso(hook, overrideFlag)}}, 0), + M("Valid helper function without loops"), + HSFEE, + ter(tesSUCCESS)); + env.close(); + } + + // Test 2: Helper function with guarded loop - should pass + { + TestHook hook = wasm[R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, int64_t error_code); + + __attribute__((noinline)) + static int64_t helper_with_loop(int64_t n) { + int64_t sum = 0; + for (int i = 0; i < 10; ++i) { + _g(2, 11); + sum += i; + } + return sum; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = helper_with_loop(5); + return accept(0, 0, result); + } + )[test.hook]"]; + + env(ripple::test::jtx::hook(alice, {{hso(hook, overrideFlag)}}, 0), + M("Helper function with guarded loop"), + HSFEE, + ter(tesSUCCESS)); + env.close(); + } + + // Test 3: Direct recursion - should fail + { + TestHook hook = wasm[R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t recursive_func(int64_t n) { + if (n <= 0) return 0; + return n + recursive_func(n - 1); + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = recursive_func(5); + return accept(0, 0, result); + } + )[test.hook]"]; + + env(ripple::test::jtx::hook(alice, {{hso(hook)}}, 0), + M("Direct recursion should fail"), + HSFEE, + ter(temMALFORMED)); + env.close(); + } + + // Test 4: Indirect recursion (A -> B -> A) - should fail + { + TestHook hook = wasm[R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t func_b(int64_t n); + + __attribute__((noinline)) + static int64_t func_a(int64_t n) { + if (n <= 0) return 0; + return n + func_b(n - 1); + } + + __attribute__((noinline)) + int64_t func_b(int64_t n) { + if (n <= 0) return 0; + return n + func_a(n - 1); + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = func_a(5); + return accept(0, 0, result); + } + )[test.hook]"]; + + env(ripple::test::jtx::hook(alice, {{hso(hook)}}, 0), + M("Indirect recursion should fail"), + HSFEE, + ter(temMALFORMED)); + env.close(); + } + + // Test 5: Deep call chain (A -> B -> C -> D) - should pass if WCE is OK + { + TestHook hook = wasm[R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t func_d(int64_t n) { + return n * 2; + } + + __attribute__((noinline)) + static int64_t func_c(int64_t n) { + return func_d(n) + 1; + } + + __attribute__((noinline)) + static int64_t func_b(int64_t n) { + return func_c(n) + 1; + } + + __attribute__((noinline)) + static int64_t func_a(int64_t n) { + return func_b(n) + 1; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = func_a(5); + return accept(0, 0, result); + } + )[test.hook]"]; + + env(ripple::test::jtx::hook(alice, {{hso(hook, overrideFlag)}}, 0), + M("Deep call chain without recursion"), + HSFEE, + ter(tesSUCCESS)); + env.close(); + } + + // Test 6: Helper called multiple times - WCE should accumulate + { + TestHook hook = wasm[R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t expensive_helper() { + int64_t sum = 0; + for (int i = 0; i < 100; ++i) { + _g(2, 101); + sum += i; + } + return sum; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = 0; + result += expensive_helper(); + result += expensive_helper(); + result += expensive_helper(); + return accept(0, 0, result); + } + )[test.hook]"]; + + env(ripple::test::jtx::hook(alice, {{hso(hook, overrideFlag)}}, 0), + M("Helper called multiple times"), + HSFEE, + ter(tesSUCCESS)); + env.close(); + } + + // Test 7: WCE overflow through many helpers - should fail + { + TestHook hook = wasm[R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t large_helper() { + int64_t sum = 0; + for (int i = 0; i < 10000; ++i) { + _g(2, 10001); + sum += i; + } + return sum; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = 0; + for (int i = 0; i < 10; ++i) { + _g(3, 11); + result += large_helper(); + } + return accept(0, 0, result); + } + )[test.hook]"]; + + env(ripple::test::jtx::hook(alice, {{hso(hook)}}, 0), + M("WCE overflow through helpers"), + HSFEE, + ter(temMALFORMED)); + env.close(); + } + } + void test_emit(FeatureBitset features) { @@ -13407,6 +13656,7 @@ public: test_rollback(features); testGuards(features); + testHelperFunctions(features); test_emit(features); // // test_etxn_burden(features); // tested above diff --git a/src/test/app/SetHook_wasm.h b/src/test/app/SetHook_wasm.h index 73294c9fb..d7433ad1b 100644 --- a/src/test/app/SetHook_wasm.h +++ b/src/test/app/SetHook_wasm.h @@ -543,6 +543,370 @@ std::map> wasm = { }}, /* ==== WASM: 6 ==== */ + {R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t simple_helper(int64_t x) { + return x + 1; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = simple_helper(5); + return accept(0, 0, result); + } + )[test.hook]", + { + 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x13U, + 0x03U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, + 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x02U, + 0x17U, 0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, + 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, + 0x70U, 0x74U, 0x00U, 0x01U, 0x03U, 0x02U, 0x01U, 0x02U, 0x05U, 0x03U, + 0x01U, 0x00U, 0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0x80U, + 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, + 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x88U, + 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, + 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x02U, 0x0AU, 0x9DU, + 0x80U, 0x00U, 0x01U, 0x99U, 0x80U, 0x00U, 0x00U, 0x41U, 0x01U, 0x41U, + 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x00U, + 0x41U, 0x00U, 0x42U, 0x06U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x0BU, + }}, + + /* ==== WASM: 7 ==== */ + {R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, int64_t error_code); + + __attribute__((noinline)) + static int64_t helper_with_loop(int64_t n) { + int64_t sum = 0; + for (int i = 0; i < 10; ++i) { + _g(2, 11); + sum += i; + } + return sum; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = helper_with_loop(5); + return accept(0, 0, result); + } + )[test.hook]", + { + 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x17U, + 0x04U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, + 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, + 0x00U, 0x01U, 0x7EU, 0x02U, 0x17U, 0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, + 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, + 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x01U, 0x03U, 0x03U, + 0x02U, 0x02U, 0x03U, 0x05U, 0x03U, 0x01U, 0x00U, 0x02U, 0x06U, 0x21U, + 0x05U, 0x7FU, 0x01U, 0x41U, 0x80U, 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, + 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, + 0x7FU, 0x00U, 0x41U, 0x80U, 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, + 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, + 0x6BU, 0x00U, 0x02U, 0x0AU, 0x96U, 0x81U, 0x00U, 0x02U, 0x9DU, 0x80U, + 0x00U, 0x00U, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x1AU, 0x41U, 0x00U, 0x41U, 0x00U, 0x10U, 0x83U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, + 0xF2U, 0x80U, 0x00U, 0x00U, 0x41U, 0x02U, 0x41U, 0x0BU, 0x10U, 0x80U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x02U, 0x41U, 0x0BU, 0x10U, + 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x02U, 0x41U, 0x0BU, + 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x02U, 0x41U, + 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x02U, + 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, + 0x02U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, + 0x41U, 0x02U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x1AU, 0x41U, 0x02U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, + 0x00U, 0x1AU, 0x41U, 0x02U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x1AU, 0x41U, 0x02U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x1AU, 0x42U, 0x2DU, 0x0BU, + }}, + + /* ==== WASM: 8 ==== */ + {R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t recursive_func(int64_t n) { + if (n <= 0) return 0; + return n + recursive_func(n - 1); + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = recursive_func(5); + return accept(0, 0, result); + } + )[test.hook]", + { + 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x20U, + 0x05U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, + 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x05U, 0x7FU, 0x7EU, 0x7EU, 0x7EU, + 0x7EU, 0x00U, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7EU, + 0x01U, 0x7EU, 0x02U, 0x26U, 0x03U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x02U, + 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, + 0x63U, 0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, + 0x76U, 0x08U, 0x5FU, 0x5FU, 0x6DU, 0x75U, 0x6CU, 0x74U, 0x69U, 0x33U, + 0x00U, 0x02U, 0x03U, 0x03U, 0x02U, 0x03U, 0x04U, 0x05U, 0x03U, 0x01U, + 0x00U, 0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0x80U, 0x88U, + 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, + 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x88U, 0x04U, + 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, + 0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x03U, 0x0AU, 0x94U, 0x81U, + 0x00U, 0x02U, 0x9FU, 0x80U, 0x00U, 0x00U, 0x41U, 0x01U, 0x41U, 0x01U, + 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x00U, 0x41U, + 0x00U, 0x42U, 0x05U, 0x10U, 0x84U, 0x80U, 0x80U, 0x80U, 0x00U, 0x10U, + 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, 0xEEU, 0x80U, 0x00U, 0x02U, + 0x01U, 0x7FU, 0x01U, 0x7EU, 0x23U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x41U, 0x10U, 0x6BU, 0x22U, 0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, + 0x00U, 0x02U, 0x40U, 0x02U, 0x40U, 0x20U, 0x00U, 0x42U, 0x01U, 0x59U, + 0x0DU, 0x00U, 0x42U, 0x00U, 0x21U, 0x00U, 0x0CU, 0x01U, 0x0BU, 0x20U, + 0x01U, 0x20U, 0x00U, 0x42U, 0x7EU, 0x7CU, 0x42U, 0x00U, 0x20U, 0x00U, + 0x42U, 0x7FU, 0x7CU, 0x22U, 0x02U, 0x42U, 0x00U, 0x10U, 0x82U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x20U, 0x02U, 0x20U, 0x02U, 0x7EU, 0x20U, 0x00U, + 0x7CU, 0x20U, 0x01U, 0x29U, 0x03U, 0x00U, 0x42U, 0x01U, 0x88U, 0x20U, + 0x01U, 0x41U, 0x08U, 0x6AU, 0x29U, 0x03U, 0x00U, 0x42U, 0x3FU, 0x86U, + 0x84U, 0x7DU, 0x21U, 0x00U, 0x0BU, 0x20U, 0x01U, 0x41U, 0x10U, 0x6AU, + 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x00U, 0x0BU, + }}, + + /* ==== WASM: 9 ==== */ + {R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t func_b(int64_t n); + + __attribute__((noinline)) + static int64_t func_a(int64_t n) { + if (n <= 0) return 0; + return n + func_b(n - 1); + } + + __attribute__((noinline)) + int64_t func_b(int64_t n) { + if (n <= 0) return 0; + return n + func_a(n - 1); + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = func_a(5); + return accept(0, 0, result); + } + )[test.hook]", + { + 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x18U, + 0x04U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, + 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, + 0x01U, 0x7EU, 0x01U, 0x7EU, 0x02U, 0x17U, 0x02U, 0x03U, 0x65U, 0x6EU, + 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, + 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x01U, 0x03U, + 0x04U, 0x03U, 0x02U, 0x03U, 0x03U, 0x05U, 0x03U, 0x01U, 0x00U, 0x02U, + 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0x80U, 0x88U, 0x04U, 0x0BU, + 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, + 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x88U, 0x04U, 0x0BU, 0x7FU, + 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U, 0x68U, + 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x02U, 0x0AU, 0xE3U, 0x80U, 0x00U, 0x03U, + 0x9FU, 0x80U, 0x00U, 0x00U, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, + 0x05U, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x10U, 0x81U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x0BU, 0x9DU, 0x80U, 0x00U, 0x00U, 0x02U, 0x40U, + 0x20U, 0x00U, 0x42U, 0x01U, 0x59U, 0x0DU, 0x00U, 0x42U, 0x00U, 0x0FU, + 0x0BU, 0x20U, 0x00U, 0x42U, 0x7FU, 0x7CU, 0x10U, 0x84U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x20U, 0x00U, 0x7CU, 0x0BU, 0x9DU, 0x80U, 0x00U, 0x00U, + 0x02U, 0x40U, 0x20U, 0x00U, 0x42U, 0x01U, 0x59U, 0x0DU, 0x00U, 0x42U, + 0x00U, 0x0FU, 0x0BU, 0x20U, 0x00U, 0x42U, 0x7FU, 0x7CU, 0x10U, 0x83U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x00U, 0x7CU, 0x0BU, + }}, + + /* ==== WASM: 10 ==== */ + {R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t func_d(int64_t n) { + return n * 2; + } + + __attribute__((noinline)) + static int64_t func_c(int64_t n) { + return func_d(n) + 1; + } + + __attribute__((noinline)) + static int64_t func_b(int64_t n) { + return func_c(n) + 1; + } + + __attribute__((noinline)) + static int64_t func_a(int64_t n) { + return func_b(n) + 1; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = func_a(5); + return accept(0, 0, result); + } + )[test.hook]", + { + 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x13U, + 0x03U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, + 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x02U, + 0x17U, 0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, + 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, + 0x70U, 0x74U, 0x00U, 0x01U, 0x03U, 0x02U, 0x01U, 0x02U, 0x05U, 0x03U, + 0x01U, 0x00U, 0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0x80U, + 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, + 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x88U, + 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, + 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x02U, 0x0AU, 0x9DU, + 0x80U, 0x00U, 0x01U, 0x99U, 0x80U, 0x00U, 0x00U, 0x41U, 0x01U, 0x41U, + 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x00U, + 0x41U, 0x00U, 0x42U, 0x0DU, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x0BU, + }}, + + /* ==== WASM: 11 ==== */ + {R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t expensive_helper() { + int64_t sum = 0; + for (int i = 0; i < 100; ++i) { + _g(2, 101); + sum += i; + } + return sum; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = 0; + result += expensive_helper(); + result += expensive_helper(); + result += expensive_helper(); + return accept(0, 0, result); + } + )[test.hook]", + { + 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x17U, + 0x04U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, + 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, + 0x00U, 0x01U, 0x7EU, 0x02U, 0x17U, 0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, + 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, + 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x01U, 0x03U, 0x03U, + 0x02U, 0x02U, 0x03U, 0x05U, 0x03U, 0x01U, 0x00U, 0x02U, 0x06U, 0x21U, + 0x05U, 0x7FU, 0x01U, 0x41U, 0x80U, 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, + 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, + 0x7FU, 0x00U, 0x41U, 0x80U, 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, + 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, + 0x6BU, 0x00U, 0x02U, 0x0AU, 0xD8U, 0x80U, 0x00U, 0x02U, 0xABU, 0x80U, + 0x00U, 0x00U, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x1AU, 0x41U, 0x00U, 0x41U, 0x00U, 0x10U, 0x83U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x7CU, + 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x7CU, 0x10U, 0x81U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x0BU, 0xA6U, 0x80U, 0x00U, 0x01U, 0x01U, 0x7EU, + 0x42U, 0xE4U, 0x00U, 0x21U, 0x00U, 0x03U, 0x40U, 0x41U, 0x02U, 0x41U, + 0xE5U, 0x00U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, + 0x00U, 0x42U, 0x7FU, 0x7CU, 0x22U, 0x00U, 0x50U, 0x45U, 0x0DU, 0x00U, + 0x0BU, 0x42U, 0xD6U, 0x26U, 0x0BU, + }}, + + /* ==== WASM: 12 ==== */ + {R"[test.hook]( + #include + extern int32_t _g(uint32_t id, uint32_t maxiter); + extern int64_t accept(uint32_t read_ptr, uint32_t read_len, + int64_t error_code); + + __attribute__((noinline)) + static int64_t large_helper() { + int64_t sum = 0; + for (int i = 0; i < 10000; ++i) { + _g(2, 10001); + sum += i; + } + return sum; + } + + int64_t hook(uint32_t reserved) { + _g(1,1); + int64_t result = 0; + for (int i = 0; i < 10; ++i) { + _g(3, 11); + result += large_helper(); + } + return accept(0, 0, result); + } + )[test.hook]", + { + 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x17U, + 0x04U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, + 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, + 0x00U, 0x01U, 0x7EU, 0x02U, 0x17U, 0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, + 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, + 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x01U, 0x03U, 0x03U, + 0x02U, 0x02U, 0x03U, 0x05U, 0x03U, 0x01U, 0x00U, 0x02U, 0x06U, 0x21U, + 0x05U, 0x7FU, 0x01U, 0x41U, 0x80U, 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, + 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, + 0x7FU, 0x00U, 0x41U, 0x80U, 0x88U, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, + 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, + 0x6BU, 0x00U, 0x02U, 0x0AU, 0xA1U, 0x82U, 0x00U, 0x02U, 0xF0U, 0x81U, + 0x00U, 0x01U, 0x09U, 0x7EU, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x03U, 0x41U, 0x0BU, 0x10U, + 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x10U, 0x83U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x21U, 0x01U, 0x41U, 0x03U, 0x41U, 0x0BU, 0x10U, 0x80U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, + 0x00U, 0x21U, 0x02U, 0x41U, 0x03U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, + 0x80U, 0x80U, 0x00U, 0x1AU, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x21U, 0x03U, 0x41U, 0x03U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, + 0x80U, 0x00U, 0x1AU, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, + 0x04U, 0x41U, 0x03U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, + 0x00U, 0x1AU, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x05U, + 0x41U, 0x03U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x1AU, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x06U, 0x41U, + 0x03U, 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, + 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x07U, 0x41U, 0x03U, + 0x41U, 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x10U, + 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x08U, 0x41U, 0x03U, 0x41U, + 0x0BU, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x10U, 0x83U, + 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x09U, 0x41U, 0x03U, 0x41U, 0x0BU, + 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x41U, 0x00U, 0x41U, + 0x00U, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x09U, 0x20U, + 0x08U, 0x20U, 0x07U, 0x20U, 0x06U, 0x20U, 0x05U, 0x20U, 0x04U, 0x20U, + 0x03U, 0x20U, 0x02U, 0x20U, 0x01U, 0x7CU, 0x7CU, 0x7CU, 0x7CU, 0x7CU, + 0x7CU, 0x7CU, 0x7CU, 0x7CU, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, + 0x0BU, 0xAAU, 0x80U, 0x00U, 0x01U, 0x01U, 0x7EU, 0x42U, 0x90U, 0xCEU, + 0x00U, 0x21U, 0x00U, 0x03U, 0x40U, 0x41U, 0x02U, 0x41U, 0x91U, 0xCEU, + 0x00U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x00U, + 0x42U, 0x7FU, 0x7CU, 0x22U, 0x00U, 0x50U, 0x45U, 0x0DU, 0x00U, 0x0BU, + 0x42U, 0xF8U, 0xB9U, 0xEBU, 0x17U, 0x0BU, + }}, + + /* ==== WASM: 13 ==== */ {R"[test.hook]( #include extern int32_t _g(uint32_t, uint32_t); @@ -1159,7 +1523,7 @@ std::map> wasm = { 0x78U, 0x29U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 7 ==== */ + /* ==== WASM: 14 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1264,7 +1628,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 8 ==== */ + /* ==== WASM: 15 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1386,7 +1750,7 @@ std::map> wasm = { 0x58U, 0x4EU, 0x00U, }}, - /* ==== WASM: 9 ==== */ + /* ==== WASM: 16 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1509,7 +1873,7 @@ std::map> wasm = { 0x4EU, 0x59U, 0x5FU, 0x4EU, 0x4FU, 0x4EU, 0x43U, 0x45U, 0x53U, 0x00U, }}, - /* ==== WASM: 10 ==== */ + /* ==== WASM: 17 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1589,7 +1953,7 @@ std::map> wasm = { 0x54U, 0x00U, }}, - /* ==== WASM: 11 ==== */ + /* ==== WASM: 18 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1634,7 +1998,7 @@ std::map> wasm = { 0x30U, 0x00U, }}, - /* ==== WASM: 12 ==== */ + /* ==== WASM: 19 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -1953,7 +2317,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 13 ==== */ + /* ==== WASM: 20 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -2739,7 +3103,7 @@ std::map> wasm = { 0x37U, 0x36U, 0x33U, 0x4CU, 0x4CU, 0x20U, 0x29U, 0x00U, }}, - /* ==== WASM: 14 ==== */ + /* ==== WASM: 21 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -3129,7 +3493,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 15 ==== */ + /* ==== WASM: 22 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -3310,7 +3674,7 @@ std::map> wasm = { 0x38U, 0x4CU, 0x4CU, 0x29U, 0x00U, }}, - /* ==== WASM: 16 ==== */ + /* ==== WASM: 23 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -3499,7 +3863,7 @@ std::map> wasm = { 0x29U, 0x00U, }}, - /* ==== WASM: 17 ==== */ + /* ==== WASM: 24 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -3738,7 +4102,7 @@ std::map> wasm = { 0x00U, 0x42U, 0x00U, 0x10U, 0x85U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 18 ==== */ + /* ==== WASM: 25 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -4440,7 +4804,7 @@ std::map> wasm = { 0x38U, 0x35U, 0x35U, 0x32U, 0x55U, 0x29U, 0x00U, }}, - /* ==== WASM: 19 ==== */ + /* ==== WASM: 26 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -5785,7 +6149,7 @@ std::map> wasm = { 0x20U, 0x29U, 0x00U, }}, - /* ==== WASM: 20 ==== */ + /* ==== WASM: 27 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -5887,7 +6251,7 @@ std::map> wasm = { 0x84U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 21 ==== */ + /* ==== WASM: 28 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -5930,7 +6294,7 @@ std::map> wasm = { 0x00U, 0x0BU, }}, - /* ==== WASM: 22 ==== */ + /* ==== WASM: 29 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -6078,7 +6442,7 @@ std::map> wasm = { 0x34U, 0x34U, 0x4CU, 0x4CU, 0x2CU, 0x20U, 0x33U, 0x29U, 0x00U, }}, - /* ==== WASM: 23 ==== */ + /* ==== WASM: 30 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -6406,7 +6770,7 @@ std::map> wasm = { 0x38U, 0x34U, 0x39U, 0x30U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 24 ==== */ + /* ==== WASM: 31 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -6611,7 +6975,7 @@ std::map> wasm = { 0x10U, 0x85U, 0x80U, 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 25 ==== */ + /* ==== WASM: 32 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -7295,7 +7659,7 @@ std::map> wasm = { 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 26 ==== */ + /* ==== WASM: 33 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -7590,7 +7954,7 @@ std::map> wasm = { 0x32U, 0x34U, 0x31U, 0x36U, 0x55U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 27 ==== */ + /* ==== WASM: 34 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8303,7 +8667,7 @@ std::map> wasm = { 0x31U, 0x33U, 0x33U, 0x38U, 0x20U, 0x29U, 0x00U, }}, - /* ==== WASM: 28 ==== */ + /* ==== WASM: 35 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8388,7 +8752,7 @@ std::map> wasm = { 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x32U, 0x30U, 0x00U, }}, - /* ==== WASM: 29 ==== */ + /* ==== WASM: 36 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8450,7 +8814,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x00U, 0x0BU, }}, - /* ==== WASM: 30 ==== */ + /* ==== WASM: 37 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8527,7 +8891,7 @@ std::map> wasm = { 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 31 ==== */ + /* ==== WASM: 38 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8604,7 +8968,7 @@ std::map> wasm = { 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 32 ==== */ + /* ==== WASM: 39 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -8861,7 +9225,7 @@ std::map> wasm = { 0x00U, 0x00U, }}, - /* ==== WASM: 33 ==== */ + /* ==== WASM: 40 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9019,7 +9383,7 @@ std::map> wasm = { 0x04U, 0x00U, 0x00U, }}, - /* ==== WASM: 34 ==== */ + /* ==== WASM: 41 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9372,7 +9736,7 @@ std::map> wasm = { 0x00U, 0x2AU, 0x04U, 0x00U, 0x00U, 0x31U, 0x04U, 0x00U, 0x00U, }}, - /* ==== WASM: 35 ==== */ + /* ==== WASM: 42 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9405,7 +9769,7 @@ std::map> wasm = { 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x0BU, }}, - /* ==== WASM: 36 ==== */ + /* ==== WASM: 43 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9632,7 +9996,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 37 ==== */ + /* ==== WASM: 44 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9663,7 +10027,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x0BU, }}, - /* ==== WASM: 38 ==== */ + /* ==== WASM: 45 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -9974,7 +10338,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 39 ==== */ + /* ==== WASM: 46 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10051,7 +10415,7 @@ std::map> wasm = { 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 40 ==== */ + /* ==== WASM: 47 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10085,7 +10449,7 @@ std::map> wasm = { 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U, 0x0BU, }}, - /* ==== WASM: 41 ==== */ + /* ==== WASM: 48 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10172,7 +10536,7 @@ std::map> wasm = { 0x32U, 0x00U, }}, - /* ==== WASM: 42 ==== */ + /* ==== WASM: 49 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10206,7 +10570,7 @@ std::map> wasm = { 0x0BU, }}, - /* ==== WASM: 43 ==== */ + /* ==== WASM: 50 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10346,7 +10710,7 @@ std::map> wasm = { 0x54U, 0x5FU, 0x4DU, 0x45U, 0x54U, 0x00U, }}, - /* ==== WASM: 44 ==== */ + /* ==== WASM: 51 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10536,7 +10900,7 @@ std::map> wasm = { 0x31U, 0x34U, 0x00U, }}, - /* ==== WASM: 45 ==== */ + /* ==== WASM: 52 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10690,7 +11054,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 46 ==== */ + /* ==== WASM: 53 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -10851,7 +11215,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 47 ==== */ + /* ==== WASM: 54 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11008,7 +11372,7 @@ std::map> wasm = { 0x53U, 0x4CU, 0x4FU, 0x54U, 0x53U, 0x00U, }}, - /* ==== WASM: 48 ==== */ + /* ==== WASM: 55 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11093,7 +11457,7 @@ std::map> wasm = { 0x74U, 0x79U, 0x70U, 0x65U, 0x28U, 0x29U, 0x00U, }}, - /* ==== WASM: 49 ==== */ + /* ==== WASM: 56 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11350,7 +11714,7 @@ std::map> wasm = { 0x00U, 0x00U, }}, - /* ==== WASM: 50 ==== */ + /* ==== WASM: 57 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11588,7 +11952,7 @@ std::map> wasm = { 0x3EU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 51 ==== */ + /* ==== WASM: 58 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11684,7 +12048,7 @@ std::map> wasm = { 0x53U, 0x54U, 0x00U, }}, - /* ==== WASM: 52 ==== */ + /* ==== WASM: 59 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11794,7 +12158,7 @@ std::map> wasm = { 0x20U, 0x31U, 0x00U, }}, - /* ==== WASM: 53 ==== */ + /* ==== WASM: 60 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -11924,7 +12288,7 @@ std::map> wasm = { 0x30U, 0x30U, 0x30U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 54 ==== */ + /* ==== WASM: 61 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -12198,7 +12562,7 @@ std::map> wasm = { 0x30U, 0x00U, }}, - /* ==== WASM: 55 ==== */ + /* ==== WASM: 62 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -12335,7 +12699,7 @@ std::map> wasm = { 0x2CU, 0x20U, 0x73U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x31U, 0x00U, }}, - /* ==== WASM: 56 ==== */ + /* ==== WASM: 63 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -12629,7 +12993,7 @@ std::map> wasm = { 0x5FU, 0x53U, 0x4CU, 0x4FU, 0x54U, 0x53U, 0x00U, }}, - /* ==== WASM: 57 ==== */ + /* ==== WASM: 64 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -12863,7 +13227,7 @@ std::map> wasm = { 0x5FU, 0x53U, 0x4CU, 0x4FU, 0x54U, 0x53U, 0x00U, }}, - /* ==== WASM: 58 ==== */ + /* ==== WASM: 65 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13159,7 +13523,7 @@ std::map> wasm = { 0x2CU, 0x20U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 59 ==== */ + /* ==== WASM: 66 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13363,7 +13727,7 @@ std::map> wasm = { 0x6EU, 0x74U, 0x32U, 0x22U, 0x20U, 0x2BU, 0x20U, 0x69U, 0x29U, 0x00U, }}, - /* ==== WASM: 60 ==== */ + /* ==== WASM: 67 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13480,7 +13844,7 @@ std::map> wasm = { 0x69U, 0x29U, 0x00U, }}, - /* ==== WASM: 61 ==== */ + /* ==== WASM: 68 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13589,7 +13953,7 @@ std::map> wasm = { 0x6EU, 0x74U, 0x65U, 0x6EU, 0x74U, 0x32U, 0x22U, 0x29U, 0x00U, }}, - /* ==== WASM: 62 ==== */ + /* ==== WASM: 69 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -13862,7 +14226,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 63 ==== */ + /* ==== WASM: 70 ==== */ {R"[test.hook]( #include #define sfInvoiceID ((5U << 16U) + 17U) @@ -14081,7 +14445,7 @@ std::map> wasm = { 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 64 ==== */ + /* ==== WASM: 71 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14193,7 +14557,7 @@ std::map> wasm = { 0x58U, 0x49U, 0x53U, 0x54U, 0x00U, }}, - /* ==== WASM: 65 ==== */ + /* ==== WASM: 72 ==== */ {R"[test.hook]( #include #define sfInvoiceID ((5U << 16U) + 17U) @@ -14329,7 +14693,7 @@ std::map> wasm = { 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 66 ==== */ + /* ==== WASM: 73 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14465,7 +14829,7 @@ std::map> wasm = { 0x49U, 0x47U, 0x00U, }}, - /* ==== WASM: 67 ==== */ + /* ==== WASM: 74 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14604,7 +14968,7 @@ std::map> wasm = { 0x66U, 0x28U, 0x64U, 0x61U, 0x74U, 0x61U, 0x32U, 0x29U, 0x00U, }}, - /* ==== WASM: 68 ==== */ + /* ==== WASM: 75 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14716,7 +15080,7 @@ std::map> wasm = { 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 69 ==== */ + /* ==== WASM: 76 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14810,7 +15174,7 @@ std::map> wasm = { 0x61U, 0x64U, 0x5BU, 0x69U, 0x5DU, 0x00U, }}, - /* ==== WASM: 70 ==== */ + /* ==== WASM: 77 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -14943,7 +15307,7 @@ std::map> wasm = { 0x64U, 0x5BU, 0x69U, 0x5DU, 0x00U, }}, - /* ==== WASM: 71 ==== */ + /* ==== WASM: 78 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -15031,7 +15395,7 @@ std::map> wasm = { 0x61U, 0x74U, 0x61U, 0x29U, 0x00U, }}, - /* ==== WASM: 72 ==== */ + /* ==== WASM: 79 ==== */ {R"[test.hook]( #include #define sfInvoiceID ((5U << 16U) + 17U) @@ -15142,7 +15506,7 @@ std::map> wasm = { 0x20U, 0x33U, 0x32U, 0x00U, }}, - /* ==== WASM: 73 ==== */ + /* ==== WASM: 80 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -15353,7 +15717,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 74 ==== */ + /* ==== WASM: 81 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -15461,7 +15825,7 @@ std::map> wasm = { 0x20U, 0x22U, 0x32U, 0x22U, 0x2CU, 0x20U, 0x31U, 0x29U, 0x00U, }}, - /* ==== WASM: 75 ==== */ + /* ==== WASM: 82 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16073,7 +16437,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 76 ==== */ + /* ==== WASM: 83 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16260,7 +16624,7 @@ std::map> wasm = { 0x63U, 0x65U, 0x29U, 0x20U, 0x3EU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 77 ==== */ + /* ==== WASM: 84 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16610,7 +16974,7 @@ std::map> wasm = { 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 78 ==== */ + /* ==== WASM: 85 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16746,7 +17110,7 @@ std::map> wasm = { 0x00U, }}, - /* ==== WASM: 79 ==== */ + /* ==== WASM: 86 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16805,7 +17169,7 @@ std::map> wasm = { 0x64U, 0xE1U, 0xF1U, }}, - /* ==== WASM: 79 ==== */ + /* ==== WASM: 87 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -16978,7 +17342,7 @@ std::map> wasm = { 0x54U, 0x5FU, 0x45U, 0x58U, 0x49U, 0x53U, 0x54U, 0x00U, }}, - /* ==== WASM: 80 ==== */ + /* ==== WASM: 88 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -17126,7 +17490,7 @@ std::map> wasm = { 0x30U, 0x00U, 0x22U, 0x00U, 0x00U, 0x00U, 0x00U, }}, - /* ==== WASM: 81 ==== */ + /* ==== WASM: 89 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -17223,7 +17587,7 @@ std::map> wasm = { 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 82 ==== */ + /* ==== WASM: 90 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -17282,7 +17646,7 @@ std::map> wasm = { 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, }}, - /* ==== WASM: 83 ==== */ + /* ==== WASM: 91 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -17341,7 +17705,7 @@ std::map> wasm = { 0x4EU, 0x44U, 0x53U, 0x00U, }}, - /* ==== WASM: 84 ==== */ + /* ==== WASM: 92 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -19170,7 +19534,7 @@ std::map> wasm = { 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 85 ==== */ + /* ==== WASM: 93 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -20512,7 +20876,7 @@ std::map> wasm = { 0x20U, 0x30U, 0x2CU, 0x20U, 0x30U, 0x29U, 0x29U, 0x00U, }}, - /* ==== WASM: 86 ==== */ + /* ==== WASM: 94 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -23445,7 +23809,7 @@ std::map> wasm = { 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 87 ==== */ + /* ==== WASM: 95 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -25410,7 +25774,7 @@ std::map> wasm = { 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, }}, - /* ==== WASM: 88 ==== */ + /* ==== WASM: 96 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -25695,7 +26059,7 @@ std::map> wasm = { 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x00U, }}, - /* ==== WASM: 89 ==== */ + /* ==== WASM: 97 ==== */ {R"[test.hook]( #include extern int32_t _g(uint32_t, uint32_t); @@ -26282,7 +26646,7 @@ std::map> wasm = { 0x4EU, 0x5FU, 0x46U, 0x41U, 0x49U, 0x4CU, 0x55U, 0x52U, 0x45U, 0x00U, }}, - /* ==== WASM: 90 ==== */ + /* ==== WASM: 98 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -26311,7 +26675,7 @@ std::map> wasm = { 0x0BU, }}, - /* ==== WASM: 91 ==== */ + /* ==== WASM: 99 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -26343,7 +26707,7 @@ std::map> wasm = { 0x20U, 0x52U, 0x65U, 0x6AU, 0x65U, 0x63U, 0x74U, 0x65U, 0x64U, 0x00U, }}, - /* ==== WASM: 92 ==== */ + /* ==== WASM: 100 ==== */ {R"[test.hook]( (module (type (;0;) (func (param i32 i32 i64) (result i64))) @@ -26370,7 +26734,7 @@ std::map> wasm = { 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U, 0x00U, 0x0BU, }}, - /* ==== WASM: 93 ==== */ + /* ==== WASM: 101 ==== */ {R"[test.hook]( (module (type (;0;) (func (param i32 i32) (result i32))) @@ -26423,7 +26787,7 @@ std::map> wasm = { 0x00U, 0x1AU, 0x0BU, }}, - /* ==== WASM: 94 ==== */ + /* ==== WASM: 102 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -33066,7 +33430,7 @@ std::map> wasm = { 0x39U, 0x30U, 0x31U, 0x32U, 0x33U, 0x00U, }}, - /* ==== WASM: 95 ==== */ + /* ==== WASM: 103 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); @@ -33112,7 +33476,7 @@ std::map> wasm = { 0x0BU, 0x06U, 0x76U, 0x61U, 0x6CU, 0x75U, 0x65U, 0x00U, }}, - /* ==== WASM: 96 ==== */ + /* ==== WASM: 104 ==== */ {R"[test.hook]( #include extern int32_t _g (uint32_t id, uint32_t maxiter); diff --git a/src/test/app/build_test_hooks.sh b/src/test/app/build_test_hooks.sh index 4e57701a8..2110d4b13 100755 --- a/src/test/app/build_test_hooks.sh +++ b/src/test/app/build_test_hooks.sh @@ -58,8 +58,21 @@ cat $INPUT_FILE | tr '\n' '\f' | then echo '#include "api.h"' > "$WASM_DIR/test-$COUNTER-gen.c" tr '\f' '\n' <<< $line >> "$WASM_DIR/test-$COUNTER-gen.c" - DECLARED="`tr '\f' '\n' <<< $line | grep -E '(extern|define) ' | grep -Eo '[a-z\-\_]+ *\(' | grep -v 'sizeof' | sed -E 's/[^a-z\-\_]//g' | sort | uniq`" - USED="`tr '\f' '\n' <<< $line | grep -vE '(extern|define) ' | grep -Eo '[a-z\-\_]+\(' | grep -v 'sizeof' | sed -E 's/[^a-z\-\_]//g' | grep -vE '^(hook|cbak)' | sort | uniq`" + DECLARED="`tr '\f' '\n' <<< $line \ + | grep -E '(extern|static|define) ' \ + | grep -Eo '[a-z\-\_]+ *\(' \ + | grep -v 'sizeof' \ + | sed -E 's/[^a-z\-\_]//g' \ + | grep -vE '^__attribute__$' \ + | sort | uniq`" + + USED="`tr '\f' '\n' <<< $line \ + | grep -vE '(extern|static|define) ' \ + | grep -Eo '[a-z\-\_]+\(' \ + | grep -v 'sizeof' \ + | sed -E 's/[^a-z\-\_]//g' \ + | grep -vE '^(__attribute__|hook|cbak)$' \ + | sort | uniq`" ONCE="`echo $DECLARED $USED | tr ' ' '\n' | sort | uniq -c | grep '1 ' | sed -E 's/^ *1 //g'`" FILTER="`echo $DECLARED | tr ' ' '|' | sed -E 's/\|$//g'`" UNDECL="`echo $ONCE | grep -v -E $FILTER 2>/dev/null || echo ''`" @@ -69,7 +82,7 @@ cat $INPUT_FILE | tr '\n' '\f' | echo "$line" exit 1 fi - wasmcc -x c /dev/stdin -o /dev/stdout -O2 -Wl,--allow-undefined <<< "`tr '\f' '\n' <<< $line`" | + wasmcc -x c /dev/stdin -o /dev/stdout -O2 -Wl,--allow-undefined,--export=hook,--export=cbak <<< "`tr '\f' '\n' <<< $line`" | hook-cleaner - - 2>/dev/null | xxd -p -u -c 10 | sed -E 's/../0x&U,/g' | sed -E 's/^/ /g' >> $OUTPUT_FILE