Support r2core.js for Emscripten >=v1.37.24 (#12502)

* Support r2core.js for Emscripten >=v1.37.24

cwrap needs to be exported explicitly via EXTRA_EXPORTED_RUNTIME_METHODS
+ allocate larger memory, allow for growth and no aborting malloc

* wasm_asm was wrongly also included in anal.wasm

This causes link errors where duplicate symbols aren't allowed.

* supply wasm plugin to suppress meta arch warning

r2 core initializes itself for the current architecture until one is
explicitly specified (e.g. loading a binary).  Since asm.wasm and
arch.wasm isn't supplied by default, r2 when built for WebAssembly
emits some ugly warnings when loading.  Besides, those modules
(incl. bin.wasm) aren't that large.

* r2core: Make it possible to know when init is done
This commit is contained in:
iamahuman 2018-12-17 19:55:44 +09:00 committed by radare
parent 7060103292
commit a54dbe914b
3 changed files with 7 additions and 2 deletions

View File

@ -20,6 +20,10 @@ ifeq (${COMPILER},emscripten)
# -s INLINING_LIMIT=1
# --memory-init-file 0
CFLAGS+=-s EXPORTED_FUNCTIONS='["_r2_asmjs_new", "_r2_asmjs_cmd", "_r2_asmjs_free", "_r2_asmjs_openurl"]'
CFLAGS+=-s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap", "addOnInit"]'
CFLAGS+=-s TOTAL_MEMORY=33554432
CFLAGS+=-s ALLOW_MEMORY_GROWTH=1
CFLAGS+=-s ABORTING_MALLOC=0
#CFLAGS+=-Oz --memory-init-file 0
endif

View File

@ -1,6 +1,4 @@
WASM_ROOT=../../asm/arch/wasm
OBJ_WASM=anal_wasm.o
OBJ_WASM+=$(WASM_ROOT)/wasm.o
CFLAGS+=-I$(WASM_ROOT)
STATIC_OBJ+=${OBJ_WASM}

View File

@ -6,12 +6,14 @@ asm.x86_cs
asm.x86_nz
asm.mips_cs
asm.avr
asm.wasm
anal.avr
anal.mips_cs
anal.x86_cs
anal.arm_cs
anal.java
anal.dalvik
anal.wasm
bin.any
bin.elf
bin.elf64
@ -22,6 +24,7 @@ bin.mz
bin.pe64
bin.mach0
bin.mach064
bin.wasm
bin_xtr.xtr_fatmach0
core.java
core.a2f