stage2: Upstream zwld (partly) into wasm backend #10229
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This upstreams a lot of logic from https://github.com/Luukdegram/zwld.
For now, I have chosen a hybrid method of linking, where easy-to-track and small computations are done using incremental style but hard-to-track linking is delayed until
flushModule()
. This has the benefits of having more information available during the linking process, and not having to worry too much about updating all indexes constantly. Besides, this will allow us to merge the remaining parts of zwld (once it gains the missing features), with almost no effort, meaning we will then be able to link both stage1 as well as stage2 code with external object files.Prior to this PR, we were using a userland implementation of an offset table where we placed it inside wasm's memory. After this PR, we will generate and resolve relocations properly. We now have all the information available to also produce object files from the wasm backend, rather than only executables (once the emitting parts are implemented).
cc @kubkon