| (module binary "\00asm\01\00\00\00") |
| (module binary "\00asm" "\01\00\00\00") |
| (module $M1 binary "\00asm\01\00\00\00") |
| (module $M2 binary "\00asm" "\01\00\00\00") |
| |
| (assert_malformed (module binary "") "unexpected end") |
| (assert_malformed (module binary "\01") "unexpected end") |
| (assert_malformed (module binary "\00as") "unexpected end") |
| (assert_malformed (module binary "asm\00") "magic header not detected") |
| (assert_malformed (module binary "msa\00") "magic header not detected") |
| (assert_malformed (module binary "msa\00\01\00\00\00") "magic header not detected") |
| (assert_malformed (module binary "msa\00\00\00\00\01") "magic header not detected") |
| (assert_malformed (module binary "asm\01\00\00\00\00") "magic header not detected") |
| (assert_malformed (module binary "wasm\01\00\00\00") "magic header not detected") |
| (assert_malformed (module binary "\7fasm\01\00\00\00") "magic header not detected") |
| (assert_malformed (module binary "\80asm\01\00\00\00") "magic header not detected") |
| (assert_malformed (module binary "\82asm\01\00\00\00") "magic header not detected") |
| (assert_malformed (module binary "\ffasm\01\00\00\00") "magic header not detected") |
| |
| ;; 8-byte endian-reversed. |
| (assert_malformed (module binary "\00\00\00\01msa\00") "magic header not detected") |
| |
| ;; Middle-endian byte orderings. |
| (assert_malformed (module binary "a\00ms\00\01\00\00") "magic header not detected") |
| (assert_malformed (module binary "sm\00a\00\00\01\00") "magic header not detected") |
| |
| ;; Upper-cased. |
| (assert_malformed (module binary "\00ASM\01\00\00\00") "magic header not detected") |
| |
| ;; EBCDIC-encoded magic. |
| (assert_malformed (module binary "\00\81\a2\94\01\00\00\00") "magic header not detected") |
| |
| ;; Leading UTF-8 BOM. |
| (assert_malformed (module binary "\ef\bb\bf\00asm\01\00\00\00") "magic header not detected") |
| |
| ;; Malformed binary version. |
| (assert_malformed (module binary "\00asm") "unexpected end") |
| (assert_malformed (module binary "\00asm\01") "unexpected end") |
| (assert_malformed (module binary "\00asm\01\00\00") "unexpected end") |
| (assert_malformed (module binary "\00asm\00\00\00\00") "unknown binary version") |
| (assert_malformed (module binary "\00asm\0d\00\00\00") "unknown binary version") |
| (assert_malformed (module binary "\00asm\0e\00\00\00") "unknown binary version") |
| (assert_malformed (module binary "\00asm\00\01\00\00") "unknown binary version") |
| (assert_malformed (module binary "\00asm\00\00\01\00") "unknown binary version") |
| (assert_malformed (module binary "\00asm\00\00\00\01") "unknown binary version") |
| |
| |
| ;; call_indirect reserved byte equal to zero. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\04\04\01\70\00\00" ;; Table section |
| "\0a\09\01" ;; Code section |
| |
| ;; function 0 |
| "\07\00" |
| "\41\00" ;; i32.const 0 |
| "\11\00" ;; call_indirect (type 0) |
| "\01" ;; call_indirect reserved byte is not equal to zero! |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| ;; call_indirect reserved byte should not be a "long" LEB128 zero. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\04\04\01\70\00\00" ;; Table section |
| "\0a\0a\01" ;; Code section |
| |
| ;; function 0 |
| "\07\00" |
| "\41\00" ;; i32.const 0 |
| "\11\00" ;; call_indirect (type 0) |
| "\80\00" ;; call_indirect reserved byte |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| ;; Same as above for 3, 4, and 5-byte zero encodings. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\04\04\01\70\00\00" ;; Table section |
| "\0a\0b\01" ;; Code section |
| |
| ;; function 0 |
| "\08\00" |
| "\41\00" ;; i32.const 0 |
| "\11\00" ;; call_indirect (type 0) |
| "\80\80\00" ;; call_indirect reserved byte |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\04\04\01\70\00\00" ;; Table section |
| "\0a\0c\01" ;; Code section |
| |
| ;; function 0 |
| "\09\00" |
| "\41\00" ;; i32.const 0 |
| "\11\00" ;; call_indirect (type 0) |
| "\80\80\80\00" ;; call_indirect reserved byte |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\04\04\01\70\00\00" ;; Table section |
| "\0a\0d\01" ;; Code section |
| |
| ;; function 0 |
| "\0a\00" |
| "\41\00" ;; i32.const 0 |
| "\11\00" ;; call_indirect (type 0) |
| "\80\80\80\80\00" ;; call_indirect reserved byte |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| ;; memory.grow reserved byte equal to zero. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\09\01" ;; Code section |
| |
| ;; function 0 |
| "\07\00" |
| "\41\00" ;; i32.const 0 |
| "\40" ;; memory.grow |
| "\01" ;; memory.grow reserved byte is not equal to zero! |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| ;; memory.grow reserved byte should not be a "long" LEB128 zero. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\0a\01" ;; Code section |
| |
| ;; function 0 |
| "\08\00" |
| "\41\00" ;; i32.const 0 |
| "\40" ;; memory.grow |
| "\80\00" ;; memory.grow reserved byte |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| ;; Same as above for 3, 4, and 5-byte zero encodings. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\0b\01" ;; Code section |
| |
| ;; function 0 |
| "\09\00" |
| "\41\00" ;; i32.const 0 |
| "\40" ;; memory.grow |
| "\80\80\00" ;; memory.grow reserved byte |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\0c\01" ;; Code section |
| |
| ;; function 0 |
| "\0a\00" |
| "\41\00" ;; i32.const 0 |
| "\40" ;; memory.grow |
| "\80\80\80\00" ;; memory.grow reserved byte |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\0d\01" ;; Code section |
| |
| ;; function 0 |
| "\0b\00" |
| "\41\00" ;; i32.const 0 |
| "\40" ;; memory.grow |
| "\80\80\80\80\00" ;; memory.grow reserved byte |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| ;; memory.size reserved byte equal to zero. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\07\01" ;; Code section |
| |
| ;; function 0 |
| "\05\00" |
| "\3f" ;; memory.size |
| "\01" ;; memory.size reserved byte is not equal to zero! |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| ;; memory.size reserved byte should not be a "long" LEB128 zero. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\08\01" ;; Code section |
| |
| ;; function 0 |
| "\06\00" |
| "\3f" ;; memory.size |
| "\80\00" ;; memory.size reserved byte |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| ;; Same as above for 3, 4, and 5-byte zero encodings. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\09\01" ;; Code section |
| |
| ;; function 0 |
| "\07\00" |
| "\3f" ;; memory.size |
| "\80\80\00" ;; memory.size reserved byte |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\0a\01" ;; Code section |
| |
| ;; function 0 |
| "\08\00" |
| "\3f" ;; memory.size |
| "\80\80\80\00" ;; memory.size reserved byte |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\05\03\01\00\00" ;; Memory section |
| "\0a\0b\01" ;; Code section |
| |
| ;; function 0 |
| "\09\00" |
| "\3f" ;; memory.size |
| "\80\80\80\80\00" ;; memory.size reserved byte |
| "\1a" ;; drop |
| "\0b" ;; end |
| ) |
| "zero flag expected" |
| ) |
| |
| ;; No more than 2^32 locals. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\0a\0c\01" ;; Code section |
| |
| ;; function 0 |
| "\0a\02" |
| "\ff\ff\ff\ff\0f\7f" ;; 0xFFFFFFFF i32 |
| "\02\7e" ;; 0x00000002 i64 |
| "\0b" ;; end |
| ) |
| "too many locals" |
| ) |
| |
| ;; Local count can be 0. |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section |
| "\0a\0a\01" ;; Code section |
| |
| ;; function 0 |
| "\08\03" |
| "\00\7f" ;; 0 i32 |
| "\00\7e" ;; 0 i64 |
| "\02\7d" ;; 2 f32 |
| "\0b" ;; end |
| ) |
| |
| ;; Function section has non-zero count, but code section is absent. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\03\02\00\00" ;; Function section with 2 functions |
| ) |
| "function and code section have inconsistent lengths" |
| ) |
| |
| ;; Code section has non-zero count, but function section is absent. |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\0a\04\01\02\00\0b" ;; Code section with 1 empty function |
| ) |
| "function and code section have inconsistent lengths" |
| ) |
| |
| ;; Function section count > code section count |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\03\02\00\00" ;; Function section with 2 functions |
| "\0a\04\01\02\00\0b" ;; Code section with 1 empty function |
| ) |
| "function and code section have inconsistent lengths" |
| ) |
| |
| ;; Function section count < code section count |
| (assert_malformed |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\01\04\01\60\00\00" ;; Type section |
| "\03\02\01\00" ;; Function section with 1 function |
| "\0a\07\02\02\00\0b\02\00\0b" ;; Code section with 2 empty functions |
| ) |
| "function and code section have inconsistent lengths" |
| ) |
| |
| ;; Function section has zero count, and code section is absent. |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\03\01\00" ;; Function section with 0 functions |
| ) |
| |
| ;; Code section has zero count, and function section is absent. |
| (module binary |
| "\00asm" "\01\00\00\00" |
| "\0a\01\00" ;; Code section with 0 functions |
| ) |