Combine multiple wasm files

803 views
Skip to first unread message

Mehaboob kk

unread,
Jun 19, 2021, 6:45:38 PM6/19/21
to emscripte...@googlegroups.com
Hello,

Is it possible to combine multiple .wasm files to one single .wasm file?

Scenario:
I want to share a library(SDK) to an end customer who is building the .wasm/JS application. Customer concerned that loading multiple wasm files is not efficient. So we wanted to combine two wasm files. Although I can share static lib generated using Emscripten, its not preferred because .a file is easy to reverse compared to wasm right?

Any inputs on this please?

Thank you

Sam Clegg

unread,
Jun 19, 2021, 8:23:43 PM6/19/21
to emscripte...@googlegroups.com
What is the current mechanism for loading the wasm file you are supplying?  Are you using emscripten's dynamic linking capability (i.e. MAIN_MODULE + SIDE_MODULE?).

If that answer is yes, and you are asking about linking a SIDE_MODULE into the MAIN_MODULE ahead of time, its not something that is supported no.  Also, shared libraries (side moudles) are are only slightly more obfuscated than object files and `.a` archives.  They are all in the wasm format which is fairly easy to disassembly.  If you want to try to prevent decompilation or disassembly you would need to do more than just ship as a shared library (side module) you would also need to perform some kind of obfuscation, which by its nature (and the nature of WebAssemlby in particular) is always going to have limits.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAO5iXcCQC45LU%3DNMFev5PYjn%2BmzOOgDfhXx0ahDXq8GqKRVjJQ%40mail.gmail.com.

Mehaboob kk

unread,
Sep 1, 2021, 10:17:46 PM9/1/21
to emscripte...@googlegroups.com
Sorry, I missed this post. Thank you for answering my question. What I am doing now is to build multiple .a files and combine while linking into one wasm file. 
I tried reverse engineer wasm and .a files back to c file and its still wat like format not getting back to the original c/c++ code which I started with. However, someone who is intimately familiar with wasm may be able to figure out the source, just like a assembly language expert can understand the logic. Now I am trying to apply some source obfuscation as binary obfuscation tools not available for wasm. 
Do you think my understanding is correct? Are there any tools out there to reproduce the exact c code from wasm binary?




Sam Clegg

unread,
Sep 2, 2021, 6:46:16 AM9/2/21
to emscripte...@googlegroups.com
On Wed, Sep 1, 2021 at 7:17 PM Mehaboob kk <mehab...@gmail.com> wrote:
Sorry, I missed this post. Thank you for answering my question. What I am doing now is to build multiple .a files and combine while linking into one wasm file. 
I tried reverse engineer wasm and .a files back to c file and its still wat like format not getting back to the original c/c++ code which I started with. However, someone who is intimately familiar with wasm may be able to figure out the source, just like a assembly language expert can understand the logic. Now I am trying to apply some source obfuscation as binary obfuscation tools not available for wasm. 
Do you think my understanding is correct? Are there any tools out there to reproduce the exact c code from wasm binary?

 
No, just like with other binary formats, disassemblers and de-compilers can never reproduce the exact C code from a binary.    For example local variable names cannot ever be recovered. 




On Sat, Jun 19, 2021 at 8:23 PM 'Sam Clegg' via emscripten-discuss <emscripte...@googlegroups.com> wrote:
What is the current mechanism for loading the wasm file you are supplying?  Are you using emscripten's dynamic linking capability (i.e. MAIN_MODULE + SIDE_MODULE?).

If that answer is yes, and you are asking about linking a SIDE_MODULE into the MAIN_MODULE ahead of time, its not something that is supported no.  Also, shared libraries (side moudles) are are only slightly more obfuscated than object files and `.a` archives.  They are all in the wasm format which is fairly easy to disassembly.  If you want to try to prevent decompilation or disassembly you would need to do more than just ship as a shared library (side module) you would also need to perform some kind of obfuscation, which by its nature (and the nature of WebAssemlby in particular) is always going to have limits.

On Sat, Jun 19, 2021 at 3:45 PM Mehaboob kk <mehab...@gmail.com> wrote:
Hello,

Is it possible to combine multiple .wasm files to one single .wasm file?

Scenario:
I want to share a library(SDK) to an end customer who is building the .wasm/JS application. Customer concerned that loading multiple wasm files is not efficient. So we wanted to combine two wasm files. Although I can share static lib generated using Emscripten, its not preferred because .a file is easy to reverse compared to wasm right?

Any inputs on this please?

Thank you

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAO5iXcCQC45LU%3DNMFev5PYjn%2BmzOOgDfhXx0ahDXq8GqKRVjJQ%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29zxMEFFi8gHEP5C0pBJ0idQh8qeqT%2B1S5v%3D9XO5BMKNA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages