Skip to content

Commit

Permalink
Library sandboxing changes
Browse files Browse the repository at this point in the history
- Windows/msvc support for runtime, codegen and builtins as well as support for a wider list of platforms/architectures/compilers including Android (arm architectures), Windows 32-bit etc.
- Support for growable indirect function call tables
- Support for library sandboxing apis --- wasm function type index lookup (so host can add new callbacks), make heaps aligned to 4gb for compatiblity with the RLBox sandboxing framework
- Allow multiple sandbox instances of the same library by moving global vars into a context structure that is passed to every function
- Migrated from emscripten to use of wasi-clang
- Upstream libc-wasi does not support windows, so I have written a minimal cross platform wasi support which includes just basic wasi function (just enough to get simple IO libraries running. Nothing complicated like networking or filesystem is supported)
- Removed use of per function call signal handler, setjmp/longjmp as this slows transitions
- Removed name mangling to simplify function lookup
- Remove stack depth counting as this adds unnecessary overhead
- A debugging aid built directly into wasm2c generated code that is similar to valgrind like shadow memory (significantly eases debugging of wasm)
- A wasm2c runner that can run full applications (code that has a main), when they are compiled via wasm2c to C and then to a shared library (.so/.dll)
  • Loading branch information
shravanrn committed Feb 18, 2022
1 parent a8f401d commit f62d8f0
Show file tree
Hide file tree
Showing 24 changed files with 4,368 additions and 826 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/bin
/build
/build*
/out
/fuzz-out
/emscripten
*.pyc
*.o
.idea/
.vscode/
/cmake-build-debug/
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,9 @@ set(WABT_LIBRARY_SRC

add_library(wabt STATIC ${WABT_LIBRARY_SRC})

IF (NOT WIN32)
add_library(wasm-rt-impl STATIC wasm2c/wasm-rt-impl.c wasm2c/wasm-rt-impl.h)
install(TARGETS wasm-rt-impl DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES wasm2c/wasm-rt.h wasm2c/wasm-rt-impl.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif ()
add_library(wasm-rt-impl STATIC SHARED wasm2c/wasm-rt-impl.c wasm2c/wasm-rt-os-unix.c wasm2c/wasm-rt-os-win.c wasm2c/wasm-rt-wasi.c)
install(TARGETS wasm-rt-impl DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES wasm2c/wasm-rt.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

if (BUILD_FUZZ_TOOLS)
set(FUZZ_FLAGS "-fsanitize=fuzzer,address")
Expand Down Expand Up @@ -472,6 +470,19 @@ if (BUILD_TOOLS)
INSTALL
)

if (NOT WIN32)
set(LDL_LIB "-ldl")
else()
set(LDL_LIB "")
endif()

wabt_executable(
NAME wasm2c-runner
SOURCES wasm2c/wasm-rt-runner.c
LIBS ${LDL_LIB}
INSTALL
)

# wasm-opcodecnt
wabt_executable(
NAME wasm-opcodecnt
Expand Down
Loading

0 comments on commit f62d8f0

Please sign in to comment.