Skip to content

Commit 2458c41

Browse files
authored
Supply fuzz imports to second modules as well (#8705)
Update execution-results.h to supply standard fuzzing imports, including imported externref globals materialized on demand, to second modules. This matches the behavior of fuzz_shell.js, which already makes these imports available to both modules.
1 parent 332a49f commit 2458c41

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/tools/execution-results.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,10 @@ struct ExecutionResults {
470470
secondInterface = std::make_unique<LoggingExternalInterface>(
471471
loggings, *second, linkedInstances);
472472
secondInstance = std::make_shared<ModuleRunner>(
473-
*second, secondInterface.get(), linkedInstances);
473+
*second,
474+
secondInterface.get(),
475+
linkedInstances,
476+
std::make_shared<FuzzerImportResolver>(linkedInstances));
474477
instantiate(*secondInstance, *secondInterface);
475478
}
476479

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
;; RUN: wasm-opt %s -all --fuzz-exec-before --fuzz-exec-second=%s.second -q -o /dev/null 2>&1 | filecheck %s
2+
3+
;; Check that imported externref globals work in second modules as well.
4+
5+
(module
6+
(import "__fuzz_import" "extern$" (global $gimport$0 externref))
7+
8+
(func (export "check") (result i32)
9+
(ref.is_null (global.get $gimport$0))
10+
)
11+
)
12+
13+
;; CHECK: [fuzz-exec] export check
14+
;; CHECK-NEXT: [fuzz-exec] note result: check => 0
15+
;; CHECK: [fuzz-exec] export check_second
16+
;; CHECK-NEXT: [fuzz-exec] note result: check_second => 0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(module
2+
(import "__fuzz_import" "extern$" (global $gimport$0 externref))
3+
4+
(func (export "check_second") (result i32)
5+
(ref.is_null (global.get $gimport$0))
6+
)
7+
)

0 commit comments

Comments
 (0)