Skip to content

Compatibility with --pie and --experimental-pic wasm-ld flag #4493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jkelleyrtp opened this issue Apr 29, 2025 · 0 comments
Open

Compatibility with --pie and --experimental-pic wasm-ld flag #4493

jkelleyrtp opened this issue Apr 29, 2025 · 0 comments

Comments

@jkelleyrtp
Copy link

jkelleyrtp commented Apr 29, 2025

Motivation

I've implemented WASM hot patching for Rust.

DioxusLabs/dioxus#3797 (comment)

432065352-b81f1a60-b6b2-422d-a536-d9e0bcd75221.mp4

I'd like to fixup the generated patches by running the various transforms (externref being the pricky set) but wasm-bindgen simply refuses to run with WASM linked with the wasm-ld pie and pic flags.

❯ wasm-bindgen --out-dir patch --target web libsimple-web-example-fullstack-patch-1745952796957.wasm
error: invalid offset for segment of function table Global(Id { idx: 2 })

The ifunc table is initialized to a global because it is relocated at runtime.

https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md

For references this is the set of linker args I'm passing to wasm-ld:

"--fatal-warnings",
"--verbose",
"--import-memory",
"--import-table",
"--growable-table",
"--export-all",
"--export",
"main",
"--allow-undefined",
"--no-demangle",
"--no-entry",
"--pie",
"--no-gc-sections",
"--experimental-pic",

Proposed Solution

wasm-bindgen should be able to work with relocatable ifunc tables.

Alternatives

I can work around this somewhat (using --table-base and --global-base flags and skipping PIE/PIC) but the tooling shouldn't just give up when it sees PIC/PIE code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant