Skip to content

Commit

Permalink
Add steps to use wasm modules with imported memory and imported table
Browse files Browse the repository at this point in the history
  • Loading branch information
shravanrn committed Mar 5, 2024
1 parent a1dc855 commit a1d607e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
- [Installing and running tutorial examples](./chapters/tutorial-install.md)
- [Additional resources](./chapters/additional.md)
- [Modifying a project that uses Make to compile to Wasm](./chapters/makefile-wasm.md)
- [Using a Wasm module with imported memory and imported tables](./chapters/wasm-exported-sandbox.md)
- [More tutorials](chapters/appendix.md)
1 change: 1 addition & 0 deletions src/chapters/additional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Additional resources
11 changes: 11 additions & 0 deletions src/chapters/wasm-exported-sandbox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Using a Wasm module with imported memory and imported tables

By default, RLBox operates on Wasm modules with an imported memory and imported
table. This allows RLBox to optimize the memory allocation's alignment for its
internal operations. However, you can also use modules with exported memory and
exported tables (albeit with some performance penalty).

To do this, adjust the flags during the compilation of your Wasm module to
export memory and tables. Specifically, remove the arguments
`-Wl,--import-memory -Wl,--import-table` if present, and use the arguments
`-Wl,--export-all -Wl,--export-table`
8 changes: 6 additions & 2 deletions src/chapters/wasm-sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ wasi-clang will link wasi-libc (a custom version of musl) with your library
instead of the system `libc`. The wasi-libc library and headers live in
`$WASI_SYSROOT`

Also note worthy are the `$(WASM_CFLAGS)` which are important to ensure that
our output plays nicely with the rest of the toolchain.
Also note worthy are the `$(WASM_CFLAGS)` which are important to ensure that our
output plays nicely with the rest of the toolchain. By default, the flags we use
forces the Wasm module to use an "imported" memory allocation and "imported"
indirection function table that is created by RLBox for optimal performance.
(See [Using a Wasm module with imported memory and imported tables](./wasm-exported-sandbox.md)
for other options)

<!-- XXX explain flags -->

Expand Down

0 comments on commit a1d607e

Please sign in to comment.