-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Load precompiled module from library loaded by the OS loader? #7777
Comments
Serialized modules happen to use the ELF format, but that should be treated as an internal implementation detail to Wasmtime and is not intended to be exposed to any loader other than Module::deserialize, such as an OS loader. In general if pages can't be mapped as executable at all, then Wasmtime won't work whether it is mapping those pages out of a file (as in deserialize) or materializing them otherwise to create an executable Module. Can you tell us more about the use case that motivates this request? Maybe there is another way to meet it. |
Use case is using Wasmtime on platforms which limit mapping pages as executable. As I understand it, Wasmtime only needs to map compiled code as executable during Module creation, and doesn't need to generate any new code during execution, right? (with the exception of generating host function trampolines, but I take that this is intended to be removed too) |
Yes once a module is loaded and executable no further executable mappings need be may (so long as you don't use Are you working with a platform like iOS that doesn't allow mapping executable memory at all? Or something along those lines? If new executable memory can be dynamically loaded Wasmtime should work well, but if all the executable memory must be statically enumerated that'll be more difficult. |
I'm looking at feasibility of using wasmtime on game console. I will know more about the limitations later but it would be under NDA so I probably won't be able to discuss them here anyway. Alternatively I'm considiering using something like wasm2c, but that would require more changes in embedding code so getting wasmtime to work would be nice. I'm correct in that if sections from ELF artifact would be loaded into address space (with .text mapped as executable), it would suffice to basically modify CodeMemory::new to read header from passed pointer (obviously it won't be header of real underlying file, just decoy to point to already loaded data), and make CodeMemory::publish no-op? Or is there something more to it? It would need some external tooling to mangle precompiled output into object file that can be used, put decoy header in there, etc, but doesn't seem too complicated. As for |
Ah ok makes sense. The exact implementation of this I'm not certain about, but you're on the right track ish. Currently What this would perhaps look like is something along the lines of a |
Feature
Precompiled modules are ELF files that seemingly are able to be linked into executables. Would it be possible to let them load using OS loader (either by linking them into application binary, or linking into shared object and
dlopen
), and then import this code into wasmtime Module?Benefit
Support of platforms that doesn't allow mapping pages as executable, like iOS or game consoles.
Implementation
Module::deserialize
variant that takes pointers to already loaded segments and fills them intoCodeMemory
struct instead of mmaping them. Probably also needs #7349 to be useful.The text was updated successfully, but these errors were encountered: