[llvm-branch-commits] [lld] d2953ab - [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 17 01:06:57 PST 2024
Author: Sam Clegg
Date: 2024-12-17T10:06:24+01:00
New Revision: d2953ab0a79f9f2d2877703dbc235b92541faec9
URL: https://github.com/llvm/llvm-project/commit/d2953ab0a79f9f2d2877703dbc235b92541faec9
DIFF: https://github.com/llvm/llvm-project/commit/d2953ab0a79f9f2d2877703dbc235b92541faec9.diff
LOG: [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: https://github.com/emscripten-core/emscripten/issues/22538
(cherry picked from commit 5c8fd1eece8fff69871cef57a2363dc0f734a7d1)
Added:
Modified:
lld/wasm/SyntheticSections.cpp
Removed:
################################################################################
diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index f02f55519a2512..72d08b849d8e86 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -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);
More information about the llvm-branch-commits
mailing list