0
0
mirror of https://github.com/llvm/llvm-project.git synced 2025-04-21 16:46:58 +00:00

[lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 ()

In the case of `--wasm64` we were setting the type of the init expression
to be 64-bit but were only setting the low 32-bits of the value (by
assigning to Int32).

Fixes: https://github.com/emscripten-core/emscripten/issues/22538
(cherry picked from commit 5c8fd1eece8fff69871cef57a2363dc0f734a7d1)
This commit is contained in:
Sam Clegg 2024-09-09 09:28:08 -07:00 committed by Tobias Hieta
parent 3d21a9a8e4
commit d2953ab0a7
No known key found for this signature in database
GPG Key ID: 44F2485E45D59042

@ -587,8 +587,7 @@ void ElemSection::writeBody() {
initExpr.Inst.Value.Global = WasmSym::tableBase->getGlobalIndex();
} else {
bool is64 = config->is64.value_or(false);
initExpr.Inst.Opcode = is64 ? WASM_OPCODE_I64_CONST : WASM_OPCODE_I32_CONST;
initExpr.Inst.Value.Int32 = config->tableBase;
initExpr = intConst(config->tableBase, is64);
}
writeInitExpr(os, initExpr);