Skip to content
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

wasm: Finish TLS & shared-memory implementation #68

Merged
merged 6 commits into from
Jul 15, 2023

Conversation

Luukdegram
Copy link
Collaborator

This implements TLS relocations and fixes various issues in the shared-memory implementation. With these additions, we can now correctly link the threading example from the Zig main repo. The last remaining step for full static-linking support is garbage collection.

Fixes memory_init by making timeout a i64 instead of i32.
Also fixes tls_init by setting the __tls_base global instead of
retrieving it and correctly writing the 0 byte as u8 rather than
as u32.
When we have shared-memory, the memory will be initialized during
module initialization. To ensure this is being done, we set the
mentioned function as the entrypoint of the WebAssembly module.
This function will be called upon thread creation too, to ensure
the memory is correctly initialized. The execution of the first
startup will then continue with `__start` (when available).
We were writing the values as unsigned integers, causing OOB memory
reads. We now correctly write the constants as signed integers by
first bitcasting them.
@Luukdegram Luukdegram merged commit 82439c7 into kubkon:main Jul 15, 2023
2 checks passed
@Luukdegram Luukdegram deleted the threads branch July 15, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant