[lld] [lld][WebAssembly] Fix used of uninitialized stack data with -wasm64 (PR #107780)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 8 15:32:39 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-wasm
Author: Sam Clegg (sbc100)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/107780.diff
1 Files Affected:
- (modified) lld/wasm/SyntheticSections.cpp (+1-2)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/107780
More information about the llvm-commits
mailing list