rustwasm/twiggy

WASM files with a Tags section are not supported

SingleAccretion opened this issue · 1 comments

WASM files with a tag section (i. e. those produced by compilers targeting the EH proposal) fail to parse:

> twiggy top HelloWasm.wasm

error: WASM error: Invalid section code (at offset 18306)
  caused by: Invalid section code (at offset 18306)

> wasm-objdump -h HelloWasm.wasm

HelloWasm.wasm: file format wasm 0x1

Sections:

     Type start=0x0000000e end=0x000006b1 (size=0x000006a3) count: 199
   Import start=0x000006b7 end=0x00000a8f (size=0x000003d8) count: 37
 Function start=0x00000a95 end=0x00004768 (size=0x00003cd3) count: 15498
    Table start=0x0000476e end=0x00004775 (size=0x00000007) count: 1
   Memory start=0x0000477b end=0x00004782 (size=0x00000007) count: 1 <!-- Note the end offset in decimal: 18306 -->   
      Tag start=0x00004788 end=0x0000478b (size=0x00000003) count: 1
   Global start=0x00004791 end=0x000047a9 (size=0x00000018) count: 4
   Export start=0x000047af end=0x00004c60 (size=0x000004b1) count: 68
     Elem start=0x00004c66 end=0x000097e5 (size=0x00004b7f) count: 1
     Code start=0x000097eb end=0x003278db (size=0x0031e0f0) count: 15498
     Data start=0x003278e1 end=0x0044360f (size=0x0011bd2e) count: 2

twiggy version: twiggy-opt 0.7.0

Steps to Reproduce

Using the Emscripten SDK:

int main()
{
    try
    {
        throw 1;
    }
    catch (int i) { }
}
> emcc -c repro.cpp -o repro.o -fwasm-exceptions
> twiggy top repro.o

It will be fixed by upgrading wasmparser. https://docs.rs/wasmparser/latest/wasmparser/enum.TagKind.html as the newer version seems to support the exception tag.