alexcrichton commented on issue #3266:
It's worth noting that this will, by default, not play nicely with https://github.com/bytecodealliance/wasmtime/pull/3265. Relocations are the only part of the file which we actually modify today, so some code will be added to tempoarily change the text section to read/write if relocations need to be applied. With https://github.com/bytecodealliance/wasmtime/pull/3254, though, that should be rare. I don't actually know if it's possible for the new backend to generate any other relocations after we remove those for
call
instructions.
github-actions[bot] commented on issue #3266:
Subscribe to Label Action
cc @peterhuene
<details>
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:c-api"Thus the following users have been cc'd because of the following labels:
- peterhuene: wasmtime:api, wasmtime:c-api
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
alexcrichton commented on issue #3266:
Ok I've added a commit to handle the case that we need relocations now that https://github.com/bytecodealliance/wasmtime/pull/3265 is in
main
peterhuene commented on issue #3266:
So I through a little test program together: https://gist.github.com/peterhuene/64a5dc5dd22f28950ec397a5709f0eda
This seems to do what we want: a single mapping where we can keep everything but the text section read-only and have CoW semantics for the text section when applying relocations.
peterhuene commented on issue #3266:
Also, we'll need to have something in
CodeMemory
for Windows that detects if the mapping is backed by a file and usePAGE_WRITECOPY
(that's not a valid protection level for anonymous pages) for the relocations; otherwise we can stick toPAGE_READWRITE
.
peterhuene edited a comment on issue #3266:
So I threw a little test program together: https://gist.github.com/peterhuene/64a5dc5dd22f28950ec397a5709f0eda
This seems to do what we want: a single mapping where we can keep everything but the text section read-only and have CoW semantics for the text section when applying relocations.
alexcrichton commented on issue #3266:
So I threw a little test program together: https://gist.github.com/peterhuene/64a5dc5dd22f28950ec397a5709f0eda
Thanks for this! I just blindly copy/pasted that into Wasmtime now :)
As you can probably tell I did not indeed run tests at all on Windows beforehand, how naive of me to assume it would be the same! In any case I'm glad you know what you're doing, it would have taken me quite awhile to figure out how to align all those stars...
alexcrichton commented on issue #3266:
Oh hey and with your help works on the first try!
Last updated: Nov 22 2024 at 17:03 UTC