Enable register native with iwasm (#1120)

Enable register native with iwasm application, add sample and update document.
This commit is contained in:
Wenyong Huang
2022-04-27 11:12:50 +08:00
committed by GitHub
parent 9013a474bc
commit 2007ba38cf
11 changed files with 374 additions and 13 deletions

View File

@ -129,11 +129,19 @@ int main(int argc, char **argv)
}
```
## Build native lib into shared library and register it with `iwasm` application
Developer can also build the native library into a shared library and register it with iwasm application:
```bash
iwasm --native-lib=<lib file> <wasm file>
```
Refer to [native lib sample](../samples/native-lib) for more details.
## Buffer address conversion and boundary check
A WebAssembly sandbox ensures applications only access to its own memory with a private address space. When passing a pointer address from WASM to native, the address value must be converted to native address before the native function can access it. It is also the native world's responsibility to check the buffer length is not over its sandbox boundary.
A WebAssembly sandbox ensures applications only access to its own memory with a private address space. When passing a pointer address from WASM to native, the address value must be converted to native address before the native function can access it. It is also the native world's responsibility to check the buffer length is not over its sandbox boundary.