diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 20194de..eaf88b1 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -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) diff --git a/src/chapters/additional.md b/src/chapters/additional.md new file mode 100644 index 0000000..c97d415 --- /dev/null +++ b/src/chapters/additional.md @@ -0,0 +1 @@ +# Additional resources diff --git a/src/chapters/wasm-exported-sandbox.md b/src/chapters/wasm-exported-sandbox.md new file mode 100644 index 0000000..36f591c --- /dev/null +++ b/src/chapters/wasm-exported-sandbox.md @@ -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` \ No newline at end of file diff --git a/src/chapters/wasm-sandbox.md b/src/chapters/wasm-sandbox.md index 563dc5b..474ec5b 100644 --- a/src/chapters/wasm-sandbox.md +++ b/src/chapters/wasm-sandbox.md @@ -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)