diff options
author | Alon Zakai <azakai@google.com> | 2024-11-07 14:28:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-07 14:28:59 -0800 |
commit | 7a0e738e363d13880ec25018134e178d57c5ba6a (patch) | |
tree | a7567d6f7d460b87153f3a7c29e40777639a154f /src/tools | |
parent | d01620f88748825e136495824ce7f7312d90966d (diff) | |
download | binaryen-7a0e738e363d13880ec25018134e178d57c5ba6a.tar.gz binaryen-7a0e738e363d13880ec25018134e178d57c5ba6a.tar.bz2 binaryen-7a0e738e363d13880ec25018134e178d57c5ba6a.zip |
[wasm64] Fix copying of 64-bit tables, and fuzz them (#7065)
`ModuleUtils::copyTable` was not copying the `indexType` property.
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 26c321961..ed3287a7c 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -370,8 +370,26 @@ void TranslateToFuzzReader::setupTables() { if (iter != wasm.tables.end()) { table = iter->get(); } else { - auto tablePtr = builder.makeTable( - Names::getValidTableName(wasm, "fuzzing_table"), funcref, 0, 0); + // Start from a potentially empty table. + Address initial = upTo(10); + // Make the max potentially higher, or unlimited. + Address max; + if (oneIn(2)) { + max = initial + upTo(4); + } else { + max = Memory::kUnlimitedSize; + } + // Fuzz wasm64 when possible, sometimes. + auto indexType = Type::i32; + if (wasm.features.hasMemory64() && oneIn(2)) { + indexType = Type::i64; + } + auto tablePtr = + builder.makeTable(Names::getValidTableName(wasm, "fuzzing_table"), + funcref, + initial, + max, + indexType); tablePtr->hasExplicitName = true; table = wasm.addTable(std::move(tablePtr)); } |