Generate identify .map file based on the wasm file. This file can be used later to append DWARF to the post-processed wasm.
Marges initial DWARF, wasm .map file and placed that into post-processed wasm.
$ cat fib2.c
int fib(int n) {
int i, t, a = 0, b = 1;
for (i = 0; i < n; i++) {
t = a;
a = b;
b += t;
}
return b;
}
void test() {
fib(6);
}
# Build wasm file with DWARF info
$ clang -g fib2.c -Wl,-no-entry,--export=test,--export=fib -nostdlib -o fib2.wasm
# Generate identity .map file
$ cargo run --bin wtmaps fib2.wasm -o fib2.map
# Optimize wasm using binaryen, provide initial/identity .map file and produce .map w/post-processed wasm
$ wasm-opt fib2.wasm -o fib2_o.wasm -ism fib2.map -osm fib2_o.map
# Merge post-processed fib2_o.wasm with original DWARF information (from fib2.wasm) trasformed using fib2_o.map.
$ cargo run --bin wdwarf-cp fib2.wasm -o fib2_t.wasm -m fib2_o.map -w fib2_o.wasm