Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Tool:Emscripten

From ReverseEngineering.wiki
Tool
On this wiki Facts · Code · Notes · Topics

Emscripten (MIT / NCSA) compiles C and C++ to WebAssembly and emits a JavaScript glue file with a Module object, a wasmImports table and a createWasm function that fetches and instantiates the .wasm next to it.

The glue is how to name the functions of an Emscripten .wasm whose own names were minified (Format:WebAssembly binary format#Toolchain identification).

Glue markers (src/shell.js and src/preamble.js at 5f63ff2e)

  • var Module = typeof <EXPORT_NAME> != 'undefined' ? <EXPORT_NAME> : {} at the top (shell.js lines 27-37; EXPORT_NAME defaults to Module).
  • Module['locateFile'] hook used to find the .wasm (shell.js line 176); wasmBinaryFile and findWasmBinary pick the file name (preamble.js lines 408-445); a secondary .deferred.wasm or .<moduleID>.wasm name for split modules (lines 503-506).
  • createWasm() builds the import object with 'env': wasmImports (preamble.js lines 724, 740), calls WebAssembly.instantiateStreaming where allowed (589, 680) and stores wasmExports = instance.exports, then runs wasmExports['__wasm_call_ctors'] (172).
  • In minified release builds the import module is a and the names a, b, c; the wasmImports object in the glue is the only map back to real functions.

Reversing

Read wasmImports for the libc and syscall stubs the program uses, then the exported wrapper calls (_main, _malloc, ...) to give names to the exports. Unverified: names of wrappers in a fully minified glue were not checked on a sample here.

Source: emscripten-core/emscripten at 5f63ff2e370da7e6fffd8f54379860bdd18118f9 (read, not run).

Code & repositories

  • https://github.com/emscripten-core/emscripten @ 5f63ff2e370da7e6fffd8f54379860bdd18118f9 · license: MIT OR NCSA (declared by the contributor for the files used; GitHub reports MIT (read from LICENSE; GitHub's API was busy) for the repository)
    Emscripten: src/shell.js and src/preamble.js are the JS glue templates (Module, wasmBinaryFile, createWasm, wasmImports).
    Tested on: source read, not run · checked 2026-10-19