summaryrefslogtreecommitdiff
path: root/src/passes/PostEmscripten.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2024-01-31 19:08:12 +0000
committerGitHub <noreply@github.com>2024-01-31 11:08:12 -0800
commit396a826d791e63322cd4f47f116412d3e30ea5fc (patch)
treea897e3113eb33d84f2c4dd405870e3cfb1e4374b /src/passes/PostEmscripten.cpp
parentcf14a9fa9cd6f99ef78a5ffa70cfcb024a524919 (diff)
downloadbinaryen-396a826d791e63322cd4f47f116412d3e30ea5fc.tar.gz
binaryen-396a826d791e63322cd4f47f116412d3e30ea5fc.tar.bz2
binaryen-396a826d791e63322cd4f47f116412d3e30ea5fc.zip
[PostEmscripten] Fix calcSegmentOffsets for large offsets (#6260)
Specifically offsets larger than 2^32 which were being interpreted misinterpreted here as very large int64_t values.
Diffstat (limited to 'src/passes/PostEmscripten.cpp')
-rw-r--r--src/passes/PostEmscripten.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp
index 6dc32eaa8..b7d3e9f91 100644
--- a/src/passes/PostEmscripten.cpp
+++ b/src/passes/PostEmscripten.cpp
@@ -95,12 +95,11 @@ static void calcSegmentOffsets(Module& wasm,
return;
}
}
- auto it = offsets.find(curr->segment);
- if (it != offsets.end()) {
+ if (offsets.find(curr->segment) != offsets.end()) {
Fatal() << "Cannot get offset of passive segment initialized "
"multiple times";
}
- offsets[curr->segment] = dest->value.getInteger();
+ offsets[curr->segment] = dest->value.getUnsigned();
}
} searcher(passiveOffsets);
searcher.walkModule(&wasm);
@@ -317,7 +316,7 @@ struct PostEmscripten : public Pass {
// The first operand is the function pointer index, which must be
// constant if we are to optimize it statically.
if (auto* index = curr->operands[0]->dynCast<Const>()) {
- size_t indexValue = index->value.getInteger();
+ size_t indexValue = index->value.getUnsigned();
if (indexValue >= flatTable.names.size()) {
// UB can lead to indirect calls to invalid pointers.
return;