So is your problem now solved?
To rephrase my response: If you are injecting code into a module, can't
you also simply inject a new import?
On Sat, May 4, 2019 at 10:33 PM Duan Bing wrote:
> Hi, Sam:
> Yes, I have an implementation based on WAVM, design doc :
>
Hi, Sam:
Yes, I have an implementation based on WAVM, design doc :
https://github.com/duanbing/WAVM/blob/master/Gas.md .
'Sam Clegg' via emscripten-discuss
于2019年5月4日周六 下午3:14写道:
> One way to achieve this might be to use binaryen tools to inject your wasm
> code into the module. One of
One way to achieve this might be to use binaryen tools to inject your wasm
code into the module. One of the simplest ways would be use wasm-dis to
turn the module into text, when wasm-as to re-assembly it after adding your
new imports and code.
*From: *Duan Bing
*Date: *Fri, May 3, 2019 at 8:14
PS: I've been looking around a bit, and maybe this is the better solution
(via __attribute__(...)):
__attribute__((visibility("default"))) void foo(void);
This should be the clang equivalent to __declspec(dllimport) in the Visual
Studio compiler, see here:
Thanks, your new idea works for me. the motivation of doing this is that
I will call this imported function while I will insert some wasm code to
the original wasm file later, similar to this project had done
https://github.com/ewasm/wasm-metering , but by a different PL. so I don't
want the
Ah ok, I misunderstood your question, apologies. I don't know how one would
add a function declaration to the WASM imports table like this.
EMSCRIPTEN_KEEPALIVE and the "-s EXPORTED_FUNCTIONS" linker option would
work for the "other side" (some WASM module exporting functions to the
outside).
Thanks, Floh. it works when the function is defined.
Actually, my function is an external function declaration, like
extern "C" void foo();
It doesn't work even I declare like this:
extern "C" void EMSCRIPTEN_KEEPALIVE foo().
Do you have any idea for this situation?
Floh 于2019年5月2日周四
Have a look at EMSCRIPTEN_KEEPALIVE:
https://emscripten.org/docs/api_reference/emscripten.h.html#c.EMSCRIPTEN_KEEPALIVE,
this prevents a C/C++ function from being removed even when it isn't
referenced by other C/C++ code (normally this is used to call C functions
from the JS side).
On
I declare an external function in C source file, but never used by the
code, then compile it to wasm by EMCC. there is no doubt the external
function will be eliminated by the compiler.
Is there any approach to keep this external function and then be compiled
to an import function in wasm?
The