diff options
-rw-r--r-- | src/binary-reader.cc | 22 | ||||
-rw-r--r-- | test/spec/bulk-memory-operations/imports.txt | 2 | ||||
-rw-r--r-- | test/spec/imports.txt | 2 | ||||
-rw-r--r-- | test/spec/memory.txt | 5 | ||||
-rw-r--r-- | test/spec/reference-types/imports.txt | 2 |
5 files changed, 23 insertions, 10 deletions
diff --git a/src/binary-reader.cc b/src/binary-reader.cc index fcb38a6c..74fd3a67 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -2006,7 +2006,8 @@ Result BinaryReader::ReadImportSection(Offset section_size) { uint8_t kind; CHECK_RESULT(ReadU8(&kind, "import kind")); - CALLBACK(OnImport, i, static_cast<ExternalKind>(kind), module_name, field_name); + CALLBACK(OnImport, i, static_cast<ExternalKind>(kind), module_name, + field_name); switch (static_cast<ExternalKind>(kind)) { case ExternalKind::Func: { Index sig_index; @@ -2060,6 +2061,16 @@ Result BinaryReader::ReadImportSection(Offset section_size) { } } } + + ERROR_UNLESS(num_memory_imports_ <= 1, + "memory count (%" PRIindex ") must be 0 or 1", + num_memory_imports_); + if (!options_.features.reference_types_enabled()) { + ERROR_UNLESS(num_table_imports_ <= 1, + "table count (%" PRIindex ") must be 0 or 1", + num_table_imports_); + } + CALLBACK0(EndImportSection); return Result::Ok; } @@ -2085,8 +2096,9 @@ Result BinaryReader::ReadTableSection(Offset section_size) { CALLBACK(BeginTableSection, section_size); CHECK_RESULT(ReadCount(&num_tables_, "table count")); if (!options_.features.reference_types_enabled()) { - ERROR_UNLESS(num_tables_ <= 1, "table count (%" PRIindex ") must be 0 or 1", - num_tables_); + ERROR_UNLESS(num_table_imports_ + num_tables_ <= 1, + "table count (%" PRIindex ") must be 0 or 1", + num_table_imports_ + num_tables_); } CALLBACK(OnTableCount, num_tables_); for (Index i = 0; i < num_tables_; ++i) { @@ -2103,7 +2115,9 @@ Result BinaryReader::ReadTableSection(Offset section_size) { Result BinaryReader::ReadMemorySection(Offset section_size) { CALLBACK(BeginMemorySection, section_size); CHECK_RESULT(ReadCount(&num_memories_, "memory count")); - ERROR_UNLESS(num_memories_ <= 1, "memory count must be 0 or 1"); + ERROR_UNLESS(num_memory_imports_ + num_memories_ <= 1, + "memory count (%" PRIindex ") must be 0 or 1", + num_memory_imports_ + num_memories_); CALLBACK(OnMemoryCount, num_memories_); for (Index i = 0; i < num_memories_; ++i) { Index memory_index = num_memory_imports_ + i; diff --git a/test/spec/bulk-memory-operations/imports.txt b/test/spec/bulk-memory-operations/imports.txt index 1b7d1434..ec2e700e 100644 --- a/test/spec/bulk-memory-operations/imports.txt +++ b/test/spec/bulk-memory-operations/imports.txt @@ -163,7 +163,7 @@ out/test/spec/bulk-memory-operations/imports.wast:409: assert_invalid passed: error: unknown import module "" 0000010: error: OnImportMemory callback failed out/test/spec/bulk-memory-operations/imports.wast:413: assert_invalid passed: - 000000b: error: memory count must be 0 or 1 + 000000b: error: memory count (2) must be 0 or 1 out/test/spec/bulk-memory-operations/imports.wast:428: assert_unlinkable passed: error: unknown module field "unknown" 000001b: error: OnImportMemory callback failed diff --git a/test/spec/imports.txt b/test/spec/imports.txt index 60ef9fdc..477c1d30 100644 --- a/test/spec/imports.txt +++ b/test/spec/imports.txt @@ -162,7 +162,7 @@ out/test/spec/imports.wast:409: assert_invalid passed: error: unknown import module "" 0000010: error: OnImportMemory callback failed out/test/spec/imports.wast:413: assert_invalid passed: - 000000b: error: memory count must be 0 or 1 + 000000b: error: memory count (2) must be 0 or 1 out/test/spec/imports.wast:428: assert_unlinkable passed: error: unknown module field "unknown" 000001b: error: OnImportMemory callback failed diff --git a/test/spec/memory.txt b/test/spec/memory.txt index b62fb8e1..033f0d75 100644 --- a/test/spec/memory.txt +++ b/test/spec/memory.txt @@ -2,10 +2,9 @@ ;;; STDIN_FILE: third_party/testsuite/memory.wast (;; STDOUT ;;; out/test/spec/memory.wast:8: assert_invalid passed: - 000000b: error: memory count must be 0 or 1 + 000000b: error: memory count (2) must be 0 or 1 out/test/spec/memory.wast:9: assert_invalid passed: - error: only one memory allowed - 0000023: error: OnMemory callback failed + 0000021: error: memory count (2) must be 0 or 1 out/test/spec/memory.wast:18: assert_invalid passed: 000000b: error: data section without memory section out/test/spec/memory.wast:19: assert_invalid passed: diff --git a/test/spec/reference-types/imports.txt b/test/spec/reference-types/imports.txt index 4e4036a5..017c5e41 100644 --- a/test/spec/reference-types/imports.txt +++ b/test/spec/reference-types/imports.txt @@ -161,7 +161,7 @@ out/test/spec/reference-types/imports.wast:421: assert_invalid passed: error: unknown import module "" 0000010: error: OnImportMemory callback failed out/test/spec/reference-types/imports.wast:425: assert_invalid passed: - 000000b: error: memory count must be 0 or 1 + 000000b: error: memory count (2) must be 0 or 1 out/test/spec/reference-types/imports.wast:440: assert_unlinkable passed: error: unknown module field "unknown" 000001b: error: OnImportMemory callback failed |