Skip to content

Commit d2953ab

Browse files
sbc100tru
authored andcommitted
[lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780)
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: emscripten-core/emscripten#22538 (cherry picked from commit 5c8fd1e)
1 parent 3d21a9a commit d2953ab

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lld/wasm/SyntheticSections.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,7 @@ void ElemSection::writeBody() {
587587
initExpr.Inst.Value.Global = WasmSym::tableBase->getGlobalIndex();
588588
} else {
589589
bool is64 = config->is64.value_or(false);
590-
initExpr.Inst.Opcode = is64 ? WASM_OPCODE_I64_CONST : WASM_OPCODE_I32_CONST;
591-
initExpr.Inst.Value.Int32 = config->tableBase;
590+
initExpr = intConst(config->tableBase, is64);
592591
}
593592
writeInitExpr(os, initExpr);
594593

0 commit comments

Comments
 (0)