Stream: general

Topic: Modifying component wasm binaries


view this post on Zulip Daniel Macovei (Jul 31 2023 at 16:22):

Currently playing around with replacing wasm sections with other sections. Is there a recommended way to go about doing that?

view this post on Zulip Daniel Macovei (Jul 31 2023 at 16:23):

Specifically... interested in inlining import statements with an external wasm component

view this post on Zulip Daniel Macovei (Jul 31 2023 at 16:36):

Been playing around with a few ways. May try and make a RawSection from wasm-encoder and just remove the raw bytes that are the import section

view this post on Zulip fitzgen (he/him) (Jul 31 2023 at 17:15):

there isn't really a good framework for dealing with this kind of stuff. wasmparser and wasm-encoder is pretty much how it is done. you can look at various Mutator impls in wasm-mutate to get an idea of how these sorts of things have been done before

view this post on Zulip Daniel Macovei (Jul 31 2023 at 17:43):

Thanks for the info! Yeah I was looking around there a bit too. I was getting the impression that it's primarily been used for core wasm modules, which I believe have some guarantees about section order that I know longer get to assume when working with components right?

view this post on Zulip Daniel Macovei (Jul 31 2023 at 18:02):

I guess you could always just parse the whole thing and for each payload you get, encode precisely what you just parsed, except for replacing the specific section with some other component. Feels a little awkward but it would get the job done I think

view this post on Zulip Bailey Hayes (Jul 31 2023 at 19:53):

It might also be worth checking out https://github.com/rustwasm/walrus

Walrus is a WebAssembly transformation library ๐ŸŒŠ๐Ÿ˜. Contribute to rustwasm/walrus development by creating an account on GitHub.

view this post on Zulip Guy Bedford (Jul 31 2023 at 23:20):

I'd be all for extending walrus to support components

view this post on Zulip Daniel Macovei (Aug 01 2023 at 21:45):

I think I've found a way to meet my immediate needs using a combo of wasmparser and wasm-encoder. Could definitely be cool to help out with some walrus component support in the long term though


Last updated: Nov 22 2024 at 16:03 UTC