1 (module binary "\00asm\01\00\00\00")
2 (module binary "\00asm" "\01\00\00\00")
3 (module $M1 binary "\00asm\01\00\00\00")
4 (module $M2 binary "\00asm" "\01\00\00\00")
6 (assert_malformed (module binary "") "unexpected end")
7 (assert_malformed (module binary "\01") "unexpected end")
8 (assert_malformed (module binary "\00as") "unexpected end")
9 (assert_malformed (module binary "asm\00") "magic header not detected")
10 (assert_malformed (module binary "msa\00") "magic header not detected")
11 (assert_malformed (module binary "msa\00\01\00\00\00") "magic header not detected")
12 (assert_malformed (module binary "msa\00\00\00\00\01") "magic header not detected")
13 (assert_malformed (module binary "asm\01\00\00\00\00") "magic header not detected")
14 (assert_malformed (module binary "wasm\01\00\00\00") "magic header not detected")
15 (assert_malformed (module binary "\7fasm\01\00\00\00") "magic header not detected")
16 (assert_malformed (module binary "\80asm\01\00\00\00") "magic header not detected")
17 (assert_malformed (module binary "\82asm\01\00\00\00") "magic header not detected")
18 (assert_malformed (module binary "\ffasm\01\00\00\00") "magic header not detected")
20 ;; 8-byte endian-reversed.
21 (assert_malformed (module binary "\00\00\00\01msa\00") "magic header not detected")
23 ;; Middle-endian byte orderings.
24 (assert_malformed (module binary "a\00ms\00\01\00\00") "magic header not detected")
25 (assert_malformed (module binary "sm\00a\00\00\01\00") "magic header not detected")
28 (assert_malformed (module binary "\00ASM\01\00\00\00") "magic header not detected")
30 ;; EBCDIC-encoded magic.
31 (assert_malformed (module binary "\00\81\a2\94\01\00\00\00") "magic header not detected")
34 (assert_malformed (module binary "\ef\bb\bf\00asm\01\00\00\00") "magic header not detected")
36 ;; Malformed binary version.
37 (assert_malformed (module binary "\00asm") "unexpected end")
38 (assert_malformed (module binary "\00asm\01") "unexpected end")
39 (assert_malformed (module binary "\00asm\01\00\00") "unexpected end")
40 (assert_malformed (module binary "\00asm\00\00\00\00") "unknown binary version")
41 (assert_malformed (module binary "\00asm\0d\00\00\00") "unknown binary version")
42 (assert_malformed (module binary "\00asm\0e\00\00\00") "unknown binary version")
43 (assert_malformed (module binary "\00asm\00\01\00\00") "unknown binary version")
44 (assert_malformed (module binary "\00asm\00\00\01\00") "unknown binary version")
45 (assert_malformed (module binary "\00asm\00\00\00\01") "unknown binary version")
47 ;; Unsigned LEB128 can have non-minimal length
49 "\00asm" "\01\00\00\00"
50 "\05\04\01" ;; Memory section with 1 entry
51 "\00\82\00" ;; no max, minimum 2
54 "\00asm" "\01\00\00\00"
55 "\05\07\01" ;; Memory section with 1 entry
56 "\00\82\80\80\80\00" ;; no max, minimum 2
59 ;; Signed LEB128 can have non-minimal length
61 "\00asm" "\01\00\00\00"
62 "\06\07\01" ;; Global section with 1 entry
63 "\7f\00" ;; i32, immutable
64 "\41\80\00" ;; i32.const 0
68 "\00asm" "\01\00\00\00"
69 "\06\07\01" ;; Global section with 1 entry
70 "\7f\00" ;; i32, immutable
71 "\41\ff\7f" ;; i32.const -1
75 "\00asm" "\01\00\00\00"
76 "\06\0a\01" ;; Global section with 1 entry
77 "\7f\00" ;; i32, immutable
78 "\41\80\80\80\80\00" ;; i32.const 0
82 "\00asm" "\01\00\00\00"
83 "\06\0a\01" ;; Global section with 1 entry
84 "\7f\00" ;; i32, immutable
85 "\41\ff\ff\ff\ff\7f" ;; i32.const -1
90 "\00asm" "\01\00\00\00"
91 "\06\07\01" ;; Global section with 1 entry
92 "\7e\00" ;; i64, immutable
93 "\42\80\00" ;; i64.const 0 with unused bits set
97 "\00asm" "\01\00\00\00"
98 "\06\07\01" ;; Global section with 1 entry
99 "\7e\00" ;; i64, immutable
100 "\42\ff\7f" ;; i64.const -1 with unused bits unset
104 "\00asm" "\01\00\00\00"
105 "\06\0f\01" ;; Global section with 1 entry
106 "\7e\00" ;; i64, immutable
107 "\42\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with unused bits set
111 "\00asm" "\01\00\00\00"
112 "\06\0f\01" ;; Global section with 1 entry
113 "\7e\00" ;; i64, immutable
114 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with unused bits unset
119 "\00asm" "\01\00\00\00"
120 "\05\03\01" ;; Memory section with 1 entry
121 "\00\00" ;; no max, minimum 0
122 "\0b\06\01" ;; Data section with 1 entry
123 "\00" ;; Memory index 0
124 "\41\00\0b\00" ;; (i32.const 0) with contents ""
128 "\00asm" "\01\00\00\00"
129 "\04\04\01" ;; Table section with 1 entry
130 "\70\00\00" ;; no max, minimum 0, funcref
131 "\09\06\01" ;; Element section with 1 entry
132 "\00" ;; Table index 0
133 "\41\00\0b\00" ;; (i32.const 0) with no elements
136 ;; Data segment memory index can have non-minimal length
138 "\00asm" "\01\00\00\00"
139 "\05\03\01" ;; Memory section with 1 entry
140 "\00\00" ;; no max, minimum 0
141 "\0b\07\01" ;; Data section with 1 entry
142 "\80\00" ;; Memory index 0, encoded with 2 bytes
143 "\41\00\0b\00" ;; (i32.const 0) with contents ""
146 ;; Element segment table index can have non-minimal length
148 "\00asm" "\01\00\00\00"
149 "\04\04\01" ;; Table section with 1 entry
150 "\70\00\00" ;; no max, minimum 0, funcref
151 "\09\09\01" ;; Element section with 1 entry
152 "\02\80\00" ;; Table index 0, encoded with 2 bytes
153 "\41\00\0b\00\00" ;; (i32.const 0) with no elements
156 ;; Unsigned LEB128 must not be overlong
159 "\00asm" "\01\00\00\00"
160 "\05\08\01" ;; Memory section with 1 entry
161 "\00\82\80\80\80\80\00" ;; no max, minimum 2 with one byte too many
163 "integer representation too long"
166 ;; Signed LEB128 must not be overlong
169 "\00asm" "\01\00\00\00"
170 "\06\0b\01" ;; Global section with 1 entry
171 "\7f\00" ;; i32, immutable
172 "\41\80\80\80\80\80\00" ;; i32.const 0 with one byte too many
175 "integer representation too long"
179 "\00asm" "\01\00\00\00"
180 "\06\0b\01" ;; Global section with 1 entry
181 "\7f\00" ;; i32, immutable
182 "\41\ff\ff\ff\ff\ff\7f" ;; i32.const -1 with one byte too many
185 "integer representation too long"
190 "\00asm" "\01\00\00\00"
191 "\06\10\01" ;; Global section with 1 entry
192 "\7e\00" ;; i64, immutable
193 "\42\80\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with one byte too many
196 "integer representation too long"
200 "\00asm" "\01\00\00\00"
201 "\06\10\01" ;; Global section with 1 entry
202 "\7e\00" ;; i64, immutable
203 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with one byte too many
206 "integer representation too long"
209 ;; Unsigned LEB128s zero-extend
212 "\00asm" "\01\00\00\00"
213 "\05\07\01" ;; Memory section with 1 entry
214 "\00\82\80\80\80\70" ;; no max, minimum 2 with unused bits set
220 "\00asm" "\01\00\00\00"
221 "\05\07\01" ;; Memory section with 1 entry
222 "\00\82\80\80\80\40" ;; no max, minimum 2 with some unused bits set
227 ;; Signed LEB128s sign-extend
230 "\00asm" "\01\00\00\00"
231 "\06\0a\01" ;; Global section with 1 entry
232 "\7f\00" ;; i32, immutable
233 "\41\80\80\80\80\70" ;; i32.const 0 with unused bits set
240 "\00asm" "\01\00\00\00"
241 "\06\0a\01" ;; Global section with 1 entry
242 "\7f\00" ;; i32, immutable
243 "\41\ff\ff\ff\ff\0f" ;; i32.const -1 with unused bits unset
250 "\00asm" "\01\00\00\00"
251 "\06\0a\01" ;; Global section with 1 entry
252 "\7f\00" ;; i32, immutable
253 "\41\80\80\80\80\1f" ;; i32.const 0 with some unused bits set
260 "\00asm" "\01\00\00\00"
261 "\06\0a\01" ;; Global section with 1 entry
262 "\7f\00" ;; i32, immutable
263 "\41\ff\ff\ff\ff\4f" ;; i32.const -1 with some unused bits unset
271 "\00asm" "\01\00\00\00"
272 "\06\0f\01" ;; Global section with 1 entry
273 "\7e\00" ;; i64, immutable
274 "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set
281 "\00asm" "\01\00\00\00"
282 "\06\0f\01" ;; Global section with 1 entry
283 "\7e\00" ;; i64, immutable
284 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset
291 "\00asm" "\01\00\00\00"
292 "\06\0f\01" ;; Global section with 1 entry
293 "\7e\00" ;; i64, immutable
294 "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set
301 "\00asm" "\01\00\00\00"
302 "\06\0f\01" ;; Global section with 1 entry
303 "\7e\00" ;; i64, immutable
304 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset
313 "\00asm" "\01\00\00\00"
314 "\06\0f\01" ;; Global section with 1 entry
315 "\7e\00" ;; i64, immutable
316 "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set
323 "\00asm" "\01\00\00\00"
324 "\06\0f\01" ;; Global section with 1 entry
325 "\7e\00" ;; i64, immutable
326 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset
333 "\00asm" "\01\00\00\00"
334 "\06\0f\01" ;; Global section with 1 entry
335 "\7e\00" ;; i64, immutable
336 "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set
343 "\00asm" "\01\00\00\00"
344 "\06\0f\01" ;; Global section with 1 entry
345 "\7e\00" ;; i64, immutable
346 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset
353 ;; Unsigned LEB128 must not be overlong
356 "\00asm" "\01\00\00\00"
357 "\05\08\01" ;; Memory section with 1 entry
358 "\00\82\80\80\80\80\00" ;; no max, minimum 2 with one byte too many
360 "integer representation too long"
364 "\00asm" "\01\00\00\00"
365 "\01\04\01\60\00\00" ;; Type section
366 "\03\02\01\00" ;; Function section
367 "\05\03\01\00\01" ;; Memory section
368 "\0a\11\01" ;; Code section
370 "\0f\01\01" ;; local type count
372 "\41\00" ;; i32.const 0
375 "\82\80\80\80\80\00" ;; offset 2 with one byte too many
379 "integer representation too long"
383 "\00asm" "\01\00\00\00"
384 "\01\04\01\60\00\00" ;; Type section
385 "\03\02\01\00" ;; Function section
386 "\05\03\01\00\01" ;; Memory section
387 "\0a\11\01" ;; Code section
389 "\0f\01\01" ;; local type count
391 "\41\00" ;; i32.const 0
393 "\82\80\80\80\80\00" ;; alignment 2 with one byte too many
398 "integer representation too long"
402 "\00asm" "\01\00\00\00"
403 "\01\04\01\60\00\00" ;; Type section
404 "\03\02\01\00" ;; Function section
405 "\05\03\01\00\01" ;; Memory section
406 "\0a\12\01" ;; Code section
408 "\10\01\01" ;; local type count
410 "\41\00" ;; i32.const 0
411 "\41\03" ;; i32.const 3
413 "\82\80\80\80\80\00" ;; alignment 2 with one byte too many
417 "integer representation too long"
421 "\00asm" "\01\00\00\00"
422 "\01\04\01\60\00\00" ;; Type section
423 "\03\02\01\00" ;; Function section
424 "\05\03\01\00\01" ;; Memory section
425 "\0a\12\01" ;; Code section
427 "\10\01\01" ;; local type count
429 "\41\00" ;; i32.const 0
430 "\41\03" ;; i32.const 3
433 "\82\80\80\80\80\00" ;; offset 2 with one byte too many
436 "integer representation too long"
439 ;; Signed LEB128 must not be overlong
442 "\00asm" "\01\00\00\00"
443 "\06\0b\01" ;; Global section with 1 entry
444 "\7f\00" ;; i32, immutable
445 "\41\80\80\80\80\80\00" ;; i32.const 0 with one byte too many
448 "integer representation too long"
452 "\00asm" "\01\00\00\00"
453 "\06\0b\01" ;; Global section with 1 entry
454 "\7f\00" ;; i32, immutable
455 "\41\ff\ff\ff\ff\ff\7f" ;; i32.const -1 with one byte too many
458 "integer representation too long"
463 "\00asm" "\01\00\00\00"
464 "\06\10\01" ;; Global section with 1 entry
465 "\7e\00" ;; i64, immutable
466 "\42\80\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with one byte too many
469 "integer representation too long"
473 "\00asm" "\01\00\00\00"
474 "\06\10\01" ;; Global section with 1 entry
475 "\7e\00" ;; i64, immutable
476 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with one byte too many
479 "integer representation too long"
482 ;; Unsigned LEB128s zero-extend
485 "\00asm" "\01\00\00\00"
486 "\05\07\01" ;; Memory section with 1 entry
487 "\00\82\80\80\80\70" ;; no max, minimum 2 with unused bits set
493 "\00asm" "\01\00\00\00"
494 "\05\07\01" ;; Memory section with 1 entry
495 "\00\82\80\80\80\40" ;; no max, minimum 2 with some unused bits set
501 "\00asm" "\01\00\00\00"
502 "\01\04\01\60\00\00" ;; Type section
503 "\03\02\01\00" ;; Function section
504 "\05\03\01\00\01" ;; Memory section
505 "\0a\10\01" ;; Code section
507 "\0e\01\01" ;; local type count
509 "\41\00" ;; i32.const 0
512 "\82\80\80\80\10" ;; offset 2 with unused bits set
520 "\00asm" "\01\00\00\00"
521 "\01\04\01\60\00\00" ;; Type section
522 "\03\02\01\00" ;; Function section
523 "\05\03\01\00\01" ;; Memory section
524 "\0a\10\01" ;; Code section
526 "\0e\01\01" ;; local type count
528 "\41\00" ;; i32.const 0
531 "\82\80\80\80\40" ;; offset 2 with some unused bits set
539 "\00asm" "\01\00\00\00"
540 "\01\04\01\60\00\00" ;; Type section
541 "\03\02\01\00" ;; Function section
542 "\05\03\01\00\01" ;; Memory section
543 "\0a\10\01" ;; Code section
544 "\0e\01\01" ;; local type count
546 "\41\00" ;; i32.const 0
548 "\82\80\80\80\10" ;; alignment 2 with unused bits set
557 "\00asm" "\01\00\00\00"
558 "\01\04\01\60\00\00" ;; Type section
559 "\03\02\01\00" ;; Function section
560 "\05\03\01\00\01" ;; Memory section
561 "\0a\10\01" ;; Code section
563 "\0e\01\01" ;; local type count
565 "\41\00" ;; i32.const 0
567 "\82\80\80\80\40" ;; alignment 2 with some unused bits set
576 "\00asm" "\01\00\00\00"
577 "\01\04\01\60\00\00" ;; Type section
578 "\03\02\01\00" ;; Function section
579 "\05\03\01\00\01" ;; Memory section
580 "\0a\11\01" ;; Code section
582 "\0f\01\01" ;; local type count
584 "\41\00" ;; i32.const 0
585 "\41\03" ;; i32.const 3
587 "\82\80\80\80\10" ;; alignment 2 with unused bits set
595 "\00asm" "\01\00\00\00"
596 "\01\04\01\60\00\00" ;; Type section
597 "\03\02\01\00" ;; Function section
598 "\05\03\01\00\01" ;; Memory section
599 "\0a\11\01" ;; Code section
601 "\0f\01\01" ;; local type count
603 "\41\00" ;; i32.const 0
604 "\41\03" ;; i32.const 3
606 "\82\80\80\80\40" ;; alignment 2 with some unused bits set
614 "\00asm" "\01\00\00\00"
615 "\01\04\01\60\00\00" ;; Type section
616 "\03\02\01\00" ;; Function section
617 "\05\03\01\00\01" ;; Memory section
618 "\0a\11\01" ;; Code section
620 "\0f\01\01" ;; local type count
622 "\41\00" ;; i32.const 0
623 "\41\03" ;; i32.const 3
626 "\82\80\80\80\10" ;; offset 2 with unused bits set
633 "\00asm" "\01\00\00\00"
634 "\01\04\01\60\00\00" ;; Type section
635 "\03\02\01\00" ;; Function section
636 "\05\03\01\00\01" ;; Memory section
637 "\0a\11\01" ;; Code section
640 "\0f\01\01" ;; local type count
642 "\41\00" ;; i32.const 0
643 "\41\03" ;; i32.const 3
646 "\82\80\80\80\40" ;; offset 2 with some unused bits set
652 ;; Signed LEB128s sign-extend
655 "\00asm" "\01\00\00\00"
656 "\06\0a\01" ;; Global section with 1 entry
657 "\7f\00" ;; i32, immutable
658 "\41\80\80\80\80\70" ;; i32.const 0 with unused bits set
665 "\00asm" "\01\00\00\00"
666 "\06\0a\01" ;; Global section with 1 entry
667 "\7f\00" ;; i32, immutable
668 "\41\ff\ff\ff\ff\0f" ;; i32.const -1 with unused bits unset
675 "\00asm" "\01\00\00\00"
676 "\06\0a\01" ;; Global section with 1 entry
677 "\7f\00" ;; i32, immutable
678 "\41\80\80\80\80\1f" ;; i32.const 0 with some unused bits set
685 "\00asm" "\01\00\00\00"
686 "\06\0a\01" ;; Global section with 1 entry
687 "\7f\00" ;; i32, immutable
688 "\41\ff\ff\ff\ff\4f" ;; i32.const -1 with some unused bits unset
696 "\00asm" "\01\00\00\00"
697 "\06\0f\01" ;; Global section with 1 entry
698 "\7e\00" ;; i64, immutable
699 "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set
706 "\00asm" "\01\00\00\00"
707 "\06\0f\01" ;; Global section with 1 entry
708 "\7e\00" ;; i64, immutable
709 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset
716 "\00asm" "\01\00\00\00"
717 "\06\0f\01" ;; Global section with 1 entry
718 "\7e\00" ;; i64, immutable
719 "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set
726 "\00asm" "\01\00\00\00"
727 "\06\0f\01" ;; Global section with 1 entry
728 "\7e\00" ;; i64, immutable
729 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset
735 ;; memory.grow reserved byte equal to zero.
738 "\00asm" "\01\00\00\00"
739 "\01\04\01\60\00\00" ;; Type section
740 "\03\02\01\00" ;; Function section
741 "\05\03\01\00\00" ;; Memory section
742 "\0a\09\01" ;; Code section
746 "\41\00" ;; i32.const 0
748 "\01" ;; memory.grow reserved byte is not equal to zero!
755 ;; memory.grow reserved byte should not be a "long" LEB128 zero.
758 "\00asm" "\01\00\00\00"
759 "\01\04\01\60\00\00" ;; Type section
760 "\03\02\01\00" ;; Function section
761 "\05\03\01\00\00" ;; Memory section
762 "\0a\0a\01" ;; Code section
766 "\41\00" ;; i32.const 0
768 "\80\00" ;; memory.grow reserved byte
775 ;; Same as above for 3, 4, and 5-byte zero encodings.
778 "\00asm" "\01\00\00\00"
779 "\01\04\01\60\00\00" ;; Type section
780 "\03\02\01\00" ;; Function section
781 "\05\03\01\00\00" ;; Memory section
782 "\0a\0b\01" ;; Code section
786 "\41\00" ;; i32.const 0
788 "\80\80\00" ;; memory.grow reserved byte
797 "\00asm" "\01\00\00\00"
798 "\01\04\01\60\00\00" ;; Type section
799 "\03\02\01\00" ;; Function section
800 "\05\03\01\00\00" ;; Memory section
801 "\0a\0c\01" ;; Code section
805 "\41\00" ;; i32.const 0
807 "\80\80\80\00" ;; memory.grow reserved byte
816 "\00asm" "\01\00\00\00"
817 "\01\04\01\60\00\00" ;; Type section
818 "\03\02\01\00" ;; Function section
819 "\05\03\01\00\00" ;; Memory section
820 "\0a\0d\01" ;; Code section
824 "\41\00" ;; i32.const 0
826 "\80\80\80\80\00" ;; memory.grow reserved byte
833 ;; memory.size reserved byte equal to zero.
836 "\00asm" "\01\00\00\00"
837 "\01\04\01\60\00\00" ;; Type section
838 "\03\02\01\00" ;; Function section
839 "\05\03\01\00\00" ;; Memory section
840 "\0a\07\01" ;; Code section
845 "\01" ;; memory.size reserved byte is not equal to zero!
852 ;; memory.size reserved byte should not be a "long" LEB128 zero.
855 "\00asm" "\01\00\00\00"
856 "\01\04\01\60\00\00" ;; Type section
857 "\03\02\01\00" ;; Function section
858 "\05\03\01\00\00" ;; Memory section
859 "\0a\08\01" ;; Code section
864 "\80\00" ;; memory.size reserved byte
871 ;; Same as above for 3, 4, and 5-byte zero encodings.
874 "\00asm" "\01\00\00\00"
875 "\01\04\01\60\00\00" ;; Type section
876 "\03\02\01\00" ;; Function section
877 "\05\03\01\00\00" ;; Memory section
878 "\0a\09\01" ;; Code section
883 "\80\80\00" ;; memory.size reserved byte
892 "\00asm" "\01\00\00\00"
893 "\01\04\01\60\00\00" ;; Type section
894 "\03\02\01\00" ;; Function section
895 "\05\03\01\00\00" ;; Memory section
896 "\0a\0a\01" ;; Code section
901 "\80\80\80\00" ;; memory.size reserved byte
910 "\00asm" "\01\00\00\00"
911 "\01\04\01\60\00\00" ;; Type section
912 "\03\02\01\00" ;; Function section
913 "\05\03\01\00\00" ;; Memory section
914 "\0a\0b\01" ;; Code section
919 "\80\80\80\80\00" ;; memory.size reserved byte
926 ;; No more than 2^32 locals.
929 "\00asm" "\01\00\00\00"
930 "\01\04\01\60\00\00" ;; Type section
931 "\03\02\01\00" ;; Function section
932 "\0a\0c\01" ;; Code section
936 "\ff\ff\ff\ff\0f\7f" ;; 0xFFFFFFFF i32
937 "\02\7e" ;; 0x00000002 i64
943 ;; Local count can be 0.
945 "\00asm" "\01\00\00\00"
946 "\01\04\01\60\00\00" ;; Type section
947 "\03\02\01\00" ;; Function section
948 "\0a\0a\01" ;; Code section
958 ;; Function section has non-zero count, but code section is absent.
961 "\00asm" "\01\00\00\00"
962 "\01\04\01\60\00\00" ;; Type section
963 "\03\03\02\00\00" ;; Function section with 2 functions
965 "function and code section have inconsistent lengths"
968 ;; Code section has non-zero count, but function section is absent.
971 "\00asm" "\01\00\00\00"
972 "\0a\04\01\02\00\0b" ;; Code section with 1 empty function
974 "function and code section have inconsistent lengths"
977 ;; Function section count > code section count
980 "\00asm" "\01\00\00\00"
981 "\01\04\01\60\00\00" ;; Type section
982 "\03\03\02\00\00" ;; Function section with 2 functions
983 "\0a\04\01\02\00\0b" ;; Code section with 1 empty function
985 "function and code section have inconsistent lengths"
988 ;; Function section count < code section count
991 "\00asm" "\01\00\00\00"
992 "\01\04\01\60\00\00" ;; Type section
993 "\03\02\01\00" ;; Function section with 1 function
994 "\0a\07\02\02\00\0b\02\00\0b" ;; Code section with 2 empty functions
996 "function and code section have inconsistent lengths"
999 ;; Function section has zero count, and code section is absent.
1001 "\00asm" "\01\00\00\00"
1002 "\03\01\00" ;; Function section with 0 functions
1005 ;; Code section has zero count, and function section is absent.
1007 "\00asm" "\01\00\00\00"
1008 "\0a\01\00" ;; Code section with 0 functions
1011 ;; Fewer passive segments than datacount
1014 "\00asm" "\01\00\00\00"
1015 "\0c\01\03" ;; Datacount section with value "3"
1016 "\0b\05\02" ;; Data section with two entries
1017 "\01\00" ;; Passive data section
1018 "\01\00") ;; Passive data section
1019 "data count and data section have inconsistent lengths")
1021 ;; More passive segments than datacount
1024 "\00asm" "\01\00\00\00"
1025 "\0c\01\01" ;; Datacount section with value "1"
1026 "\0b\05\02" ;; Data section with two entries
1027 "\01\00" ;; Passive data section
1028 "\01\00") ;; Passive data section
1029 "data count and data section have inconsistent lengths")
1031 ;; memory.init requires a datacount section
1034 "\00asm" "\01\00\00\00"
1036 "\01\04\01\60\00\00" ;; Type section
1037 "\03\02\01\00" ;; Function section
1038 "\05\03\01\00\00" ;; Memory section
1039 "\0a\0e\01" ;; Code section
1043 "\41\00" ;; zero args
1046 "\fc\08\00\00" ;; memory.init
1049 "\0b\03\01\01\00" ;; Data section
1051 "data count section required")
1053 ;; data.drop requires a datacount section
1056 "\00asm" "\01\00\00\00"
1058 "\01\04\01\60\00\00" ;; Type section
1059 "\03\02\01\00" ;; Function section
1060 "\05\03\01\00\00" ;; Memory section
1061 "\0a\07\01" ;; Code section
1065 "\fc\09\00" ;; data.drop
1068 "\0b\03\01\01\00" ;; Data section
1070 "data count section required")
1072 ;; passive element segment containing opcode other than ref.func or ref.null
1075 "\00asm" "\01\00\00\00"
1077 "\01\04\01\60\00\00" ;; Type section
1079 "\03\02\01\00" ;; Function section
1081 "\04\04\01" ;; Table section with 1 entry
1082 "\70\00\00" ;; no max, minimum 0, funcref
1084 "\05\03\01\00\00" ;; Memory section
1086 "\09\07\01" ;; Element section with one segment
1087 "\05\70" ;; Passive, funcref
1089 "\d5\00\0b" ;; bad opcode, index 0, end
1091 "\0a\04\01" ;; Code section
1098 ;; passive element segment containing type other than funcref
1101 "\00asm" "\01\00\00\00"
1103 "\01\04\01\60\00\00" ;; Type section
1105 "\03\02\01\00" ;; Function section
1107 "\04\04\01" ;; Table section with 1 entry
1108 "\70\00\00" ;; no max, minimum 0, funcref
1110 "\05\03\01\00\00" ;; Memory section
1112 "\09\07\01" ;; Element section with one segment
1113 "\05\7f" ;; Passive, i32
1115 "\d2\00\0b" ;; ref.func, index 0, end
1117 "\0a\04\01" ;; Code section
1122 "malformed reference type")
1124 ;; passive element segment containing opcode ref.func
1126 "\00asm" "\01\00\00\00"
1128 "\01\04\01\60\00\00" ;; Type section
1130 "\03\02\01\00" ;; Function section
1132 "\04\04\01" ;; Table section with 1 entry
1133 "\70\00\00" ;; no max, minimum 0, funcref
1135 "\05\03\01\00\00" ;; Memory section
1137 "\09\07\01" ;; Element section with one segment
1138 "\05\70" ;; Passive, funcref
1140 "\d2\00\0b" ;; ref.func, index 0, end
1142 "\0a\04\01" ;; Code section
1148 ;; passive element segment containing opcode ref.null
1150 "\00asm" "\01\00\00\00"
1152 "\01\04\01\60\00\00" ;; Type section
1154 "\03\02\01\00" ;; Function section
1156 "\04\04\01" ;; Table section with 1 entry
1157 "\70\00\00" ;; no max, minimum 0, funcref
1159 "\05\03\01\00\00" ;; Memory section
1161 "\09\07\01" ;; Element section with one segment
1162 "\05\70" ;; Passive, funcref
1164 "\d0\70\0b" ;; ref.null, end
1166 "\0a\04\01" ;; Code section
1173 ;; Type count can be zero
1175 "\00asm" "\01\00\00\00"
1176 "\01\01\00" ;; type count can be zero
1179 ;; 2 type declared, 1 given
1182 "\00asm" "\01\00\00\00"
1183 "\01\07\02" ;; type section with inconsistent count (2 declared, 1 given)
1184 "\60\00\00" ;; 1st type
1185 ;; "\60\00\00" ;; 2nd type (missed)
1187 "unexpected end of section or function"
1190 ;; 1 type declared, 2 given
1193 "\00asm" "\01\00\00\00"
1194 "\01\07\01" ;; type section with inconsistent count (1 declared, 2 given)
1195 "\60\00\00" ;; 1st type
1196 "\60\00\00" ;; 2nd type (redundant)
1198 "section size mismatch"
1201 ;; Import count can be zero
1203 "\00asm" "\01\00\00\00"
1204 "\01\05\01" ;; type section
1205 "\60\01\7f\00" ;; type 0
1206 "\02\01\00" ;; import count can be zero
1209 ;; 2 import declared, 1 given
1212 "\00asm" "\01\00\00\00"
1213 "\01\05\01" ;; type section
1214 "\60\01\7f\00" ;; type 0
1215 "\02\16\02" ;; import section with inconsistent count (2 declared, 1 given)
1217 "\08" ;; string length
1218 "\73\70\65\63\74\65\73\74" ;; spectest
1219 "\09" ;; string length
1220 "\70\72\69\6e\74\5f\69\33\32" ;; print_i32
1221 "\00\00" ;; import kind, import signature index
1225 "unexpected end of section or function"
1228 ;; 1 import declared, 2 given
1231 "\00asm" "\01\00\00\00"
1232 "\01\09\02" ;; type section
1233 "\60\01\7f\00" ;; type 0
1234 "\60\01\7d\00" ;; type 1
1235 "\02\2b\01" ;; import section with inconsistent count (1 declared, 2 given)
1237 "\08" ;; string length
1238 "\73\70\65\63\74\65\73\74" ;; spectest
1239 "\09" ;; string length
1240 "\70\72\69\6e\74\5f\69\33\32" ;; print_i32
1241 "\00\00" ;; import kind, import signature index
1244 "\08" ;; string length
1245 "\73\70\65\63\74\65\73\74" ;; spectest
1246 "\09" ;; string length
1247 "\70\72\69\6e\74\5f\66\33\32" ;; print_f32
1248 "\00\01" ;; import kind, import signature index
1250 "section size mismatch"
1253 ;; Table count can be zero
1255 "\00asm" "\01\00\00\00"
1256 "\04\01\00" ;; table count can be zero
1259 ;; 1 table declared, 0 given
1262 "\00asm" "\01\00\00\00"
1263 "\04\01\01" ;; table section with inconsistent count (1 declared, 0 given)
1264 ;; "\70\01\00\00" ;; table entity
1266 "unexpected end of section or function"
1269 ;; Memory count can be zero
1271 "\00asm" "\01\00\00\00"
1272 "\05\01\00" ;; memory count can be zero
1275 ;; 1 memory declared, 0 given
1278 "\00asm" "\01\00\00\00"
1279 "\05\01\01" ;; memory section with inconsistent count (1 declared, 0 given)
1280 ;; "\00\00" ;; memory 0 (missed)
1282 "unexpected end of section or function"
1285 ;; Global count can be zero
1287 "\00asm" "\01\00\00\00"
1288 "\06\01\00" ;; global count can be zero
1291 ;; 2 global declared, 1 given
1294 "\00asm" "\01\00\00\00"
1295 "\06\06\02" ;; global section with inconsistent count (2 declared, 1 given)
1296 "\7f\00\41\00\0b" ;; global 0
1297 ;; "\7f\00\41\00\0b" ;; global 1 (missed)
1299 "unexpected end of section or function"
1302 ;; 1 global declared, 2 given
1305 "\00asm" "\01\00\00\00"
1306 "\06\0b\01" ;; global section with inconsistent count (1 declared, 2 given)
1307 "\7f\00\41\00\0b" ;; global 0
1308 "\7f\00\41\00\0b" ;; global 1 (redundant)
1310 "section size mismatch"
1313 ;; Export count can be 0
1315 "\00asm" "\01\00\00\00"
1316 "\01\04\01" ;; type section
1317 "\60\00\00" ;; type 0
1318 "\03\03\02\00\00" ;; func section
1319 "\07\01\00" ;; export count can be zero
1320 "\0a\07\02" ;; code section
1321 "\02\00\0b" ;; function body 0
1322 "\02\00\0b" ;; function body 1
1325 ;; 2 export declared, 1 given
1328 "\00asm" "\01\00\00\00"
1329 "\01\04\01" ;; type section
1330 "\60\00\00" ;; type 0
1331 "\03\03\02\00\00" ;; func section
1332 "\07\06\02" ;; export section with inconsistent count (2 declared, 1 given)
1334 "\66\31" ;; export name
1335 "\00\00" ;; export kind, export func index
1336 ;; "\02" ;; export 1 (missed)
1337 ;; "\66\32" ;; export name
1338 ;; "\00\01" ;; export kind, export func index
1339 "\0a\07\02" ;; code section
1340 "\02\00\0b" ;; function body 0
1341 "\02\00\0b" ;; function body 1
1343 "unexpected end of section or function"
1346 ;; 1 export declared, 2 given
1349 "\00asm" "\01\00\00\00"
1350 "\01\04\01" ;; type section
1351 "\60\00\00" ;; type 0
1352 "\03\03\02\00\00" ;; func section
1353 "\07\0b\01" ;; export section with inconsistent count (1 declared, 2 given)
1355 "\66\31" ;; export name
1356 "\00\00" ;; export kind, export func index
1357 "\02" ;; export 1 (redundant)
1358 "\66\32" ;; export name
1359 "\00\01" ;; export kind, export func index
1360 "\0a\07\02" ;; code section
1361 "\02\00\0b" ;; function body 0
1362 "\02\00\0b" ;; function body 1
1364 "section size mismatch"
1367 ;; elem segment count can be zero
1369 "\00asm" "\01\00\00\00"
1370 "\01\04\01" ;; type section
1371 "\60\00\00" ;; type 0
1372 "\03\02\01\00" ;; func section
1373 "\04\04\01" ;; table section
1374 "\70\00\01" ;; table 0
1375 "\09\01\00" ;; elem segment count can be zero
1376 "\0a\04\01" ;; code section
1377 "\02\00\0b" ;; function body
1380 ;; 2 elem segment declared, 1 given
1383 "\00asm" "\01\00\00\00"
1384 "\01\04\01" ;; type section
1385 "\60\00\00" ;; type 0
1386 "\03\02\01\00" ;; func section
1387 "\04\04\01" ;; table section
1388 "\70\00\01" ;; table 0
1389 "\09\07\02" ;; elem with inconsistent segment count (2 declared, 1 given)
1390 "\00\41\00\0b\01\00" ;; elem 0
1391 ;; "\00\41\00\0b\01\00" ;; elem 1 (missed)
1392 "\0a\04\01" ;; code section
1393 "\02\00\0b" ;; function body
1395 "malformed elements segment kind"
1398 ;; 1 elem segment declared, 2 given
1401 "\00asm" "\01\00\00\00"
1402 "\01\04\01" ;; type section
1403 "\60\00\00" ;; type 0
1404 "\03\02\01\00" ;; func section
1405 "\04\04\01" ;; table section
1406 "\70\00\01" ;; table 0
1407 "\09\0d\01" ;; elem with inconsistent segment count (1 declared, 2 given)
1408 "\00\41\00\0b\01\00" ;; elem 0
1409 "\00\41\00\0b\01\00" ;; elem 1 (redundant)
1410 "\0a\04\01" ;; code section
1411 "\02\00\0b" ;; function body
1413 "section size mismatch"
1416 ;; data segment count can be zero
1418 "\00asm" "\01\00\00\00"
1419 "\05\03\01" ;; memory section
1420 "\00\01" ;; memory 0
1421 "\0b\01\00" ;; data segment count can be zero
1424 ;; 2 data segment declared, 1 given
1427 "\00asm" "\01\00\00\00"
1428 "\05\03\01" ;; memory section
1429 "\00\01" ;; memory 0
1430 "\0b\07\02" ;; data with inconsistent segment count (2 declared, 1 given)
1431 "\00\41\00\0b\01\61" ;; data 0
1432 ;; "\00\41\01\0b\01\62" ;; data 1 (missed)
1434 "unexpected end of section or function"
1437 ;; 1 data segment declared, 2 given
1440 "\00asm" "\01\00\00\00"
1441 "\05\03\01" ;; memory section
1442 "\00\01" ;; memory 0
1443 "\0b\0d\01" ;; data with inconsistent segment count (1 declared, 2 given)
1444 "\00\41\00\0b\01\61" ;; data 0
1445 "\00\41\01\0b\01\62" ;; data 1 (redundant)
1447 "section size mismatch"
1450 ;; data segment has 7 bytes declared, but 6 bytes given
1453 "\00asm" "\01\00\00\00"
1454 "\05\03\01" ;; memory section
1455 "\00\01" ;; memory 0
1456 "\0b\0c\01" ;; data section
1457 "\00\41\03\0b" ;; data segment 0
1458 "\07" ;; data segment size with inconsistent lengths (7 declared, 6 given)
1459 "\61\62\63\64\65\66" ;; 6 bytes given
1461 "unexpected end of section or function"
1464 ;; data segment has 5 bytes declared, but 6 bytes given
1467 "\00asm" "\01\00\00\00"
1468 "\05\03\01" ;; memory section
1469 "\00\01" ;; memory 0
1470 "\0b\0c\01" ;; data section
1471 "\00\41\00\0b" ;; data segment 0
1472 "\05" ;; data segment size with inconsistent lengths (5 declared, 6 given)
1473 "\61\62\63\64\65\66" ;; 6 bytes given
1475 "section size mismatch"
1478 ;; br_table target count can be zero
1480 "\00asm" "\01\00\00\00"
1481 "\01\04\01" ;; type section
1482 "\60\00\00" ;; type 0
1483 "\03\02\01\00" ;; func section
1484 "\0a\11\01" ;; code section
1487 "\41\01" ;; condition of if 0
1489 "\41\01" ;; index of br_table element
1490 "\0e\00" ;; br_table target count can be zero
1491 "\02" ;; break depth for default
1495 ;; 1 br_table target declared, 2 given
1498 "\00asm" "\01\00\00\00"
1499 "\01\04\01" ;; type section
1500 "\60\00\00" ;; type 0
1501 "\03\02\01\00" ;; func section
1502 "\0a\12\01" ;; code section
1505 "\41\01" ;; condition of if 0
1507 "\41\01" ;; index of br_table element
1508 "\0e\01" ;; br_table with inconsistent target count (1 declared, 2 given)
1509 "\00" ;; break depth 0
1510 "\01" ;; break depth 1
1511 "\02" ;; break depth for default
1514 "unexpected end of section or function"
1519 "\00asm" "\01\00\00\00"
1520 "\01\04\01\60\00\00" ;; Type section
1521 "\03\02\01\00" ;; Function section
1522 "\08\01\00" ;; Start section: function 0
1524 "\0a\04\01" ;; Code section
1530 ;; Multiple start sections
1533 "\00asm" "\01\00\00\00"
1534 "\01\04\01\60\00\00" ;; Type section
1535 "\03\02\01\00" ;; Function section
1536 "\08\01\00" ;; Start section: function 0
1537 "\08\01\00" ;; Start section: function 0
1539 "\0a\04\01" ;; Code section
1544 "junk after last section"