From 99b48ccf7e70ee53e3a65243f92e3421ac9ca17b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Aug 2026 22:44:15 +0000 Subject: [PATCH 1/3] Bump the cargo-deps group across 2 directories with 8 updates Bumps the cargo-deps group with 1 update in the /integration directory: [tokio](https://github.com/tokio-rs/tokio). Bumps the cargo-deps group with 7 updates in the /test-runner directory: | Package | From | To | | --- | --- | --- | | [wasm-bindgen-cli](https://github.com/wasm-bindgen/wasm-bindgen) | `0.2.126` | `0.2.127` | | [eyre](https://github.com/eyre-rs/eyre) | `0.6.12` | `0.6.14` | | [serde](https://github.com/serde-rs/serde) | `1.0.228` | `1.0.229` | | [serde_json](https://github.com/serde-rs/json) | `1.0.150` | `1.0.151` | | [serde_with](https://github.com/jonasbb/serde_with) | `3.21.0` | `3.22.0` | | [wasm-encoder](https://github.com/bytecodealliance/wasm-tools) | `0.253.0` | `0.256.0` | | [wasmparser](https://github.com/bytecodealliance/wasm-tools) | `0.253.0` | `0.256.0` | Updates `tokio` from 1.53.0 to 1.53.1 - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.53.0...tokio-1.53.1) Updates `wasm-bindgen-cli` from 0.2.126 to 0.2.127 - [Release notes](https://github.com/wasm-bindgen/wasm-bindgen/releases) - [Changelog](https://github.com/wasm-bindgen/wasm-bindgen/blob/main/CHANGELOG.md) - [Commits](https://github.com/wasm-bindgen/wasm-bindgen/compare/0.2.126...0.2.127) Updates `eyre` from 0.6.12 to 0.6.14 - [Commits](https://github.com/eyre-rs/eyre/compare/eyre-v0.6.12...v0.6.14) Updates `serde` from 1.0.228 to 1.0.229 - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.228...v1.0.229) Updates `serde_json` from 1.0.150 to 1.0.151 - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.150...v1.0.151) Updates `serde_with` from 3.21.0 to 3.22.0 - [Release notes](https://github.com/jonasbb/serde_with/releases) - [Commits](https://github.com/jonasbb/serde_with/compare/v3.21.0...v3.22.0) Updates `wasm-encoder` from 0.253.0 to 0.256.0 - [Release notes](https://github.com/bytecodealliance/wasm-tools/releases) - [Commits](https://github.com/bytecodealliance/wasm-tools/commits) Updates `wasmparser` from 0.253.0 to 0.256.0 - [Release notes](https://github.com/bytecodealliance/wasm-tools/releases) - [Commits](https://github.com/bytecodealliance/wasm-tools/commits) --- updated-dependencies: - dependency-name: tokio dependency-version: 1.53.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: cargo-deps - dependency-name: wasm-bindgen-cli dependency-version: 0.2.127 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: cargo-deps - dependency-name: eyre dependency-version: 0.6.14 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: cargo-deps - dependency-name: serde dependency-version: 1.0.229 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: cargo-deps - dependency-name: serde_json dependency-version: 1.0.151 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: cargo-deps - dependency-name: serde_with dependency-version: 3.22.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: cargo-deps - dependency-name: wasm-encoder dependency-version: 0.256.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: cargo-deps - dependency-name: wasmparser dependency-version: 0.256.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: cargo-deps ... Signed-off-by: dependabot[bot] --- crates/wasm_split_cli/Cargo.toml | 4 +- integration/Cargo.lock | 43 ++++++---- test-runner/Cargo.lock | 138 +++++++++++++++++++------------ test-runner/Cargo.toml | 2 +- 4 files changed, 114 insertions(+), 73 deletions(-) diff --git a/crates/wasm_split_cli/Cargo.toml b/crates/wasm_split_cli/Cargo.toml index 2b29d59..4d821f1 100644 --- a/crates/wasm_split_cli/Cargo.toml +++ b/crates/wasm_split_cli/Cargo.toml @@ -14,8 +14,8 @@ eyre = "0.6" tracing = { version = "0.1", default-features = false, features = ["std"] } lazy_static = "1.4" regex = "1.12" -wasm-encoder = { version = "0.253", features = ["wasmparser"] } -wasmparser = "0.253" +wasm-encoder = { version = "0.256", features = ["wasmparser"] } +wasmparser = "0.256" # bin-only depdencies clap = { version = "4.5", features = ["derive"], optional = true } tracing-subscriber = { version = "0.3", features = ["fmt"], optional = true } diff --git a/integration/Cargo.lock b/integration/Cargo.lock index 7a997cc..e82c49f 100644 --- a/integration/Cargo.lock +++ b/integration/Cargo.lock @@ -16,7 +16,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.108", ] [[package]] @@ -283,9 +283,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -293,29 +293,29 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] name = "serde_json" -version = "1.0.150" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "itoa", "memchr", @@ -378,11 +378,22 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tokio" -version = "1.53.0" +version = "1.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d988bcd52dbe076d3d46903332f58c912b87a2c49b1428419a5845154762ffee" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" dependencies = [ "pin-project-lite", "tokio-macros", @@ -396,7 +407,7 @@ checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.108", ] [[package]] @@ -469,7 +480,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 2.0.108", "wasm-bindgen-shared", ] @@ -512,7 +523,7 @@ checksum = "94eb68555b95bcea5e8cf4abe280b529049479fa995bfc23734af96a6aedc120" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.108", ] [[package]] @@ -536,7 +547,7 @@ dependencies = [ "base16", "quote", "sha2", - "syn", + "syn 2.0.108", ] [[package]] diff --git a/test-runner/Cargo.lock b/test-runner/Cargo.lock index 1af53ce..c5adbcd 100644 --- a/test-runner/Cargo.lock +++ b/test-runner/Cargo.lock @@ -266,7 +266,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -365,7 +365,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.117", ] [[package]] @@ -376,7 +376,7 @@ checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -407,7 +407,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -494,10 +494,11 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.12" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +checksum = "c08309dbcc659c5549a24ddb9b27027640641b282ef5768267c7e675558986a3" dependencies = [ + "autocfg", "indenter", "once_cell", ] @@ -904,10 +905,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49" dependencies = [ "jiff-static", + "jiff-tzdb-platform", "log", "portable-atomic", "portable-atomic-util", "serde", + "windows-sys 0.52.0", ] [[package]] @@ -918,14 +921,29 @@ checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", +] + +[[package]] +name = "jiff-tzdb" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e" + +[[package]] +name = "jiff-tzdb-platform" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" +dependencies = [ + "jiff-tzdb", ] [[package]] name = "js-sys" -version = "0.3.103" +version = "0.3.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" +checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a" dependencies = [ "cfg-if", "futures-util", @@ -1247,7 +1265,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -1413,9 +1431,9 @@ checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -1423,29 +1441,29 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] name = "serde_json" -version = "1.0.150" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "itoa", "memchr", @@ -1456,9 +1474,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.21.0" +version = "3.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a5c54c7310e7b8b9577c286d7e399ddd876c3e12b3ed917a8aabc4b96e9e8c" +checksum = "ee78f1fbe43ac4a0e47aadb3dbd357b69eb0d3793e948624cd03dd2750ab1c0a" dependencies = [ "base64 0.22.1", "bs58", @@ -1466,6 +1484,7 @@ dependencies = [ "hex", "indexmap 1.9.3", "indexmap 2.14.0", + "jiff", "schemars 0.9.0", "schemars 1.2.1", "serde_core", @@ -1476,14 +1495,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.21.0" +version = "3.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84d57bc0c8b9a17920c178daa6bb924850d54a9c97ab45194bb8c17ad66bb660" +checksum = "8705578779c2b6bd90d84d66eb2e206b708b1a4d7b9f17641b293545bf1c7e46" dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -1565,6 +1584,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.13.2" @@ -1573,7 +1603,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -1846,7 +1876,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -1875,9 +1905,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" +checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70" dependencies = [ "cfg-if", "once_cell", @@ -1888,9 +1918,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-cli" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2ebf6eef87c34e662347f1dddfbea541304bb7294711ed2c2acd8746cc5b50" +checksum = "6123f525ba36df42e57b67027637a78591e712a9f6a025ffd3d74298fa1c3f4c" dependencies = [ "anyhow", "clap", @@ -1911,9 +1941,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-cli-support" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c3e3bac5bcdc2a15ba22862e2cb7c0d1beddf9d46dd320bec1f6ae82f2da53" +checksum = "8d9582933b7fdee22f4ac90145336564dd0bc97c1ccb424e01c53926eb322312" dependencies = [ "anyhow", "base64 0.22.1", @@ -1929,9 +1959,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" +checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1939,31 +1969,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" +checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 2.0.117", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" +checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-bindgen-test-shared" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31d56021e873866c968588ed85ccdf56db5c426e44afdb4618c39895104b920" +checksum = "33ff1c1b360982e93b6d8ea9c04836f71dba0817a16f91e229cf3a51bdd9d987" [[package]] name = "wasm-encoder" @@ -1977,12 +2007,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.253.0" +version = "0.256.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59972d6cd272259de647b7c1f1912e45e289c75ffd4be04e10695507cd7e1b59" +checksum = "ec1492381bfd5ea51c2a99a919b676662559925cb8d7490547ec2e14c1ad3eb1" dependencies = [ "leb128fmt", - "wasmparser 0.253.0", + "wasmparser 0.256.0", ] [[package]] @@ -2010,8 +2040,8 @@ dependencies = [ "lazy_static", "regex", "tracing", - "wasm-encoder 0.253.0", - "wasmparser 0.253.0", + "wasm-encoder 0.256.0", + "wasmparser 0.256.0", ] [[package]] @@ -2029,9 +2059,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.253.0" +version = "0.256.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19db11f87d2486580e1e8b6f494c54df7e0566b87d0b599db843c24019667339" +checksum = "60bd825ffedc6cba8a642924ba7ae424afbc47811cffbcb7b92031ec24e59b4c" dependencies = [ "bitflags", "hashbrown 0.17.1", @@ -2092,7 +2122,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -2103,7 +2133,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -2318,7 +2348,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", "synstructure", ] @@ -2339,7 +2369,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -2359,7 +2389,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", "synstructure", ] @@ -2399,7 +2429,7 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] diff --git a/test-runner/Cargo.toml b/test-runner/Cargo.toml index d2be2a1..ac1b76e 100644 --- a/test-runner/Cargo.toml +++ b/test-runner/Cargo.toml @@ -11,7 +11,7 @@ default-run = "wasm-split-test-runner" [dependencies] # this MUST be the same bindgen version as used on the tested artifact -wasm-bindgen-cli = { version = "=0.2.126", artifact = ["bin:wasm-bindgen-test-runner", "bin:wasm-bindgen"] } +wasm-bindgen-cli = { version = "=0.2.127", artifact = ["bin:wasm-bindgen-test-runner", "bin:wasm-bindgen"] } wasm_split_cli_support = { path = "../crates/wasm_split_cli" } eyre = "0.6.12" tempfile = "3.27.0" From b45b784d94c887ac5f9d0dba61773f465d0f8768 Mon Sep 17 00:00:00 2001 From: WorldSEnder Date: Thu, 20 Aug 2026 16:58:48 +0200 Subject: [PATCH 2/3] update wasmparser --- Cargo.lock | 14 ++-- crates/wasm_split_cli/Cargo.toml | 4 +- crates/wasm_split_cli/src/dep_graph.rs | 9 +-- crates/wasm_split_cli/src/emit.rs | 88 +++++++++++++----------- crates/wasm_split_cli/src/emit/dwarf.rs | 12 ++-- crates/wasm_split_cli/src/read.rs | 32 ++++----- crates/wasm_split_cli/src/reloc.rs | 43 +++++------- crates/wasm_split_cli/src/split_point.rs | 7 +- crates/wasm_split_cli/src/util.rs | 18 ++++- examples/example/Cargo.toml | 2 +- integration/Cargo.lock | 36 +++++----- integration/Cargo.toml | 2 +- test-runner/Cargo.lock | 14 ++-- 13 files changed, 146 insertions(+), 135 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 007e608..734fe96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -691,12 +691,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.252.0" +version = "0.257.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8185ae345fa5687c054626ff9a50e7089797a343d9904d1dc9820eb4c4d3196f" +checksum = "7d8ad9f0a39050867bda22e6486c316e2e52d20a42154d5bc433934bf738d085" dependencies = [ "leb128fmt", - "wasmparser 0.252.0", + "wasmparser 0.257.1", ] [[package]] @@ -723,8 +723,8 @@ dependencies = [ "tempfile", "tracing", "tracing-subscriber", - "wasm-encoder 0.252.0", - "wasmparser 0.252.0", + "wasm-encoder 0.257.1", + "wasmparser 0.257.1", ] [[package]] @@ -759,9 +759,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.252.0" +version = "0.257.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3eb099dcadcde5be9eef55e3a337128efd4e44b4c93122487e4d2e4e1c6627c" +checksum = "d92fc335fb6d48f46bda1d8b26b69e28320c15ac3272208333833d6e217e2b4a" dependencies = [ "bitflags", "hashbrown 0.17.1", diff --git a/crates/wasm_split_cli/Cargo.toml b/crates/wasm_split_cli/Cargo.toml index 4d821f1..ae085db 100644 --- a/crates/wasm_split_cli/Cargo.toml +++ b/crates/wasm_split_cli/Cargo.toml @@ -14,8 +14,8 @@ eyre = "0.6" tracing = { version = "0.1", default-features = false, features = ["std"] } lazy_static = "1.4" regex = "1.12" -wasm-encoder = { version = "0.256", features = ["wasmparser"] } -wasmparser = "0.256" +wasm-encoder = { version = "0.257", features = ["wasmparser"] } +wasmparser = "0.257" # bin-only depdencies clap = { version = "4.5", features = ["derive"], optional = true } tracing-subscriber = { version = "0.3", features = ["fmt"], optional = true } diff --git a/crates/wasm_split_cli/src/dep_graph.rs b/crates/wasm_split_cli/src/dep_graph.rs index b67e7d4..eed7bdf 100644 --- a/crates/wasm_split_cli/src/dep_graph.rs +++ b/crates/wasm_split_cli/src/dep_graph.rs @@ -9,7 +9,7 @@ use wasmparser::{FunctionBody, Operator, RelocationEntry}; use crate::{ read::{GlobalId, InputFuncId, InputModule, MemoryId, SymbolIndex, TableId, TagId}, reloc::{DataSymbol, RelocDetails}, - util::shift_range, + util::{shift_range, wasm_reloc_range}, }; #[derive(Debug, PartialEq, Eq, Hash, Copy, PartialOrd, Ord, Clone)] @@ -151,7 +151,7 @@ fn iter_functions_with_relocs<'m>( let code_section_offset = module.reloc_info.code_section_reloc_base(); let mut function_index = 0; code_relocs.map(move |entry| { - let reloc_file_range = shift_range(entry.relocation_range()?, code_section_offset); + let reloc_file_range = shift_range(wasm_reloc_range(entry), code_section_offset); // We do an exponential search for a function that contains the relocation's target range. let found_index = crate::util::exponential_partition_point( &module.defined_funcs[function_index..], @@ -290,10 +290,7 @@ fn iter_data_dependencies<'m>( let mut overlap_candidates: Vec<&DataSymbol> = vec![]; std::iter::from_fn(move || loop { if let Some(&entry) = data_relocs.peek() { - let reloc_file_range = shift_range( - emit_iter_err!(entry.relocation_range()), - data_section_offset, - ); + let reloc_file_range = shift_range(wasm_reloc_range(entry), data_section_offset); let should_handle_reloc = match data_symbols.peek() { None => true, Some(next_symbol) => next_symbol.range.start >= reloc_file_range.end, diff --git a/crates/wasm_split_cli/src/emit.rs b/crates/wasm_split_cli/src/emit.rs index 230a8eb..eed4dbe 100644 --- a/crates/wasm_split_cli/src/emit.rs +++ b/crates/wasm_split_cli/src/emit.rs @@ -10,6 +10,7 @@ use crate::{ read::{InputFuncId, InputModule, InputOffset}, reloc::{RelocDetails, RelocInfo, RelocTarget}, split_point::{SplitModuleIdentifier, SplitProgramInfo}, + util::{wasm_data_len, wasm_data_start}, }; use eyre::{anyhow, bail, Context, Result}; use tracing::{trace, warn}; @@ -281,10 +282,10 @@ impl IndirectFunctionEmitInfo { #[derive(Debug)] struct LateDataRange { - input_range: Range, + input_range: Range, in_module: usize, - data_align: usize, // power of 2 - in_module_offset: usize, + data_align: u64, // power of 2 + in_module_offset: u64, } #[derive(Debug)] @@ -294,12 +295,12 @@ enum DataSegmentEmitInfo { FromInputOnlyIn(usize), Ranges { // some reloc information - base_address: usize, - per_output_offset: HashMap, + base_address: u64, + per_output_offset: HashMap, // the output segment is formed by concatenating all these segment ranges: Vec, // symbol index -> (index in 'ranges', offset in range) - range_lookup: HashMap, + range_lookup: HashMap, // we re-order ranges to put data with larger alignment up front (this saves padding bytes). // since indices are stored in the range_lookup map, we can't do this in-place and maintain a separate order here. range_emit_order: Vec, @@ -319,8 +320,8 @@ impl DataEmitInfo { Ranges { ranges: Vec, // symbol -> (index in ranges, offset in range) - range_lookup: HashMap, - base_address: usize, + range_lookup: HashMap, + base_address: u64, }, } let mut per_segment = input_module @@ -332,28 +333,32 @@ impl DataEmitInfo { // We duplicate all passive segments (there shouldn't be any except in multi-threading?) // because we don't have relocation to identify which function uses which passive data // for initialization. Hence we try to preserve indices as best as possible. - DataKind::Passive => DataSegmentAnalysis::FromInputInAll, + DataKind::Passive => Ok(DataSegmentAnalysis::FromInputInAll), DataKind::Active { offset_expr, .. } => { let segment_info = &input_module.reloc_info.segments[segment_idx]; if segment_info.flags.contains(SegmentFlags::TLS) { - return DataSegmentAnalysis::FromInputInAll; + return Ok(DataSegmentAnalysis::FromInputInAll); } let address = match offset_expr.get_operators_reader().read().unwrap() { - wasmparser::Operator::I32Const { value } => value as usize, - wasmparser::Operator::I64Const { value } => value as usize, + wasmparser::Operator::I32Const { value } => u64::try_from(value).map_err(|_| i64::from(value)), + wasmparser::Operator::I64Const { value } => u64::try_from(value).map_err(|_| value), op => { warn!("Non-constant operator {op:?} found to specify a memory's base address. Putting it into main."); - return DataSegmentAnalysis::FromInputOnlyIn(0); + return Ok(DataSegmentAnalysis::FromInputOnlyIn(0)); } }; - DataSegmentAnalysis::Ranges { + let address = match address { + Ok(addr) => addr, + Err(value) => { bail!("Invalid base address found: {value}"); }, + }; + Ok(DataSegmentAnalysis::Ranges { ranges: vec![], range_lookup: HashMap::new(), base_address: address, - } + }) } }) - .collect::>(); + .collect::, _>>()?; // Now go through all data symbols for (module_index, (_, module)) in program_info.output_modules.iter().enumerate() { @@ -406,12 +411,12 @@ impl DataEmitInfo { "data symbol in passive range should not have gotted included in this pass" ); }; - let data_len = def_data.size as usize; - let data_offset = def_data.offset as usize; + let data_len = u64::from(def_data.size); + let data_offset = u64::from(def_data.offset); let data_range = data_offset..data_offset + data_len; let in_segment = &input_module.data_segments[segment_index]; - if data_range.end > in_segment.data.len() { + if data_range.end > wasm_data_len(in_segment) { unreachable!( "Found data symbol {:?} that extends past the input module's data \ bytes: {data_range:?} not in range for data segment of length {}", @@ -421,15 +426,15 @@ impl DataEmitInfo { } let segment_align = - 1usize << input_module.reloc_info.segments[segment_index].alignment; + 1u64 << input_module.reloc_info.segments[segment_index].alignment; let mut data_align = segment_align; if data_offset != 0 { // TODO: .isolate_least_significant_one() - data_align = data_align.min(1usize << data_offset.trailing_zeros()); + data_align = data_align.min(1 << data_offset.trailing_zeros()); } debug_assert!(data_len != 0, "zero-sized symbols handled previously"); - data_align = data_align.min(1usize << data_len.trailing_zeros()); + data_align = data_align.min(1 << data_len.trailing_zeros()); let mut has_merged = false; let range_idx = ranges.len(); @@ -456,7 +461,7 @@ impl DataEmitInfo { input_range: data_range, in_module: module_index, data_align, - in_module_offset: usize::MAX, // filled in later + in_module_offset: u64::MAX, // filled in later }); range_lookup.insert(symbol_index, (range_idx, 0)); } @@ -477,7 +482,7 @@ impl DataEmitInfo { base_address, } => { let segment_alignment = - 1usize << input_module.reloc_info.segments[segment_index].alignment; + 1u64 << input_module.reloc_info.segments[segment_index].alignment; let mut range_emit_order: Vec<_> = (0..ranges.len()).collect(); range_emit_order.sort_by_key(|&range_idx| { @@ -490,11 +495,11 @@ impl DataEmitInfo { let range = &mut ranges[range_idx]; let module_len = per_module_size.entry(range.in_module).or_insert(0); let data_range = range.input_range.clone(); - let data_offset = usize::next_multiple_of(*module_len, range.data_align); + let data_offset = u64::next_multiple_of(*module_len, range.data_align); // allocate it in that module range.in_module_offset = data_offset; - *module_len = data_offset + data_range.len(); + *module_len = data_offset + (data_range.end - data_range.start); } // check that range_lookup completely covers the (non-zero) data segment? @@ -507,7 +512,7 @@ impl DataEmitInfo { let mut per_module_size = per_module_size.into_iter().collect::>(); per_module_size.sort_by_key(|&(m, _)| m); let mut per_output_offset = HashMap::new(); - let mut data_offset: usize = 0; + let mut data_offset: u64 = 0; for &(module, module_size) in &per_module_size { data_offset = data_offset.next_multiple_of(segment_alignment); per_output_offset.insert(module, data_offset); @@ -525,8 +530,8 @@ impl DataEmitInfo { // If we could move other active segments to different base addresses, this segment getting longer // would not be a problem. Since we can't guarantee this at this point though, don't risk it. // Overlapping segments *will* overwrite data! - if segment_len > input_module.data_segments[segment_index].data.len() { - let overlength = segment_len - input_module.data_segments[segment_index].data.len(); + if segment_len > wasm_data_len(&input_module.data_segments[segment_index]) { + let overlength = segment_len - wasm_data_len(&input_module.data_segments[segment_index]); trace!("{ranges:?}"); warn!("Overlong segment {segment_index} by {overlength} after relocation, putting it in main module."); DataSegmentEmitInfo::FromInputOnlyIn(0) @@ -542,7 +547,7 @@ impl DataEmitInfo { &self, symbol_index: usize, data: &DefinedDataSymbol, - ) -> Result, ()> { + ) -> Result, ()> { if data.size == 0 { // zero-sized symbols are not relocated return Ok(None); @@ -622,7 +627,7 @@ struct ModuleEmitState<'a> { } impl RelocTarget for ModuleEmitState<'_> { - fn reloc_value(&self, reloc: RelocDetails<'_>) -> Result> { + fn reloc_value(&self, reloc: RelocDetails<'_>) -> Result> { match reloc { RelocDetails::TypeIndex { .. } => { // We don't relocate types, we just copy them over @@ -662,7 +667,7 @@ impl RelocTarget for ModuleEmitState<'_> { // TODO: we could assert that we are indeed relocating a data segment here. // an improved analysis of data segments could perhaps avoid this case entirely // and restore the assertion that the referenced function is reachable. - Ok(Some(index)) + Ok(Some(index as u64)) } RelocDetails::RelTableIndex(_details) => { bail!("Unsupported relocation type: relative table index"); @@ -679,7 +684,7 @@ impl RelocTarget for ModuleEmitState<'_> { referenced by relocation." ); }; - Ok(Some(output_func_id)) + Ok(Some(output_func_id as u64)) } RelocDetails::TableNumber(details) => { if !self.is_main() && details.index != self.input_module.reloc_info.indirect_table { @@ -1038,15 +1043,15 @@ impl<'a> ModuleEmitState<'a> { .symbol_as_global .get(&global_idx) { - let (reloc_type, conv_reloc_value): (RelocationType, fn(usize) -> ConstExpr) = + let (reloc_type, conv_reloc_value): (RelocationType, fn(u64) -> ConstExpr) = match global_expr.get_operators_reader().read() { Ok(Operator::I32Const { value: _ }) => { - (RelocationType::MemoryAddrI32, |val: usize| { + (RelocationType::MemoryAddrI32, |val: u64| { ConstExpr::i32_const(val.try_into().unwrap()) }) } Ok(Operator::I64Const { value: _ }) => { - (RelocationType::MemoryAddrI64, |val: usize| { + (RelocationType::MemoryAddrI64, |val: u64| { ConstExpr::i64_const(val.try_into().unwrap()) }) } @@ -1318,7 +1323,7 @@ impl<'a> ModuleEmitState<'a> { fn get_relocated_segment_data(&self, data: &Data<'_>) -> Result> { // Note: `data.range` includes the segment header. let range_end = data.range.end; - let range_start = range_end - data.data.len(); + let range_start = wasm_data_start(data); self.get_relocated_data(range_start..range_end) } @@ -1327,11 +1332,10 @@ impl<'a> ModuleEmitState<'a> { let mut section = wasm_encoder::DataSection::new(); for (segment_idx, segment) in data_reloc.per_segment.iter().enumerate() { let input_data = &self.input_module.data_segments[segment_idx]; - let input_range_end = input_data.range.end; - let input_range_start = input_range_end - input_data.data.len(); + let input_range_start = wasm_data_start(input_data); let mut data: Vec; - let addr_offset: Option; + let addr_offset: Option; match segment { DataSegmentEmitInfo::FromInputInAll => { addr_offset = None; @@ -1368,7 +1372,7 @@ impl<'a> ModuleEmitState<'a> { let data_range = &range.input_range; let input_range = (input_range_start + data_range.start) ..(input_range_start + data_range.end); - data.resize(range.in_module_offset, 0); // pad with zeroes + data.resize(range.in_module_offset as usize, 0); // pad with zeroes data.extend(self.get_relocated_data(input_range)?); } } @@ -1384,7 +1388,7 @@ impl<'a> ModuleEmitState<'a> { let offset = match addr_offset { None => offset_expr.clone().try_into().unwrap(), Some(module_offset) => { - if module_offset <= i32::MAX as usize { + if module_offset <= i32::MAX as u64 { wasm_encoder::ConstExpr::i32_const(module_offset as i32) } else { wasm_encoder::ConstExpr::i64_const(module_offset as i64) diff --git a/crates/wasm_split_cli/src/emit/dwarf.rs b/crates/wasm_split_cli/src/emit/dwarf.rs index 4d51ea3..428c04f 100644 --- a/crates/wasm_split_cli/src/emit/dwarf.rs +++ b/crates/wasm_split_cli/src/emit/dwarf.rs @@ -18,12 +18,12 @@ struct DwarfRelocTarget<'m, 'a> { module: &'m ModuleEmitState<'a>, } -const RELOC_TO_TOMBSTONE_ADDRESS: Option = Some(reloc::SENTINEL_UNDEF); +const RELOC_TO_TOMBSTONE_ADDRESS: Option = Some(reloc::SENTINEL_UNDEF); impl RelocTarget for DwarfRelocTarget<'_, '_> { const SENTINEL_UNDEF: bool = true; - fn fixup_reloc_entry(&self, entry: &wasmparser::RelocationEntry) -> Result> { + fn fixup_reloc_entry(&self, entry: &wasmparser::RelocationEntry) -> Result> { // Should we try and recover the function offset from some internal code map? Would be // more effort to compute and keep up to date. We also need to read the current value // from `data` and use that to recover the function index. @@ -33,7 +33,7 @@ impl RelocTarget for DwarfRelocTarget<'_, '_> { ); Ok(RELOC_TO_TOMBSTONE_ADDRESS) } - fn reloc_value(&self, reloc: RelocDetails<'_>) -> Result> { + fn reloc_value(&self, reloc: RelocDetails<'_>) -> Result> { let reloc = match reloc { RelocDetails::GlobalIndex(_) => return self.module.reloc_value(reloc), RelocDetails::FunctionOffset(details) => { @@ -44,7 +44,7 @@ impl RelocTarget for DwarfRelocTarget<'_, '_> { let local_offset = local_def.and_then(|local_def| self.module.function_offset_hint.get(local_def)); match local_offset { - Some(offset) => Some(self.module.function_header_len + offset), + Some(offset) => Some((self.module.function_header_len + offset) as u64), None => RELOC_TO_TOMBSTONE_ADDRESS, } } @@ -103,8 +103,8 @@ pub fn emit_debug_info(module: &mut ModuleEmitState<'_>) -> Result<()> { }; let mut error_writer = ErrorWriter::new(std::io::BufWriter::new(std::io::stderr())); if module.emit_state.input_options.strict_tests && module.is_main() { - validate_info(&mut error_writer, input_dwarf.borrow(|v| *v)); - validate_line_progs(&mut error_writer, input_dwarf.borrow(|v| *v)); + validate_info(&mut error_writer, input_dwarf.borrow(|v| v.clone())); + validate_line_progs(&mut error_writer, input_dwarf.borrow(|v| v.clone())); if !error_writer.check_valid_and_reset() { tracing::warn!("original debug info didn't pass validation!"); } diff --git a/crates/wasm_split_cli/src/read.rs b/crates/wasm_split_cli/src/read.rs index 7922a81..55c2f49 100644 --- a/crates/wasm_split_cli/src/read.rs +++ b/crates/wasm_split_cli/src/read.rs @@ -131,14 +131,14 @@ impl<'a> Names<'a> { } } -pub type InputOffset = usize; +pub type InputOffset = u64; pub use crate::reloc::SymbolIndex; // We use our own struct here instead of a simple slice to track input positions and ranges -#[derive(Clone, Copy, Default)] +#[derive(Clone, Default)] pub struct DwarfReader<'a> { data: &'a [u8], - input_position: usize, + data_range: Range, } impl Deref for DwarfReader<'_> { type Target = [u8]; @@ -174,7 +174,7 @@ impl Debug for DwarfReader<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("DwarfReader") .field("data", &DebugBytes(self.data)) - .field("pos", &self.input_position) + .field("data_range", &self.data_range) .finish() } } @@ -185,7 +185,7 @@ impl DwarfReader<'_> { fn offset_id_dec(id: u64) -> *const u8 { std::ptr::null::().wrapping_byte_offset(id as isize) } - fn offset_of_addr(&self, ptr: *const u8) -> Option { + fn offset_of_addr(&self, ptr: *const u8) -> Option<::Offset> { let offset = ptr as isize - self.data.as_ptr() as isize; // TODO(MSRV): diff.cast_unsigned/diff.strict_cast_unsigned if offset >= 0 && offset as usize <= gimli::Reader::len(self) { @@ -195,15 +195,15 @@ impl DwarfReader<'_> { } } /// range in the input of the byte range - pub fn range(&self) -> Range { - self.input_position..self.input_position + self.data.len() + pub fn range(&self) -> Range { + self.data_range.clone() } } impl<'a> From> for DwarfReader<'a> { fn from(custom: CustomSectionReader<'a>) -> Self { DwarfReader { data: custom.data(), - input_position: custom.data_offset(), + data_range: custom.data_range(), } } } @@ -216,7 +216,7 @@ impl<'a> gimli::Reader for DwarfReader<'a> { } fn len(&self) -> Self::Offset { - self.data.len() + (self.data_range.end - self.data_range.start) as usize } fn empty(&mut self) { @@ -241,12 +241,7 @@ impl<'a> gimli::Reader for DwarfReader<'a> { fn lookup_offset_id(&self, id: gimli::ReaderOffsetId) -> Option { let ptr = Self::offset_id_dec(id.0); - let offset = ptr as isize - self.data.as_ptr() as isize; - if offset >= 0 && offset as usize <= self.len() { - Some(offset as usize) - } else { - None - } + self.offset_of_addr(ptr) } fn find(&self, byte: u8) -> gimli::Result { @@ -262,17 +257,18 @@ impl<'a> gimli::Reader for DwarfReader<'a> { } fn split(&mut self, len: Self::Offset) -> gimli::Result { - if len > self.data.len() { + if len > self.len() { return Err(gimli::Error::UnexpectedEof(self.offset_id())); } let (prefix, more) = self.data.split_at(len); + let mid = self.data_range.start + len as u64; *self = Self { data: more, - input_position: self.input_position + len, + data_range: mid..self.data_range.end, }; Ok(Self { data: prefix, - input_position: self.input_position, + data_range: self.data_range.start..mid, }) } diff --git a/crates/wasm_split_cli/src/reloc.rs b/crates/wasm_split_cli/src/reloc.rs index 4669ad2..71727bf 100644 --- a/crates/wasm_split_cli/src/reloc.rs +++ b/crates/wasm_split_cli/src/reloc.rs @@ -15,7 +15,7 @@ use wasmparser::{ use crate::{ magic_constants, read::{GlobalId, InputFuncId, InputModule, InputOffset, SectionId, TableId, TagId}, - util::{find_subrange, shift_range}, + util::{find_subrange, shift_range, wasm_reloc_range}, }; // An offset (index) into the bytes of the input module @@ -220,17 +220,17 @@ fn get_data_symbols(data_segments: &[Data], symbols: &[SymbolInfo]) -> Result data_segment.data.len() { + let symbol_range = shift_range(0..u64::from(symbol.size), u64::from(symbol.offset)); + let data_start = data_segment.range.end - data_segment.data.len() as u64; + if symbol_range.end > data_segment.range.end - data_start { bail!( "Invalid symbol {symbol:?} for data segment of size {:?}", data_segment.data.len() ); } - let data_offset = data_segment.range.end - data_segment.data.len(); data_symbols.push(DataSymbol { symbol_index, - range: shift_range(symbol_range, data_offset), + range: shift_range(symbol_range, data_start), }); } // We assume that these are sorted by range start later on @@ -433,8 +433,8 @@ impl RelocInfo<'_> { let section_relocs = self.iter_section_relocs(section); let reloc_range = find_subrange( section_relocs, - |reloc| (reloc.offset as usize) >= section_subrange.start, - |reloc| (reloc.offset as usize) < section_subrange.end, + |reloc| u64::from(reloc.offset) >= section_subrange.start, + |reloc| u64::from(reloc.offset) < section_subrange.end, ); (reloc_base, section_relocs[reloc_range].iter()) @@ -446,7 +446,7 @@ impl RelocInfo<'_> { target: &impl RelocTarget, ) -> Result> { let this = &module.reloc_info; - let mut data = Vec::from(&module.raw[range.clone()]); + let mut data = Vec::from(&module.raw[range.start as usize..range.end as usize]); let (reloc_base, relocs) = this.get_relocations_for_range(&range); let reloc_base_to_data_off = range.start - reloc_base; for relocation in relocs { @@ -597,7 +597,7 @@ impl RelocInfo<'_> { &self, reloc_target: &T, data: &mut [u8], - reloc_base_to_data_off: usize, + reloc_base_to_data_off: u64, relocation: &RelocationEntry, ) -> Result<()> { // TODO(MSRV): -1i32.cast_unsigned() since rust 1.87 @@ -619,9 +619,9 @@ impl RelocInfo<'_> { let details = self.expand_relocation(relocation)?; reloc_target.reloc_value(details)? }; - let relocation_range = relocation.relocation_range()?; - let target = &mut data[(relocation_range.start - reloc_base_to_data_off) - ..(relocation_range.end - reloc_base_to_data_off)]; + let relocation_range = wasm_reloc_range(relocation); + let target = &mut data[(relocation_range.start - reloc_base_to_data_off) as usize + ..(relocation_range.end - reloc_base_to_data_off) as usize]; let ty = relocation.ty; let Some(value) = relocated else { return Ok(()); @@ -631,13 +631,7 @@ impl RelocInfo<'_> { "relocation {relocation:?} without addend should have addend == 0, not {}", relocation.addend, ); - let () = encode_for_ty( - ty, - value, - relocation.addend as isize, - target, - T::SENTINEL_UNDEF, - )?; + let () = encode_for_ty(ty, value, relocation.addend, target, T::SENTINEL_UNDEF)?; Ok(()) } } @@ -675,13 +669,13 @@ pub enum RelocDetails<'a> { SectionOffset(SymbolDetails<'a, SectionId>), } -pub const SENTINEL_UNDEF: usize = usize::MAX; +pub const SENTINEL_UNDEF: u64 = u64::MAX; pub trait RelocTarget { const SENTINEL_UNDEF: bool = false; /// Fixup a relocation entry with an invalid symbol. If this fixup fails, /// we warn and relocate to a tombstone address or error if tombstones /// are not enabled for this relocation context. - fn fixup_reloc_entry(&self, entry: &RelocationEntry) -> Result> { + fn fixup_reloc_entry(&self, entry: &RelocationEntry) -> Result> { // assert: entry.index == (-1i32 as u32) ensure!( Self::SENTINEL_UNDEF, @@ -689,7 +683,7 @@ pub trait RelocTarget { ); Ok(Some(SENTINEL_UNDEF)) } - fn reloc_value(&self, reloc: RelocDetails<'_>) -> Result>; + fn reloc_value(&self, reloc: RelocDetails<'_>) -> Result>; } fn encode_leb128_u32_5byte(mut value: u32, buf: &mut [u8; 5]) { @@ -742,8 +736,8 @@ fn encode_u64(value: u64, buf: &mut [u8; 8]) { fn encode_for_ty( ty: RelocationType, - value: usize, - addend: isize, + value: u64, + addend: i64, target: &mut [u8], allow_undef: bool, ) -> Result<()> { @@ -760,6 +754,7 @@ fn encode_for_ty( ($resolved:ident as $t:ty, $msg:literal) => { match $resolved { SENTINEL_UNDEF if allow_undef => -1isize as $t, + #[allow(irrefutable_let_patterns)] resolved if let Ok(resolved) = resolved.try_into() => resolved, resolved => { bail!("{}: {resolved:x}", $msg); diff --git a/crates/wasm_split_cli/src/split_point.rs b/crates/wasm_split_cli/src/split_point.rs index 8425fa5..50a3ba7 100644 --- a/crates/wasm_split_cli/src/split_point.rs +++ b/crates/wasm_split_cli/src/split_point.rs @@ -153,12 +153,15 @@ fn print_deps(module_name: &str, module: &InputModule, reachable: &HashSet(slice: &[T], eventually_false: impl Fn(&T) skipped + to_test.partition_point(eventually_false) } -pub fn shift_range(range: Range, offset: usize) -> Range { +pub fn shift_range(range: Range, offset: u64) -> Range { let start = range.start.min(range.end); let new_end = range .end @@ -57,6 +57,22 @@ pub fn shift_range(range: Range, offset: usize) -> Range { new_start..new_end } +pub fn wasm_data_len(data: &wasmparser::Data<'_>) -> u64 { + let len_u64 = u64::try_from(data.data.len()).unwrap(); + debug_assert!(data.range.end >= len_u64); + len_u64 +} + +pub fn wasm_data_start(data: &wasmparser::Data<'_>) -> u64 { + data.range.end - wasm_data_len(data) +} + +pub fn wasm_reloc_range(reloc: &wasmparser::RelocationEntry) -> Range { + let start = u64::from(reloc.offset); + let len = reloc.ty.extent() as u64; + start..start + len +} + #[cfg(test)] #[test] fn test_exponential_partition() { diff --git a/examples/example/Cargo.toml b/examples/example/Cargo.toml index ba48fd1..7e417a7 100644 --- a/examples/example/Cargo.toml +++ b/examples/example/Cargo.toml @@ -14,7 +14,7 @@ futures = "0.3.30" gloo-console = "0.3.0" gloo-net = { version = "0.3.1", default-features = false, features = ["http"] } js-sys = "0.3.69" -wasm-bindgen = "=0.2.126" +wasm-bindgen = "=0.2.127" wasm-bindgen-futures = "0.4.55" wasm-streams = "0.4.0" wasm_split_helpers = { workspace = true, optional = true } diff --git a/integration/Cargo.lock b/integration/Cargo.lock index e82c49f..7d56b9b 100644 --- a/integration/Cargo.lock +++ b/integration/Cargo.lock @@ -154,9 +154,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "js-sys" -version = "0.3.103" +version = "0.3.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" +checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a" dependencies = [ "cfg-if", "futures-util", @@ -440,9 +440,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" +checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70" dependencies = [ "cfg-if", "once_cell", @@ -453,9 +453,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.76" +version = "0.4.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d" +checksum = "6b7777d5cc23d0e91404e53ce2d5e8ec7acae3026b16233dba62cd3246457950" dependencies = [ "js-sys", "wasm-bindgen", @@ -463,9 +463,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" +checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -473,9 +473,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" +checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284" dependencies = [ "bumpalo", "proc-macro2", @@ -486,18 +486,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" +checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-bindgen-test" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0d555ca874445df8d314f94f5c948a4e74e5418f332c89f660a3d8310a96f4" +checksum = "895a2607575412a4eda1df892084a375ea10dfeadc4d7d2ab87b854e4ddc7ba1" dependencies = [ "async-trait", "cast", @@ -517,9 +517,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94eb68555b95bcea5e8cf4abe280b529049479fa995bfc23734af96a6aedc120" +checksum = "4288cb0ebe215033bf949ae1fd046726daa4c32a157f24b9dc6ac387a52aa759" dependencies = [ "proc-macro2", "quote", @@ -528,9 +528,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-shared" -version = "0.2.126" +version = "0.2.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31d56021e873866c968588ed85ccdf56db5c426e44afdb4618c39895104b920" +checksum = "33ff1c1b360982e93b6d8ea9c04836f71dba0817a16f91e229cf3a51bdd9d987" [[package]] name = "wasm_split_helpers" diff --git a/integration/Cargo.toml b/integration/Cargo.toml index 20fe2a8..4993d2d 100644 --- a/integration/Cargo.toml +++ b/integration/Cargo.toml @@ -18,7 +18,7 @@ publish = false [workspace.dependencies] wasm_split_helpers = { path = "../crates/wasm_split", version = "0.2.0" } -wasm-bindgen = "=0.2.126" +wasm-bindgen = "=0.2.127" wasm-bindgen-futures = "0.4.55" wasm-bindgen-test = "0.3.55" tokio = { version = "1.48", features = ["rt", "macros"] } diff --git a/test-runner/Cargo.lock b/test-runner/Cargo.lock index c5adbcd..0efc712 100644 --- a/test-runner/Cargo.lock +++ b/test-runner/Cargo.lock @@ -2007,12 +2007,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.256.0" +version = "0.257.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec1492381bfd5ea51c2a99a919b676662559925cb8d7490547ec2e14c1ad3eb1" +checksum = "7d8ad9f0a39050867bda22e6486c316e2e52d20a42154d5bc433934bf738d085" dependencies = [ "leb128fmt", - "wasmparser 0.256.0", + "wasmparser 0.257.1", ] [[package]] @@ -2040,8 +2040,8 @@ dependencies = [ "lazy_static", "regex", "tracing", - "wasm-encoder 0.256.0", - "wasmparser 0.256.0", + "wasm-encoder 0.257.1", + "wasmparser 0.257.1", ] [[package]] @@ -2059,9 +2059,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.256.0" +version = "0.257.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60bd825ffedc6cba8a642924ba7ae424afbc47811cffbcb7b92031ec24e59b4c" +checksum = "d92fc335fb6d48f46bda1d8b26b69e28320c15ac3272208333833d6e217e2b4a" dependencies = [ "bitflags", "hashbrown 0.17.1", From 656198b1bbad9fa0bb400b48c266249f92ce6908 Mon Sep 17 00:00:00 2001 From: WorldSEnder Date: Thu, 20 Aug 2026 17:25:07 +0200 Subject: [PATCH 3/3] small bug fix related to len tracking --- crates/wasm_split_cli/src/read.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/wasm_split_cli/src/read.rs b/crates/wasm_split_cli/src/read.rs index 55c2f49..ce062ec 100644 --- a/crates/wasm_split_cli/src/read.rs +++ b/crates/wasm_split_cli/src/read.rs @@ -201,10 +201,12 @@ impl DwarfReader<'_> { } impl<'a> From> for DwarfReader<'a> { fn from(custom: CustomSectionReader<'a>) -> Self { - DwarfReader { + let rdr = DwarfReader { data: custom.data(), data_range: custom.data_range(), - } + }; + assert!(rdr.data.len() == (rdr.data_range.end - rdr.data_range.start) as usize); + rdr } } impl<'a> gimli::Reader for DwarfReader<'a> { @@ -216,7 +218,8 @@ impl<'a> gimli::Reader for DwarfReader<'a> { } fn len(&self) -> Self::Offset { - (self.data_range.end - self.data_range.start) as usize + debug_assert!(self.data.len() == (self.data_range.end - self.data_range.start) as usize); + self.data.len() } fn empty(&mut self) { @@ -262,14 +265,15 @@ impl<'a> gimli::Reader for DwarfReader<'a> { } let (prefix, more) = self.data.split_at(len); let mid = self.data_range.start + len as u64; + let split = Self { + data: prefix, + data_range: self.data_range.start..mid, + }; *self = Self { data: more, data_range: mid..self.data_range.end, }; - Ok(Self { - data: prefix, - data_range: self.data_range.start..mid, - }) + Ok(split) } fn to_slice(&self) -> gimli::Result> {