wabt: wat2wasm fails with call_indirect and relocation
The following code fails to compile by wat2wasm (v1.12) if relocatable binary (-r) is requested. Is it expected? (exit code 0xC0000005) Non-relocatable binary compiles just fine.
(module
;; (type (func (param i32)(param i32)(result i32))) ;; fails, even if present
(func $add (param i32)(param i32)(result i32)
get_local 0
get_local 1
i32.add
return
)
(table 1 anyfunc)
(elem (i32.const 0) $add)
(func $run
i32.const 4444
i32.const 5555
i32.const 0
;;call_indirect (type 0) ;; fails
call_indirect (param i32)(param i32)(result i32) ;; fails
drop
)
(export "run" (func $run))
)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 29 (21 by maintainers)
Thanks, I’ll take a look at that! I think I should be able to write something up some time this week.
The issue we are discussing here mostly refers to linking with other object files. if you are not using a linker then writing pure WAT is a lot more reasonable.
Once the linker gets involved you will, at a minimum, want to assign symbolic names to memory locations.