wa-lang.org/wazero@v1.0.2/internal/integration_test/spectest/v2/testdata/binary.wast (about) 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") 5 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") 19 20 ;; 8-byte endian-reversed. 21 (assert_malformed (module binary "\00\00\00\01msa\00") "magic header not detected") 22 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") 26 27 ;; Upper-cased. 28 (assert_malformed (module binary "\00ASM\01\00\00\00") "magic header not detected") 29 30 ;; EBCDIC-encoded magic. 31 (assert_malformed (module binary "\00\81\a2\94\01\00\00\00") "magic header not detected") 32 33 ;; Leading UTF-8 BOM. 34 (assert_malformed (module binary "\ef\bb\bf\00asm\01\00\00\00") "magic header not detected") 35 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") 46 47 ;; Invalid section id. 48 (assert_malformed (module binary "\00asm" "\01\00\00\00" "\0d\00") "malformed section id") 49 (assert_malformed (module binary "\00asm" "\01\00\00\00" "\7f\00") "malformed section id") 50 (assert_malformed (module binary "\00asm" "\01\00\00\00" "\80\00\01\00") "malformed section id") 51 (assert_malformed (module binary "\00asm" "\01\00\00\00" "\81\00\01\00") "malformed section id") 52 (assert_malformed (module binary "\00asm" "\01\00\00\00" "\ff\00\01\00") "malformed section id") 53 54 ;; Unsigned LEB128 can have non-minimal length 55 (module binary 56 "\00asm" "\01\00\00\00" 57 "\05\04\01" ;; Memory section with 1 entry 58 "\00\82\00" ;; no max, minimum 2 59 ) 60 (module binary 61 "\00asm" "\01\00\00\00" 62 "\05\07\01" ;; Memory section with 1 entry 63 "\00\82\80\80\80\00" ;; no max, minimum 2 64 ) 65 66 ;; Signed LEB128 can have non-minimal length 67 (module binary 68 "\00asm" "\01\00\00\00" 69 "\06\07\01" ;; Global section with 1 entry 70 "\7f\00" ;; i32, immutable 71 "\41\80\00" ;; i32.const 0 72 "\0b" ;; end 73 ) 74 (module binary 75 "\00asm" "\01\00\00\00" 76 "\06\07\01" ;; Global section with 1 entry 77 "\7f\00" ;; i32, immutable 78 "\41\ff\7f" ;; i32.const -1 79 "\0b" ;; end 80 ) 81 (module binary 82 "\00asm" "\01\00\00\00" 83 "\06\0a\01" ;; Global section with 1 entry 84 "\7f\00" ;; i32, immutable 85 "\41\80\80\80\80\00" ;; i32.const 0 86 "\0b" ;; end 87 ) 88 (module binary 89 "\00asm" "\01\00\00\00" 90 "\06\0a\01" ;; Global section with 1 entry 91 "\7f\00" ;; i32, immutable 92 "\41\ff\ff\ff\ff\7f" ;; i32.const -1 93 "\0b" ;; end 94 ) 95 96 (module binary 97 "\00asm" "\01\00\00\00" 98 "\06\07\01" ;; Global section with 1 entry 99 "\7e\00" ;; i64, immutable 100 "\42\80\00" ;; i64.const 0 with unused bits set 101 "\0b" ;; end 102 ) 103 (module binary 104 "\00asm" "\01\00\00\00" 105 "\06\07\01" ;; Global section with 1 entry 106 "\7e\00" ;; i64, immutable 107 "\42\ff\7f" ;; i64.const -1 with unused bits unset 108 "\0b" ;; end 109 ) 110 (module binary 111 "\00asm" "\01\00\00\00" 112 "\06\0f\01" ;; Global section with 1 entry 113 "\7e\00" ;; i64, immutable 114 "\42\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with unused bits set 115 "\0b" ;; end 116 ) 117 (module binary 118 "\00asm" "\01\00\00\00" 119 "\06\0f\01" ;; Global section with 1 entry 120 "\7e\00" ;; i64, immutable 121 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with unused bits unset 122 "\0b" ;; end 123 ) 124 125 (module binary 126 "\00asm" "\01\00\00\00" 127 "\05\03\01" ;; Memory section with 1 entry 128 "\00\00" ;; no max, minimum 0 129 "\0b\06\01" ;; Data section with 1 entry 130 "\00" ;; Memory index 0 131 "\41\00\0b\00" ;; (i32.const 0) with contents "" 132 ) 133 134 (module binary 135 "\00asm" "\01\00\00\00" 136 "\04\04\01" ;; Table section with 1 entry 137 "\70\00\00" ;; no max, minimum 0, funcref 138 "\09\06\01" ;; Element section with 1 entry 139 "\00" ;; Table index 0 140 "\41\00\0b\00" ;; (i32.const 0) with no elements 141 ) 142 143 ;; Data segment tags and memory index can have non-minimal length 144 (module binary 145 "\00asm" "\01\00\00\00" 146 "\05\03\01" ;; Memory section with 1 entry 147 "\00\00" ;; no max, minimum 0 148 "\0b\07\01" ;; Data section with 1 entry 149 "\80\00" ;; Active segment, encoded with 2 bytes 150 "\41\00\0b\00" ;; (i32.const 0) with contents "" 151 ) 152 (module binary 153 "\00asm" "\01\00\00\00" 154 "\05\03\01" ;; Memory section with 1 entry 155 "\00\00" ;; no max, minimum 0 156 "\0b\08\01" ;; Data section with 1 entry 157 "\82\00" ;; Active segment, encoded with 2 bytes 158 "\00" ;; explicit memory index 159 "\41\00\0b\00" ;; (i32.const 0) with contents "" 160 ) 161 (module binary 162 "\00asm" "\01\00\00\00" 163 "\05\03\01" ;; Memory section with 1 entry 164 "\00\00" ;; no max, minimum 0 165 "\0b\09\01" ;; Data section with 1 entry 166 "\82\00" ;; Active segment, encoded with 2 bytes 167 "\80\00" ;; explicit memory index, encoded with 2 bytes 168 "\41\00\0b\00" ;; (i32.const 0) with contents "" 169 ) 170 171 ;; Element segment tags and table index can have non-minimal length 172 (module binary 173 "\00asm" "\01\00\00\00" 174 "\04\04\01" ;; Table section with 1 entry 175 "\70\00\00" ;; no max, minimum 0, funcref 176 "\09\07\01" ;; Element section with 1 entry 177 "\80\00" ;; Active segment 178 "\41\00\0b\00" ;; (i32.const 0) with no elements 179 ) 180 (module binary 181 "\00asm" "\01\00\00\00" 182 "\04\04\01" ;; Table section with 1 entry 183 "\70\00\00" ;; no max, minimum 0, funcref 184 "\09\09\01" ;; Element section with 1 entry 185 "\02" ;; Active segment 186 "\80\00" ;; explicit table index, encoded with 2 bytes 187 "\41\00\0b\00\00" ;; (i32.const 0) with no elements 188 ) 189 (module binary 190 "\00asm" "\01\00\00\00" 191 "\04\04\01" ;; Table section with 1 entry 192 "\70\00\00" ;; no max, minimum 0, funcref 193 "\09\09\01" ;; Element section with 1 entry 194 "\82\00" ;; Active segment, encoded with 2 bytes 195 "\00" ;; explicit table index 196 "\41\00\0b\00\00" ;; (i32.const 0) with no elements 197 ) 198 (module binary 199 "\00asm" "\01\00\00\00" 200 "\04\04\01" ;; Table section with 1 entry 201 "\70\00\00" ;; no max, minimum 0, funcref 202 "\09\0a\01" ;; Element section with 1 entry 203 "\82\00" ;; Active segment, encoded with 2 bytes 204 "\80\00" ;; explicit table index, encoded with 2 bytes 205 "\41\00\0b\00\00" ;; (i32.const 0) with no elements 206 ) 207 208 ;; Type section with signed LEB128 encoded type 209 (assert_malformed 210 (module binary 211 "\00asm" "\01\00\00\00" 212 "\01" ;; Type section id 213 "\05" ;; Type section length 214 "\01" ;; Types vector length 215 "\e0\7f" ;; Malformed functype, -0x20 in signed LEB128 encoding 216 "\00\00" 217 ) 218 "integer representation too long" 219 ) 220 221 ;; Unsigned LEB128 must not be overlong 222 (assert_malformed 223 (module binary 224 "\00asm" "\01\00\00\00" 225 "\05\08\01" ;; Memory section with 1 entry 226 "\00\82\80\80\80\80\00" ;; no max, minimum 2 with one byte too many 227 ) 228 "integer representation too long" 229 ) 230 231 ;; Signed LEB128 must not be overlong 232 (assert_malformed 233 (module binary 234 "\00asm" "\01\00\00\00" 235 "\06\0b\01" ;; Global section with 1 entry 236 "\7f\00" ;; i32, immutable 237 "\41\80\80\80\80\80\00" ;; i32.const 0 with one byte too many 238 "\0b" ;; end 239 ) 240 "integer representation too long" 241 ) 242 (assert_malformed 243 (module binary 244 "\00asm" "\01\00\00\00" 245 "\06\0b\01" ;; Global section with 1 entry 246 "\7f\00" ;; i32, immutable 247 "\41\ff\ff\ff\ff\ff\7f" ;; i32.const -1 with one byte too many 248 "\0b" ;; end 249 ) 250 "integer representation too long" 251 ) 252 253 (assert_malformed 254 (module binary 255 "\00asm" "\01\00\00\00" 256 "\06\10\01" ;; Global section with 1 entry 257 "\7e\00" ;; i64, immutable 258 "\42\80\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with one byte too many 259 "\0b" ;; end 260 ) 261 "integer representation too long" 262 ) 263 (assert_malformed 264 (module binary 265 "\00asm" "\01\00\00\00" 266 "\06\10\01" ;; Global section with 1 entry 267 "\7e\00" ;; i64, immutable 268 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with one byte too many 269 "\0b" ;; end 270 ) 271 "integer representation too long" 272 ) 273 274 ;; Unsigned LEB128s zero-extend 275 (assert_malformed 276 (module binary 277 "\00asm" "\01\00\00\00" 278 "\05\07\01" ;; Memory section with 1 entry 279 "\00\82\80\80\80\70" ;; no max, minimum 2 with unused bits set 280 ) 281 "integer too large" 282 ) 283 (assert_malformed 284 (module binary 285 "\00asm" "\01\00\00\00" 286 "\05\07\01" ;; Memory section with 1 entry 287 "\00\82\80\80\80\40" ;; no max, minimum 2 with some unused bits set 288 ) 289 "integer too large" 290 ) 291 292 ;; Signed LEB128s sign-extend 293 (assert_malformed 294 (module binary 295 "\00asm" "\01\00\00\00" 296 "\06\0a\01" ;; Global section with 1 entry 297 "\7f\00" ;; i32, immutable 298 "\41\80\80\80\80\70" ;; i32.const 0 with unused bits set 299 "\0b" ;; end 300 ) 301 "integer too large" 302 ) 303 (assert_malformed 304 (module binary 305 "\00asm" "\01\00\00\00" 306 "\06\0a\01" ;; Global section with 1 entry 307 "\7f\00" ;; i32, immutable 308 "\41\ff\ff\ff\ff\0f" ;; i32.const -1 with unused bits unset 309 "\0b" ;; end 310 ) 311 "integer too large" 312 ) 313 (assert_malformed 314 (module binary 315 "\00asm" "\01\00\00\00" 316 "\06\0a\01" ;; Global section with 1 entry 317 "\7f\00" ;; i32, immutable 318 "\41\80\80\80\80\1f" ;; i32.const 0 with some unused bits set 319 "\0b" ;; end 320 ) 321 "integer too large" 322 ) 323 (assert_malformed 324 (module binary 325 "\00asm" "\01\00\00\00" 326 "\06\0a\01" ;; Global section with 1 entry 327 "\7f\00" ;; i32, immutable 328 "\41\ff\ff\ff\ff\4f" ;; i32.const -1 with some unused bits unset 329 "\0b" ;; end 330 ) 331 "integer too large" 332 ) 333 334 (assert_malformed 335 (module binary 336 "\00asm" "\01\00\00\00" 337 "\06\0f\01" ;; Global section with 1 entry 338 "\7e\00" ;; i64, immutable 339 "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set 340 "\0b" ;; end 341 ) 342 "integer too large" 343 ) 344 (assert_malformed 345 (module binary 346 "\00asm" "\01\00\00\00" 347 "\06\0f\01" ;; Global section with 1 entry 348 "\7e\00" ;; i64, immutable 349 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset 350 "\0b" ;; end 351 ) 352 "integer too large" 353 ) 354 (assert_malformed 355 (module binary 356 "\00asm" "\01\00\00\00" 357 "\06\0f\01" ;; Global section with 1 entry 358 "\7e\00" ;; i64, immutable 359 "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set 360 "\0b" ;; end 361 ) 362 "integer too large" 363 ) 364 (assert_malformed 365 (module binary 366 "\00asm" "\01\00\00\00" 367 "\06\0f\01" ;; Global section with 1 entry 368 "\7e\00" ;; i64, immutable 369 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset 370 "\0b" ;; end 371 ) 372 "integer too large" 373 ) 374 375 (assert_malformed 376 (module binary 377 "\00asm" "\01\00\00\00" 378 "\06\0f\01" ;; Global section with 1 entry 379 "\7e\00" ;; i64, immutable 380 "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set 381 "\0b" ;; end 382 ) 383 "integer too large" 384 ) 385 (assert_malformed 386 (module binary 387 "\00asm" "\01\00\00\00" 388 "\06\0f\01" ;; Global section with 1 entry 389 "\7e\00" ;; i64, immutable 390 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset 391 "\0b" ;; end 392 ) 393 "integer too large" 394 ) 395 (assert_malformed 396 (module binary 397 "\00asm" "\01\00\00\00" 398 "\06\0f\01" ;; Global section with 1 entry 399 "\7e\00" ;; i64, immutable 400 "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set 401 "\0b" ;; end 402 ) 403 "integer too large" 404 ) 405 (assert_malformed 406 (module binary 407 "\00asm" "\01\00\00\00" 408 "\06\0f\01" ;; Global section with 1 entry 409 "\7e\00" ;; i64, immutable 410 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset 411 "\0b" ;; end 412 ) 413 "integer too large" 414 ) 415 416 ;; Function with missing end marker (between two functions) 417 (assert_malformed 418 (module binary 419 "\00asm" "\01\00\00\00" 420 "\01\04\01\60\00\00" ;; Type section: 1 type 421 "\03\03\02\00\00" ;; Function section: 2 functions 422 "\0a\0c\02" ;; Code section: 2 functions 423 ;; function 0 424 "\04\00" ;; Function size and local type count 425 "\41\01" ;; i32.const 1 426 "\1a" ;; drop 427 ;; Missing end marker here 428 ;; function 1 429 "\05\00" ;; Function size and local type count 430 "\41\01" ;; i32.const 1 431 "\1a" ;; drop 432 "\0b" ;; end 433 ) 434 "END opcode expected" 435 ) 436 437 ;; Function with missing end marker (at EOF) 438 (assert_malformed 439 (module binary 440 "\00asm" "\01\00\00\00" 441 "\01\04\01\60\00\00" ;; Type section: 1 type 442 "\03\02\01\00" ;; Function section: 1 function 443 "\0a\06\01" ;; Code section: 1 function 444 ;; function 0 445 "\04\00" ;; Function size and local type count 446 "\41\01" ;; i32.const 1 447 "\1a" ;; drop 448 ;; Missing end marker here 449 ) 450 "unexpected end of section or function" 451 ) 452 453 ;; Function with missing end marker (at end of code sections) 454 (assert_malformed 455 (module binary 456 "\00asm" "\01\00\00\00" 457 "\01\04\01\60\00\00" ;; Type section: 1 type 458 "\03\02\01\00" ;; Function section: 1 function 459 "\0a\06\01" ;; Code section: 1 function 460 ;; function 0 461 "\04\00" ;; Function size and local type count 462 "\41\01" ;; i32.const 1 463 "\1a" ;; drop 464 ;; Missing end marker here 465 "\0b\03\01\01\00" ;; Data section 466 ) 467 ;; The spec interpreter consumes the `\0b` (data section start) as an 468 ;; END instruction (also happens to be `\0b`) and reports the code section as 469 ;; being larger than declared. 470 "section size mismatch" 471 ) 472 473 ;; Unsigned LEB128 must not be overlong 474 (assert_malformed 475 (module binary 476 "\00asm" "\01\00\00\00" 477 "\05\08\01" ;; Memory section with 1 entry 478 "\00\82\80\80\80\80\00" ;; no max, minimum 2 with one byte too many 479 ) 480 "integer representation too long" 481 ) 482 (assert_malformed 483 (module binary 484 "\00asm" "\01\00\00\00" 485 "\01\04\01\60\00\00" ;; Type section 486 "\03\02\01\00" ;; Function section 487 "\05\03\01\00\01" ;; Memory section 488 "\0a\11\01" ;; Code section 489 ;; function 0 490 "\0f\01\01" ;; local type count 491 "\7f" ;; i32 492 "\41\00" ;; i32.const 0 493 "\28" ;; i32.load 494 "\02" ;; alignment 2 495 "\82\80\80\80\80\00" ;; offset 2 with one byte too many 496 "\1a" ;; drop 497 "\0b" ;; end 498 ) 499 "integer representation too long" 500 ) 501 (assert_malformed 502 (module binary 503 "\00asm" "\01\00\00\00" 504 "\01\04\01\60\00\00" ;; Type section 505 "\03\02\01\00" ;; Function section 506 "\05\03\01\00\01" ;; Memory section 507 "\0a\11\01" ;; Code section 508 ;; function 0 509 "\0f\01\01" ;; local type count 510 "\7f" ;; i32 511 "\41\00" ;; i32.const 0 512 "\28" ;; i32.load 513 "\82\80\80\80\80\00" ;; alignment 2 with one byte too many 514 "\00" ;; offset 0 515 "\1a" ;; drop 516 "\0b" ;; end 517 ) 518 "integer representation too long" 519 ) 520 (assert_malformed 521 (module binary 522 "\00asm" "\01\00\00\00" 523 "\01\04\01\60\00\00" ;; Type section 524 "\03\02\01\00" ;; Function section 525 "\05\03\01\00\01" ;; Memory section 526 "\0a\12\01" ;; Code section 527 ;; function 0 528 "\10\01\01" ;; local type count 529 "\7f" ;; i32 530 "\41\00" ;; i32.const 0 531 "\41\03" ;; i32.const 3 532 "\36" ;; i32.store 533 "\82\80\80\80\80\00" ;; alignment 2 with one byte too many 534 "\03" ;; offset 3 535 "\0b" ;; end 536 ) 537 "integer representation too long" 538 ) 539 (assert_malformed 540 (module binary 541 "\00asm" "\01\00\00\00" 542 "\01\04\01\60\00\00" ;; Type section 543 "\03\02\01\00" ;; Function section 544 "\05\03\01\00\01" ;; Memory section 545 "\0a\12\01" ;; Code section 546 ;; function 0 547 "\10\01\01" ;; local type count 548 "\7f" ;; i32 549 "\41\00" ;; i32.const 0 550 "\41\03" ;; i32.const 3 551 "\36" ;; i32.store 552 "\02" ;; alignment 2 553 "\82\80\80\80\80\00" ;; offset 2 with one byte too many 554 "\0b" ;; end 555 ) 556 "integer representation too long" 557 ) 558 559 ;; Signed LEB128 must not be overlong 560 (assert_malformed 561 (module binary 562 "\00asm" "\01\00\00\00" 563 "\06\0b\01" ;; Global section with 1 entry 564 "\7f\00" ;; i32, immutable 565 "\41\80\80\80\80\80\00" ;; i32.const 0 with one byte too many 566 "\0b" ;; end 567 ) 568 "integer representation too long" 569 ) 570 (assert_malformed 571 (module binary 572 "\00asm" "\01\00\00\00" 573 "\06\0b\01" ;; Global section with 1 entry 574 "\7f\00" ;; i32, immutable 575 "\41\ff\ff\ff\ff\ff\7f" ;; i32.const -1 with one byte too many 576 "\0b" ;; end 577 ) 578 "integer representation too long" 579 ) 580 581 (assert_malformed 582 (module binary 583 "\00asm" "\01\00\00\00" 584 "\06\10\01" ;; Global section with 1 entry 585 "\7e\00" ;; i64, immutable 586 "\42\80\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with one byte too many 587 "\0b" ;; end 588 ) 589 "integer representation too long" 590 ) 591 (assert_malformed 592 (module binary 593 "\00asm" "\01\00\00\00" 594 "\06\10\01" ;; Global section with 1 entry 595 "\7e\00" ;; i64, immutable 596 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with one byte too many 597 "\0b" ;; end 598 ) 599 "integer representation too long" 600 ) 601 602 ;; Unsigned LEB128s zero-extend 603 (assert_malformed 604 (module binary 605 "\00asm" "\01\00\00\00" 606 "\05\07\01" ;; Memory section with 1 entry 607 "\00\82\80\80\80\70" ;; no max, minimum 2 with unused bits set 608 ) 609 "integer too large" 610 ) 611 (assert_malformed 612 (module binary 613 "\00asm" "\01\00\00\00" 614 "\05\07\01" ;; Memory section with 1 entry 615 "\00\82\80\80\80\40" ;; no max, minimum 2 with some unused bits set 616 ) 617 "integer too large" 618 ) 619 (assert_malformed 620 (module binary 621 "\00asm" "\01\00\00\00" 622 "\01\04\01\60\00\00" ;; Type section 623 "\03\02\01\00" ;; Function section 624 "\05\03\01\00\01" ;; Memory section 625 "\0a\10\01" ;; Code section 626 ;; function 0 627 "\0e\01\01" ;; local type count 628 "\7f" ;; i32 629 "\41\00" ;; i32.const 0 630 "\28" ;; i32.load 631 "\02" ;; alignment 2 632 "\82\80\80\80\10" ;; offset 2 with unused bits set 633 "\1a" ;; drop 634 "\0b" ;; end 635 ) 636 "integer too large" 637 ) 638 (assert_malformed 639 (module binary 640 "\00asm" "\01\00\00\00" 641 "\01\04\01\60\00\00" ;; Type section 642 "\03\02\01\00" ;; Function section 643 "\05\03\01\00\01" ;; Memory section 644 "\0a\10\01" ;; Code section 645 ;; function 0 646 "\0e\01\01" ;; local type count 647 "\7f" ;; i32 648 "\41\00" ;; i32.const 0 649 "\28" ;; i32.load 650 "\02" ;; alignment 2 651 "\82\80\80\80\40" ;; offset 2 with some unused bits set 652 "\1a" ;; drop 653 "\0b" ;; end 654 ) 655 "integer too large" 656 ) 657 (assert_malformed 658 (module binary 659 "\00asm" "\01\00\00\00" 660 "\01\04\01\60\00\00" ;; Type section 661 "\03\02\01\00" ;; Function section 662 "\05\03\01\00\01" ;; Memory section 663 "\0a\10\01" ;; Code section 664 "\0e\01\01" ;; local type count 665 "\7f" ;; i32 666 "\41\00" ;; i32.const 0 667 "\28" ;; i32.load 668 "\82\80\80\80\10" ;; alignment 2 with unused bits set 669 "\00" ;; offset 0 670 "\1a" ;; drop 671 "\0b" ;; end 672 ) 673 "integer too large" 674 ) 675 (assert_malformed 676 (module binary 677 "\00asm" "\01\00\00\00" 678 "\01\04\01\60\00\00" ;; Type section 679 "\03\02\01\00" ;; Function section 680 "\05\03\01\00\01" ;; Memory section 681 "\0a\10\01" ;; Code section 682 ;; function 0 683 "\0e\01\01" ;; local type count 684 "\7f" ;; i32 685 "\41\00" ;; i32.const 0 686 "\28" ;; i32.load 687 "\82\80\80\80\40" ;; alignment 2 with some unused bits set 688 "\00" ;; offset 0 689 "\1a" ;; drop 690 "\0b" ;; end 691 ) 692 "integer too large" 693 ) 694 (assert_malformed 695 (module binary 696 "\00asm" "\01\00\00\00" 697 "\01\04\01\60\00\00" ;; Type section 698 "\03\02\01\00" ;; Function section 699 "\05\03\01\00\01" ;; Memory section 700 "\0a\11\01" ;; Code section 701 ;; function 0 702 "\0f\01\01" ;; local type count 703 "\7f" ;; i32 704 "\41\00" ;; i32.const 0 705 "\41\03" ;; i32.const 3 706 "\36" ;; i32.store 707 "\82\80\80\80\10" ;; alignment 2 with unused bits set 708 "\03" ;; offset 3 709 "\0b" ;; end 710 ) 711 "integer too large" 712 ) 713 (assert_malformed 714 (module binary 715 "\00asm" "\01\00\00\00" 716 "\01\04\01\60\00\00" ;; Type section 717 "\03\02\01\00" ;; Function section 718 "\05\03\01\00\01" ;; Memory section 719 "\0a\11\01" ;; Code section 720 ;; function 0 721 "\0f\01\01" ;; local type count 722 "\7f" ;; i32 723 "\41\00" ;; i32.const 0 724 "\41\03" ;; i32.const 3 725 "\36" ;; i32.store 726 "\82\80\80\80\40" ;; alignment 2 with some unused bits set 727 "\03" ;; offset 3 728 "\0b" ;; end 729 ) 730 "integer too large" 731 ) 732 (assert_malformed 733 (module binary 734 "\00asm" "\01\00\00\00" 735 "\01\04\01\60\00\00" ;; Type section 736 "\03\02\01\00" ;; Function section 737 "\05\03\01\00\01" ;; Memory section 738 "\0a\11\01" ;; Code section 739 ;; function 0 740 "\0f\01\01" ;; local type count 741 "\7f" ;; i32 742 "\41\00" ;; i32.const 0 743 "\41\03" ;; i32.const 3 744 "\36" ;; i32.store 745 "\02" ;; alignment 2 746 "\82\80\80\80\10" ;; offset 2 with unused bits set 747 "\0b" ;; end 748 ) 749 "integer too large" 750 ) 751 (assert_malformed 752 (module binary 753 "\00asm" "\01\00\00\00" 754 "\01\04\01\60\00\00" ;; Type section 755 "\03\02\01\00" ;; Function section 756 "\05\03\01\00\01" ;; Memory section 757 "\0a\11\01" ;; Code section 758 759 ;; function 0 760 "\0f\01\01" ;; local type count 761 "\7f" ;; i32 762 "\41\00" ;; i32.const 0 763 "\41\03" ;; i32.const 3 764 "\36" ;; i32.store 765 "\02" ;; alignment 2 766 "\82\80\80\80\40" ;; offset 2 with some unused bits set 767 "\0b" ;; end 768 ) 769 "integer too large" 770 ) 771 772 ;; Signed LEB128s sign-extend 773 (assert_malformed 774 (module binary 775 "\00asm" "\01\00\00\00" 776 "\06\0a\01" ;; Global section with 1 entry 777 "\7f\00" ;; i32, immutable 778 "\41\80\80\80\80\70" ;; i32.const 0 with unused bits set 779 "\0b" ;; end 780 ) 781 "integer too large" 782 ) 783 (assert_malformed 784 (module binary 785 "\00asm" "\01\00\00\00" 786 "\06\0a\01" ;; Global section with 1 entry 787 "\7f\00" ;; i32, immutable 788 "\41\ff\ff\ff\ff\0f" ;; i32.const -1 with unused bits unset 789 "\0b" ;; end 790 ) 791 "integer too large" 792 ) 793 (assert_malformed 794 (module binary 795 "\00asm" "\01\00\00\00" 796 "\06\0a\01" ;; Global section with 1 entry 797 "\7f\00" ;; i32, immutable 798 "\41\80\80\80\80\1f" ;; i32.const 0 with some unused bits set 799 "\0b" ;; end 800 ) 801 "integer too large" 802 ) 803 (assert_malformed 804 (module binary 805 "\00asm" "\01\00\00\00" 806 "\06\0a\01" ;; Global section with 1 entry 807 "\7f\00" ;; i32, immutable 808 "\41\ff\ff\ff\ff\4f" ;; i32.const -1 with some unused bits unset 809 "\0b" ;; end 810 ) 811 "integer too large" 812 ) 813 814 (assert_malformed 815 (module binary 816 "\00asm" "\01\00\00\00" 817 "\06\0f\01" ;; Global section with 1 entry 818 "\7e\00" ;; i64, immutable 819 "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set 820 "\0b" ;; end 821 ) 822 "integer too large" 823 ) 824 (assert_malformed 825 (module binary 826 "\00asm" "\01\00\00\00" 827 "\06\0f\01" ;; Global section with 1 entry 828 "\7e\00" ;; i64, immutable 829 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset 830 "\0b" ;; end 831 ) 832 "integer too large" 833 ) 834 (assert_malformed 835 (module binary 836 "\00asm" "\01\00\00\00" 837 "\06\0f\01" ;; Global section with 1 entry 838 "\7e\00" ;; i64, immutable 839 "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set 840 "\0b" ;; end 841 ) 842 "integer too large" 843 ) 844 (assert_malformed 845 (module binary 846 "\00asm" "\01\00\00\00" 847 "\06\0f\01" ;; Global section with 1 entry 848 "\7e\00" ;; i64, immutable 849 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset 850 "\0b" ;; end 851 ) 852 "integer too large" 853 ) 854 855 ;; memory.grow reserved byte equal to zero. 856 (assert_malformed 857 (module binary 858 "\00asm" "\01\00\00\00" 859 "\01\04\01\60\00\00" ;; Type section 860 "\03\02\01\00" ;; Function section 861 "\05\03\01\00\00" ;; Memory section 862 "\0a\09\01" ;; Code section 863 864 ;; function 0 865 "\07\00" 866 "\41\00" ;; i32.const 0 867 "\40" ;; memory.grow 868 "\01" ;; memory.grow reserved byte is not equal to zero! 869 "\1a" ;; drop 870 "\0b" ;; end 871 ) 872 "zero byte expected" 873 ) 874 875 ;; memory.grow reserved byte should not be a "long" LEB128 zero. 876 (assert_malformed 877 (module binary 878 "\00asm" "\01\00\00\00" 879 "\01\04\01\60\00\00" ;; Type section 880 "\03\02\01\00" ;; Function section 881 "\05\03\01\00\00" ;; Memory section 882 "\0a\0a\01" ;; Code section 883 884 ;; function 0 885 "\08\00" 886 "\41\00" ;; i32.const 0 887 "\40" ;; memory.grow 888 "\80\00" ;; memory.grow reserved byte 889 "\1a" ;; drop 890 "\0b" ;; end 891 ) 892 "zero byte expected" 893 ) 894 895 ;; Same as above for 3, 4, and 5-byte zero encodings. 896 (assert_malformed 897 (module binary 898 "\00asm" "\01\00\00\00" 899 "\01\04\01\60\00\00" ;; Type section 900 "\03\02\01\00" ;; Function section 901 "\05\03\01\00\00" ;; Memory section 902 "\0a\0b\01" ;; Code section 903 904 ;; function 0 905 "\09\00" 906 "\41\00" ;; i32.const 0 907 "\40" ;; memory.grow 908 "\80\80\00" ;; memory.grow reserved byte 909 "\1a" ;; drop 910 "\0b" ;; end 911 ) 912 "zero byte expected" 913 ) 914 915 (assert_malformed 916 (module binary 917 "\00asm" "\01\00\00\00" 918 "\01\04\01\60\00\00" ;; Type section 919 "\03\02\01\00" ;; Function section 920 "\05\03\01\00\00" ;; Memory section 921 "\0a\0c\01" ;; Code section 922 923 ;; function 0 924 "\0a\00" 925 "\41\00" ;; i32.const 0 926 "\40" ;; memory.grow 927 "\80\80\80\00" ;; memory.grow reserved byte 928 "\1a" ;; drop 929 "\0b" ;; end 930 ) 931 "zero byte expected" 932 ) 933 934 (assert_malformed 935 (module binary 936 "\00asm" "\01\00\00\00" 937 "\01\04\01\60\00\00" ;; Type section 938 "\03\02\01\00" ;; Function section 939 "\05\03\01\00\00" ;; Memory section 940 "\0a\0d\01" ;; Code section 941 942 ;; function 0 943 "\0b\00" 944 "\41\00" ;; i32.const 0 945 "\40" ;; memory.grow 946 "\80\80\80\80\00" ;; memory.grow reserved byte 947 "\1a" ;; drop 948 "\0b" ;; end 949 ) 950 "zero byte expected" 951 ) 952 953 ;; memory.size reserved byte equal to zero. 954 (assert_malformed 955 (module binary 956 "\00asm" "\01\00\00\00" 957 "\01\04\01\60\00\00" ;; Type section 958 "\03\02\01\00" ;; Function section 959 "\05\03\01\00\00" ;; Memory section 960 "\0a\07\01" ;; Code section 961 962 ;; function 0 963 "\05\00" 964 "\3f" ;; memory.size 965 "\01" ;; memory.size reserved byte is not equal to zero! 966 "\1a" ;; drop 967 "\0b" ;; end 968 ) 969 "zero byte expected" 970 ) 971 972 ;; memory.size reserved byte should not be a "long" LEB128 zero. 973 (assert_malformed 974 (module binary 975 "\00asm" "\01\00\00\00" 976 "\01\04\01\60\00\00" ;; Type section 977 "\03\02\01\00" ;; Function section 978 "\05\03\01\00\00" ;; Memory section 979 "\0a\08\01" ;; Code section 980 981 ;; function 0 982 "\06\00" 983 "\3f" ;; memory.size 984 "\80\00" ;; memory.size reserved byte 985 "\1a" ;; drop 986 "\0b" ;; end 987 ) 988 "zero byte expected" 989 ) 990 991 ;; Same as above for 3, 4, and 5-byte zero encodings. 992 (assert_malformed 993 (module binary 994 "\00asm" "\01\00\00\00" 995 "\01\04\01\60\00\00" ;; Type section 996 "\03\02\01\00" ;; Function section 997 "\05\03\01\00\00" ;; Memory section 998 "\0a\09\01" ;; Code section 999 1000 ;; function 0 1001 "\07\00" 1002 "\3f" ;; memory.size 1003 "\80\80\00" ;; memory.size reserved byte 1004 "\1a" ;; drop 1005 "\0b" ;; end 1006 ) 1007 "zero byte expected" 1008 ) 1009 1010 (assert_malformed 1011 (module binary 1012 "\00asm" "\01\00\00\00" 1013 "\01\04\01\60\00\00" ;; Type section 1014 "\03\02\01\00" ;; Function section 1015 "\05\03\01\00\00" ;; Memory section 1016 "\0a\0a\01" ;; Code section 1017 1018 ;; function 0 1019 "\08\00" 1020 "\3f" ;; memory.size 1021 "\80\80\80\00" ;; memory.size reserved byte 1022 "\1a" ;; drop 1023 "\0b" ;; end 1024 ) 1025 "zero byte expected" 1026 ) 1027 1028 (assert_malformed 1029 (module binary 1030 "\00asm" "\01\00\00\00" 1031 "\01\04\01\60\00\00" ;; Type section 1032 "\03\02\01\00" ;; Function section 1033 "\05\03\01\00\00" ;; Memory section 1034 "\0a\0b\01" ;; Code section 1035 1036 ;; function 0 1037 "\09\00" 1038 "\3f" ;; memory.size 1039 "\80\80\80\80\00" ;; memory.size reserved byte 1040 "\1a" ;; drop 1041 "\0b" ;; end 1042 ) 1043 "zero byte expected" 1044 ) 1045 1046 ;; Local number is unsigned 32 bit 1047 (assert_malformed 1048 (module binary 1049 "\00asm" "\01\00\00\00" 1050 "\01\04\01\60\00\00" ;; Type section 1051 "\03\02\01\00" ;; Function section 1052 "\0a\0c\01" ;; Code section 1053 1054 ;; function 0 1055 "\0a\02" 1056 "\80\80\80\80\10\7f" ;; 0x100000000 i32 1057 "\02\7e" ;; 0x00000002 i64 1058 "\0b" ;; end 1059 ) 1060 "integer too large" 1061 ) 1062 1063 ;; Local number is unsigned 32 bit 1064 (assert_malformed 1065 (module binary 1066 "\00asm" "\01\00\00\00" 1067 "\01\04\01\60\00\00" ;; Type section 1068 "\03\02\01\00" ;; Function section 1069 "\0a\0c\01" ;; Code section 1070 1071 ;; function 0 1072 "\0a\02" 1073 "\80\80\80\80\10\7f" ;; 0x100000000 i32 1074 "\02\7e" ;; 0x00000002 i64 1075 "\0b" ;; end 1076 ) 1077 "integer too large" 1078 ) 1079 1080 ;; No more than 2^32-1 locals. 1081 (assert_malformed 1082 (module binary 1083 "\00asm" "\01\00\00\00" 1084 "\01\04\01\60\00\00" ;; Type section 1085 "\03\02\01\00" ;; Function section 1086 "\0a\0c\01" ;; Code section 1087 1088 ;; function 0 1089 "\0a\02" 1090 "\ff\ff\ff\ff\0f\7f" ;; 0xFFFFFFFF i32 1091 "\02\7e" ;; 0x00000002 i64 1092 "\0b" ;; end 1093 ) 1094 "too many locals" 1095 ) 1096 1097 (assert_malformed 1098 (module binary 1099 "\00asm" "\01\00\00\00" 1100 "\01\06\01\60\02\7f\7f\00" ;; Type section: (param i32 i32) 1101 "\03\02\01\00" ;; Function section 1102 "\0a\1c\01" ;; Code section 1103 1104 ;; function 0 1105 "\1a\04" 1106 "\80\80\80\80\04\7f" ;; 0x40000000 i32 1107 "\80\80\80\80\04\7e" ;; 0x40000000 i64 1108 "\80\80\80\80\04\7d" ;; 0x40000000 f32 1109 "\80\80\80\80\04\7c" ;; 0x40000000 f64 1110 "\0b" ;; end 1111 ) 1112 "too many locals" 1113 ) 1114 1115 ;; Local count can be 0. 1116 (module binary 1117 "\00asm" "\01\00\00\00" 1118 "\01\04\01\60\00\00" ;; Type section 1119 "\03\02\01\00" ;; Function section 1120 "\0a\0a\01" ;; Code section 1121 1122 ;; function 0 1123 "\08\03" 1124 "\00\7f" ;; 0 i32 1125 "\00\7e" ;; 0 i64 1126 "\02\7d" ;; 2 f32 1127 "\0b" ;; end 1128 ) 1129 1130 ;; Function section has non-zero count, but code section is absent. 1131 (assert_malformed 1132 (module binary 1133 "\00asm" "\01\00\00\00" 1134 "\01\04\01\60\00\00" ;; Type section 1135 "\03\03\02\00\00" ;; Function section with 2 functions 1136 ) 1137 "function and code section have inconsistent lengths" 1138 ) 1139 1140 ;; Code section has non-zero count, but function section is absent. 1141 (assert_malformed 1142 (module binary 1143 "\00asm" "\01\00\00\00" 1144 "\0a\04\01\02\00\0b" ;; Code section with 1 empty function 1145 ) 1146 "function and code section have inconsistent lengths" 1147 ) 1148 1149 ;; Function section count > code section count 1150 (assert_malformed 1151 (module binary 1152 "\00asm" "\01\00\00\00" 1153 "\01\04\01\60\00\00" ;; Type section 1154 "\03\03\02\00\00" ;; Function section with 2 functions 1155 "\0a\04\01\02\00\0b" ;; Code section with 1 empty function 1156 ) 1157 "function and code section have inconsistent lengths" 1158 ) 1159 1160 ;; Function section count < code section count 1161 (assert_malformed 1162 (module binary 1163 "\00asm" "\01\00\00\00" 1164 "\01\04\01\60\00\00" ;; Type section 1165 "\03\02\01\00" ;; Function section with 1 function 1166 "\0a\07\02\02\00\0b\02\00\0b" ;; Code section with 2 empty functions 1167 ) 1168 "function and code section have inconsistent lengths" 1169 ) 1170 1171 ;; Function section has zero count, and code section is absent. 1172 (module binary 1173 "\00asm" "\01\00\00\00" 1174 "\03\01\00" ;; Function section with 0 functions 1175 ) 1176 1177 ;; Code section has zero count, and function section is absent. 1178 (module binary 1179 "\00asm" "\01\00\00\00" 1180 "\0a\01\00" ;; Code section with 0 functions 1181 ) 1182 1183 ;; Fewer passive segments than datacount 1184 (assert_malformed 1185 (module binary 1186 "\00asm" "\01\00\00\00" 1187 "\0c\01\03" ;; Datacount section with value "3" 1188 "\0b\05\02" ;; Data section with two entries 1189 "\01\00" ;; Passive data section 1190 "\01\00") ;; Passive data section 1191 "data count and data section have inconsistent lengths") 1192 1193 ;; More passive segments than datacount 1194 (assert_malformed 1195 (module binary 1196 "\00asm" "\01\00\00\00" 1197 "\0c\01\01" ;; Datacount section with value "1" 1198 "\0b\05\02" ;; Data section with two entries 1199 "\01\00" ;; Passive data section 1200 "\01\00") ;; Passive data section 1201 "data count and data section have inconsistent lengths") 1202 1203 ;; memory.init requires a datacount section 1204 (assert_malformed 1205 (module binary 1206 "\00asm" "\01\00\00\00" 1207 1208 "\01\04\01\60\00\00" ;; Type section 1209 "\03\02\01\00" ;; Function section 1210 "\05\03\01\00\00" ;; Memory section 1211 "\0a\0e\01" ;; Code section 1212 1213 ;; function 0 1214 "\0c\00" 1215 "\41\00" ;; zero args 1216 "\41\00" 1217 "\41\00" 1218 "\fc\08\00\00" ;; memory.init 1219 "\0b" 1220 1221 "\0b\03\01\01\00" ;; Data section 1222 ) ;; end 1223 "data count section required") 1224 1225 ;; data.drop requires a datacount section 1226 (assert_malformed 1227 (module binary 1228 "\00asm" "\01\00\00\00" 1229 1230 "\01\04\01\60\00\00" ;; Type section 1231 "\03\02\01\00" ;; Function section 1232 "\05\03\01\00\00" ;; Memory section 1233 "\0a\07\01" ;; Code section 1234 1235 ;; function 0 1236 "\05\00" 1237 "\fc\09\00" ;; data.drop 1238 "\0b" 1239 1240 "\0b\03\01\01\00" ;; Data section 1241 ) ;; end 1242 "data count section required") 1243 1244 ;; passive element segment containing illegal opcode 1245 (assert_malformed 1246 (module binary 1247 "\00asm" "\01\00\00\00" 1248 1249 "\01\04\01\60\00\00" ;; Type section 1250 1251 "\03\02\01\00" ;; Function section 1252 1253 "\04\04\01" ;; Table section with 1 entry 1254 "\70\00\00" ;; no max, minimum 0, funcref 1255 1256 "\05\03\01\00\00" ;; Memory section 1257 1258 "\09\07\01" ;; Element section with one segment 1259 "\05\70" ;; Passive, funcref 1260 "\01" ;; 1 element 1261 "\f3\00\0b" ;; bad opcode, index 0, end 1262 1263 "\0a\04\01" ;; Code section 1264 1265 ;; function 0 1266 "\02\00" 1267 "\0b") ;; end 1268 "illegal opcode") 1269 1270 ;; passive element segment containing type other than funcref 1271 (assert_malformed 1272 (module binary 1273 "\00asm" "\01\00\00\00" 1274 1275 "\01\04\01\60\00\00" ;; Type section 1276 1277 "\03\02\01\00" ;; Function section 1278 1279 "\04\04\01" ;; Table section with 1 entry 1280 "\70\00\00" ;; no max, minimum 0, funcref 1281 1282 "\05\03\01\00\00" ;; Memory section 1283 1284 "\09\07\01" ;; Element section with one segment 1285 "\05\7f" ;; Passive, i32 1286 "\01" ;; 1 element 1287 "\d2\00\0b" ;; ref.func, index 0, end 1288 1289 "\0a\04\01" ;; Code section 1290 1291 ;; function 0 1292 "\02\00" 1293 "\0b") ;; end 1294 "malformed reference type") 1295 1296 ;; passive element segment containing opcode ref.func 1297 (module binary 1298 "\00asm" "\01\00\00\00" 1299 1300 "\01\04\01\60\00\00" ;; Type section 1301 1302 "\03\02\01\00" ;; Function section 1303 1304 "\04\04\01" ;; Table section with 1 entry 1305 "\70\00\00" ;; no max, minimum 0, funcref 1306 1307 "\05\03\01\00\00" ;; Memory section 1308 1309 "\09\07\01" ;; Element section with one segment 1310 "\05\70" ;; Passive, funcref 1311 "\01" ;; 1 element 1312 "\d2\00\0b" ;; ref.func, index 0, end 1313 1314 "\0a\04\01" ;; Code section 1315 1316 ;; function 0 1317 "\02\00" 1318 "\0b") ;; end 1319 1320 ;; passive element segment containing opcode ref.null 1321 (module binary 1322 "\00asm" "\01\00\00\00" 1323 1324 "\01\04\01\60\00\00" ;; Type section 1325 1326 "\03\02\01\00" ;; Function section 1327 1328 "\04\04\01" ;; Table section with 1 entry 1329 "\70\00\00" ;; no max, minimum 0, funcref 1330 1331 "\05\03\01\00\00" ;; Memory section 1332 1333 "\09\07\01" ;; Element section with one segment 1334 "\05\70" ;; Passive, funcref 1335 "\01" ;; 1 element 1336 "\d0\70\0b" ;; ref.null, end 1337 1338 "\0a\04\01" ;; Code section 1339 1340 ;; function 0 1341 "\02\00" 1342 "\0b") ;; end 1343 1344 1345 ;; Type count can be zero 1346 (module binary 1347 "\00asm" "\01\00\00\00" 1348 "\01\01\00" ;; type count can be zero 1349 ) 1350 1351 ;; 2 type declared, 1 given 1352 (assert_malformed 1353 (module binary 1354 "\00asm" "\01\00\00\00" 1355 "\01\07\02" ;; type section with inconsistent count (2 declared, 1 given) 1356 "\60\00\00" ;; 1st type 1357 ;; "\60\00\00" ;; 2nd type (missed) 1358 ) 1359 "length out of bounds" 1360 ) 1361 1362 ;; 1 type declared, 2 given 1363 (assert_malformed 1364 (module binary 1365 "\00asm" "\01\00\00\00" 1366 "\01\07\01" ;; type section with inconsistent count (1 declared, 2 given) 1367 "\60\00\00" ;; 1st type 1368 "\60\00\00" ;; 2nd type (redundant) 1369 ) 1370 "section size mismatch" 1371 ) 1372 1373 ;; Import count can be zero 1374 (module binary 1375 "\00asm" "\01\00\00\00" 1376 "\01\05\01" ;; type section 1377 "\60\01\7f\00" ;; type 0 1378 "\02\01\00" ;; import count can be zero 1379 ) 1380 1381 ;; Malformed import kind 1382 (assert_malformed 1383 (module binary 1384 "\00asm" "\01\00\00\00" 1385 "\02\04\01" ;; import section with single entry 1386 "\00" ;; string length 0 1387 "\00" ;; string length 0 1388 "\04" ;; malformed import kind 1389 ) 1390 "malformed import kind" 1391 ) 1392 (assert_malformed 1393 (module binary 1394 "\00asm" "\01\00\00\00" 1395 "\02\05\01" ;; import section with single entry 1396 "\00" ;; string length 0 1397 "\00" ;; string length 0 1398 "\04" ;; malformed import kind 1399 "\00" ;; dummy byte 1400 ) 1401 "malformed import kind" 1402 ) 1403 (assert_malformed 1404 (module binary 1405 "\00asm" "\01\00\00\00" 1406 "\02\04\01" ;; import section with single entry 1407 "\00" ;; string length 0 1408 "\00" ;; string length 0 1409 "\05" ;; malformed import kind 1410 ) 1411 "malformed import kind" 1412 ) 1413 (assert_malformed 1414 (module binary 1415 "\00asm" "\01\00\00\00" 1416 "\02\05\01" ;; import section with single entry 1417 "\00" ;; string length 0 1418 "\00" ;; string length 0 1419 "\05" ;; malformed import kind 1420 "\00" ;; dummy byte 1421 ) 1422 "malformed import kind" 1423 ) 1424 (assert_malformed 1425 (module binary 1426 "\00asm" "\01\00\00\00" 1427 "\02\04\01" ;; import section with single entry 1428 "\00" ;; string length 0 1429 "\00" ;; string length 0 1430 "\80" ;; malformed import kind 1431 ) 1432 "malformed import kind" 1433 ) 1434 (assert_malformed 1435 (module binary 1436 "\00asm" "\01\00\00\00" 1437 "\02\05\01" ;; import section with single entry 1438 "\00" ;; string length 0 1439 "\00" ;; string length 0 1440 "\80" ;; malformed import kind 1441 "\00" ;; dummy byte 1442 ) 1443 "malformed import kind" 1444 ) 1445 1446 ;; 2 import declared, 1 given 1447 (assert_malformed 1448 (module binary 1449 "\00asm" "\01\00\00\00" 1450 "\01\05\01" ;; type section 1451 "\60\01\7f\00" ;; type 0 1452 "\02\16\02" ;; import section with inconsistent count (2 declared, 1 given) 1453 ;; 1st import 1454 "\08" ;; string length 1455 "\73\70\65\63\74\65\73\74" ;; spectest 1456 "\09" ;; string length 1457 "\70\72\69\6e\74\5f\69\33\32" ;; print_i32 1458 "\00\00" ;; import kind, import signature index 1459 ;; 2nd import 1460 ;; (missed) 1461 ) 1462 "unexpected end of section or function" 1463 ) 1464 1465 ;; 1 import declared, 2 given 1466 (assert_malformed 1467 (module binary 1468 "\00asm" "\01\00\00\00" 1469 "\01\09\02" ;; type section 1470 "\60\01\7f\00" ;; type 0 1471 "\60\01\7d\00" ;; type 1 1472 "\02\2b\01" ;; import section with inconsistent count (1 declared, 2 given) 1473 ;; 1st import 1474 "\08" ;; string length 1475 "\73\70\65\63\74\65\73\74" ;; spectest 1476 "\09" ;; string length 1477 "\70\72\69\6e\74\5f\69\33\32" ;; print_i32 1478 "\00\00" ;; import kind, import signature index 1479 ;; 2nd import 1480 ;; (redundant) 1481 "\08" ;; string length 1482 "\73\70\65\63\74\65\73\74" ;; spectest 1483 "\09" ;; string length 1484 "\70\72\69\6e\74\5f\66\33\32" ;; print_f32 1485 "\00\01" ;; import kind, import signature index 1486 ) 1487 "section size mismatch" 1488 ) 1489 1490 ;; Table count can be zero 1491 (module binary 1492 "\00asm" "\01\00\00\00" 1493 "\04\01\00" ;; table count can be zero 1494 ) 1495 1496 ;; 1 table declared, 0 given 1497 (assert_malformed 1498 (module binary 1499 "\00asm" "\01\00\00\00" 1500 "\04\01\01" ;; table section with inconsistent count (1 declared, 0 given) 1501 ;; "\70\01\00\00" ;; table entity 1502 ) 1503 "unexpected end of section or function" 1504 ) 1505 1506 ;; Malformed table limits flag 1507 (assert_malformed 1508 (module binary 1509 "\00asm" "\01\00\00\00" 1510 "\04\03\01" ;; table section with one entry 1511 "\70" ;; anyfunc 1512 "\02" ;; malformed table limits flag 1513 ) 1514 "integer too large" 1515 ) 1516 (assert_malformed 1517 (module binary 1518 "\00asm" "\01\00\00\00" 1519 "\04\04\01" ;; table section with one entry 1520 "\70" ;; anyfunc 1521 "\02" ;; malformed table limits flag 1522 "\00" ;; dummy byte 1523 ) 1524 "integer too large" 1525 ) 1526 (assert_malformed 1527 (module binary 1528 "\00asm" "\01\00\00\00" 1529 "\04\06\01" ;; table section with one entry 1530 "\70" ;; anyfunc 1531 "\81\00" ;; malformed table limits flag as LEB128 1532 "\00\00" ;; dummy bytes 1533 ) 1534 "integer representation too long" 1535 ) 1536 1537 ;; Memory count can be zero 1538 (module binary 1539 "\00asm" "\01\00\00\00" 1540 "\05\01\00" ;; memory count can be zero 1541 ) 1542 1543 ;; 1 memory declared, 0 given 1544 (assert_malformed 1545 (module binary 1546 "\00asm" "\01\00\00\00" 1547 "\05\01\01" ;; memory section with inconsistent count (1 declared, 0 given) 1548 ;; "\00\00" ;; memory 0 (missed) 1549 ) 1550 "unexpected end of section or function" 1551 ) 1552 1553 ;; Malformed memory limits flag 1554 (assert_malformed 1555 (module binary 1556 "\00asm" "\01\00\00\00" 1557 "\05\02\01" ;; memory section with one entry 1558 "\02" ;; malformed memory limits flag 1559 ) 1560 "integer too large" 1561 ) 1562 (assert_malformed 1563 (module binary 1564 "\00asm" "\01\00\00\00" 1565 "\05\03\01" ;; memory section with one entry 1566 "\02" ;; malformed memory limits flag 1567 "\00" ;; dummy byte 1568 ) 1569 "integer too large" 1570 ) 1571 (assert_malformed 1572 (module binary 1573 "\00asm" "\01\00\00\00" 1574 "\05\05\01" ;; memory section with one entry 1575 "\81\00" ;; malformed memory limits flag as LEB128 1576 "\00\00" ;; dummy bytes 1577 ) 1578 "integer representation too long" 1579 ) 1580 (assert_malformed 1581 (module binary 1582 "\00asm" "\01\00\00\00" 1583 "\05\05\01" ;; memory section with one entry 1584 "\81\01" ;; malformed memory limits flag as LEB128 1585 "\00\00" ;; dummy bytes 1586 ) 1587 "integer representation too long" 1588 ) 1589 1590 ;; Global count can be zero 1591 (module binary 1592 "\00asm" "\01\00\00\00" 1593 "\06\01\00" ;; global count can be zero 1594 ) 1595 1596 ;; 2 global declared, 1 given 1597 (assert_malformed 1598 (module binary 1599 "\00asm" "\01\00\00\00" 1600 "\06\06\02" ;; global section with inconsistent count (2 declared, 1 given) 1601 "\7f\00\41\00\0b" ;; global 0 1602 ;; "\7f\00\41\00\0b" ;; global 1 (missed) 1603 ) 1604 "unexpected end of section or function" 1605 ) 1606 1607 ;; 1 global declared, 2 given 1608 (assert_malformed 1609 (module binary 1610 "\00asm" "\01\00\00\00" 1611 "\06\0b\01" ;; global section with inconsistent count (1 declared, 2 given) 1612 "\7f\00\41\00\0b" ;; global 0 1613 "\7f\00\41\00\0b" ;; global 1 (redundant) 1614 ) 1615 "section size mismatch" 1616 ) 1617 1618 ;; Export count can be 0 1619 (module binary 1620 "\00asm" "\01\00\00\00" 1621 "\01\04\01" ;; type section 1622 "\60\00\00" ;; type 0 1623 "\03\03\02\00\00" ;; func section 1624 "\07\01\00" ;; export count can be zero 1625 "\0a\07\02" ;; code section 1626 "\02\00\0b" ;; function body 0 1627 "\02\00\0b" ;; function body 1 1628 ) 1629 1630 ;; 2 export declared, 1 given 1631 (assert_malformed 1632 (module binary 1633 "\00asm" "\01\00\00\00" 1634 "\01\04\01" ;; type section 1635 "\60\00\00" ;; type 0 1636 "\03\03\02\00\00" ;; func section 1637 "\07\06\02" ;; export section with inconsistent count (2 declared, 1 given) 1638 "\02" ;; export 0 1639 "\66\31" ;; export name 1640 "\00\00" ;; export kind, export func index 1641 ;; "\02" ;; export 1 (missed) 1642 ;; "\66\32" ;; export name 1643 ;; "\00\01" ;; export kind, export func index 1644 "\0a\07\02" ;; code section 1645 "\02\00\0b" ;; function body 0 1646 "\02\00\0b" ;; function body 1 1647 ) 1648 "length out of bounds" 1649 ) 1650 1651 ;; 1 export declared, 2 given 1652 (assert_malformed 1653 (module binary 1654 "\00asm" "\01\00\00\00" 1655 "\01\04\01" ;; type section 1656 "\60\00\00" ;; type 0 1657 "\03\03\02\00\00" ;; func section 1658 "\07\0b\01" ;; export section with inconsistent count (1 declared, 2 given) 1659 "\02" ;; export 0 1660 "\66\31" ;; export name 1661 "\00\00" ;; export kind, export func index 1662 "\02" ;; export 1 (redundant) 1663 "\66\32" ;; export name 1664 "\00\01" ;; export kind, export func index 1665 "\0a\07\02" ;; code section 1666 "\02\00\0b" ;; function body 0 1667 "\02\00\0b" ;; function body 1 1668 ) 1669 "section size mismatch" 1670 ) 1671 1672 ;; elem segment count can be zero 1673 (module binary 1674 "\00asm" "\01\00\00\00" 1675 "\01\04\01" ;; type section 1676 "\60\00\00" ;; type 0 1677 "\03\02\01\00" ;; func section 1678 "\04\04\01" ;; table section 1679 "\70\00\01" ;; table 0 1680 "\09\01\00" ;; elem segment count can be zero 1681 "\0a\04\01" ;; code section 1682 "\02\00\0b" ;; function body 1683 ) 1684 1685 ;; 2 elem segment declared, 1 given 1686 (assert_malformed 1687 (module binary 1688 "\00asm" "\01\00\00\00" 1689 "\01\04\01" ;; type section 1690 "\60\00\00" ;; type 0 1691 "\03\02\01\00" ;; func section 1692 "\04\04\01" ;; table section 1693 "\70\00\01" ;; table 0 1694 "\09\07\02" ;; elem with inconsistent segment count (2 declared, 1 given) 1695 "\00\41\00\0b\01\00" ;; elem 0 1696 ;; "\00\41\00\0b\01\00" ;; elem 1 (missed) 1697 ) 1698 "unexpected end" 1699 ) 1700 1701 ;; 2 elem segment declared, 1.5 given 1702 (assert_malformed 1703 (module binary 1704 "\00asm" "\01\00\00\00" 1705 "\01\04\01" ;; type section 1706 "\60\00\00" ;; type 0 1707 "\03\02\01\00" ;; func section 1708 "\04\04\01" ;; table section 1709 "\70\00\01" ;; table 0 1710 "\09\0a\02" ;; elem with inconsistent segment count (2 declared, 1 given) 1711 "\00\41\00\0b\01\00" ;; elem 0 1712 "\00\41\00" ;; elem 1 (partial) 1713 ;; "\0b\01\00" ;; elem 1 (missing part) 1714 ) 1715 "unexpected end" 1716 ) 1717 1718 ;; 1 elem segment declared, 2 given 1719 (assert_malformed 1720 (module binary 1721 "\00asm" "\01\00\00\00" 1722 "\01\04\01" ;; type section 1723 "\60\00\00" ;; type 0 1724 "\03\02\01\00" ;; func section 1725 "\04\04\01" ;; table section 1726 "\70\00\01" ;; table 0 1727 "\09\0d\01" ;; elem with inconsistent segment count (1 declared, 2 given) 1728 "\00\41\00\0b\01\00" ;; elem 0 1729 "\00\41\00\0b\01\00" ;; elem 1 (redundant) 1730 "\0a\04\01" ;; code section 1731 "\02\00\0b" ;; function body 1732 ) 1733 "section size mismatch" 1734 ) 1735 1736 ;; data segment count can be zero 1737 (module binary 1738 "\00asm" "\01\00\00\00" 1739 "\05\03\01" ;; memory section 1740 "\00\01" ;; memory 0 1741 "\0b\01\00" ;; data segment count can be zero 1742 ) 1743 1744 ;; 2 data segment declared, 1 given 1745 (assert_malformed 1746 (module binary 1747 "\00asm" "\01\00\00\00" 1748 "\05\03\01" ;; memory section 1749 "\00\01" ;; memory 0 1750 "\0b\07\02" ;; data with inconsistent segment count (2 declared, 1 given) 1751 "\00\41\00\0b\01\61" ;; data 0 1752 ;; "\00\41\01\0b\01\62" ;; data 1 (missed) 1753 ) 1754 "unexpected end of section or function" 1755 ) 1756 1757 ;; 1 data segment declared, 2 given 1758 (assert_malformed 1759 (module binary 1760 "\00asm" "\01\00\00\00" 1761 "\05\03\01" ;; memory section 1762 "\00\01" ;; memory 0 1763 "\0b\0d\01" ;; data with inconsistent segment count (1 declared, 2 given) 1764 "\00\41\00\0b\01\61" ;; data 0 1765 "\00\41\01\0b\01\62" ;; data 1 (redundant) 1766 ) 1767 "section size mismatch" 1768 ) 1769 1770 ;; data segment has 7 bytes declared, but 6 bytes given 1771 (assert_malformed 1772 (module binary 1773 "\00asm" "\01\00\00\00" 1774 "\05\03\01" ;; memory section 1775 "\00\01" ;; memory 0 1776 "\0b\0c\01" ;; data section 1777 "\00\41\03\0b" ;; data segment 0 1778 "\07" ;; data segment size with inconsistent lengths (7 declared, 6 given) 1779 "\61\62\63\64\65\66" ;; 6 bytes given 1780 ) 1781 "unexpected end of section or function" 1782 ) 1783 1784 ;; data segment has 5 bytes declared, but 6 bytes given 1785 (assert_malformed 1786 (module binary 1787 "\00asm" "\01\00\00\00" 1788 "\05\03\01" ;; memory section 1789 "\00\01" ;; memory 0 1790 "\0b\0c\01" ;; data section 1791 "\00\41\00\0b" ;; data segment 0 1792 "\05" ;; data segment size with inconsistent lengths (5 declared, 6 given) 1793 "\61\62\63\64\65\66" ;; 6 bytes given 1794 ) 1795 "section size mismatch" 1796 ) 1797 1798 ;; br_table target count can be zero 1799 (module binary 1800 "\00asm" "\01\00\00\00" 1801 "\01\04\01" ;; type section 1802 "\60\00\00" ;; type 0 1803 "\03\02\01\00" ;; func section 1804 "\0a\11\01" ;; code section 1805 "\0f\00" ;; func 0 1806 "\02\40" ;; block 0 1807 "\41\01" ;; condition of if 0 1808 "\04\40" ;; if 0 1809 "\41\01" ;; index of br_table element 1810 "\0e\00" ;; br_table target count can be zero 1811 "\02" ;; break depth for default 1812 "\0b\0b\0b" ;; end 1813 ) 1814 1815 ;; 1 br_table target declared, 2 given 1816 (assert_malformed 1817 (module binary 1818 "\00asm" "\01\00\00\00" 1819 "\01\04\01" ;; type section 1820 "\60\00\00" ;; type 0 1821 "\03\02\01\00" ;; func section 1822 "\0a\13\01" ;; code section 1823 "\11\00" ;; func 0 1824 "\02\40" ;; block 0 1825 "\41\01" ;; condition of if 0 1826 "\04\40" ;; if 0 1827 "\41\01" ;; index of br_table element 1828 "\0e\01" ;; br_table with inconsistent target count (1 declared, 2 given) 1829 "\00" ;; break depth 0 1830 "\01" ;; break depth 1 1831 "\02" ;; break depth for default 1832 "\0b\0b\0b" ;; end 1833 ) 1834 "unexpected end" 1835 ) 1836 1837 ;; Start section 1838 (module binary 1839 "\00asm" "\01\00\00\00" 1840 "\01\04\01\60\00\00" ;; Type section 1841 "\03\02\01\00" ;; Function section 1842 "\08\01\00" ;; Start section: function 0 1843 1844 "\0a\04\01" ;; Code section 1845 ;; function 0 1846 "\02\00" 1847 "\0b" ;; end 1848 ) 1849 1850 ;; Multiple start sections 1851 (assert_malformed 1852 (module binary 1853 "\00asm" "\01\00\00\00" 1854 "\01\04\01\60\00\00" ;; Type section 1855 "\03\02\01\00" ;; Function section 1856 "\08\01\00" ;; Start section: function 0 1857 "\08\01\00" ;; Start section: function 0 1858 1859 "\0a\04\01" ;; Code section 1860 ;; function 0 1861 "\02\00" 1862 "\0b" ;; end 1863 ) 1864 "unexpected content after last section" 1865 )