Commit 3fdc2773 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Restrict exception section according to spec.

The placement of the exceptipon section is by now restricted to be in
between the Global and the Import section. This changes our validation
to check this stricter requirement now.

R=clemensh@chromium.org
TEST=unittests/WasmModuleVerifyTest
BUG=v8:8091

Change-Id: Ib3ea625fd4df93bffda47ced09e6969159f7ac70
Reviewed-on: https://chromium-review.googlesource.com/c/1356504Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57962}
parent ad9835e5
......@@ -360,7 +360,7 @@ class ModuleDecoderImpl : public Decoder {
return CheckSectionOrder(section_code, kElementSectionCode,
kCodeSectionCode);
case kExceptionSectionCode:
return CheckSectionOrder(section_code, kImportSectionCode,
return CheckSectionOrder(section_code, kGlobalSectionCode,
kExportSectionCode);
default:
UNREACHABLE();
......
......@@ -64,7 +64,7 @@ let kStartSectionCode = 8; // Start function declaration
let kElementSectionCode = 9; // Elements section
let kCodeSectionCode = 10; // Function code
let kDataSectionCode = 11; // Data segments
let kExceptionSectionCode = 12; // Exception section (must appear before code section)
let kExceptionSectionCode = 12; // Exception section (between Global & Export)
// Name section types
let kModuleNameCode = 0;
......
......@@ -576,26 +576,26 @@ TEST_F(WasmModuleVerifyTest, ExceptionSectionAfterExport) {
"The Exception section must appear before the Export section");
}
TEST_F(WasmModuleVerifyTest, ExceptionSectionBeforeImport) {
TEST_F(WasmModuleVerifyTest, ExceptionSectionBeforeGlobal) {
static const byte data[] = {SECTION(Exception, ENTRY_COUNT(0)),
SECTION(Import, ENTRY_COUNT(0))};
SECTION(Global, ENTRY_COUNT(0))};
FAIL_IF_NO_EXPERIMENTAL_EH(data);
WASM_FEATURE_SCOPE(eh);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "unexpected section: Import");
EXPECT_NOT_OK(result, "unexpected section: Global");
}
TEST_F(WasmModuleVerifyTest, ExceptionSectionAfterTypeBeforeImport) {
STATIC_ASSERT(kTypeSectionCode + 1 == kImportSectionCode);
static const byte data[] = {SECTION(Type, ENTRY_COUNT(0)),
TEST_F(WasmModuleVerifyTest, ExceptionSectionAfterMemoryBeforeGlobal) {
STATIC_ASSERT(kMemorySectionCode + 1 == kGlobalSectionCode);
static const byte data[] = {SECTION(Memory, ENTRY_COUNT(0)),
SECTION(Exception, ENTRY_COUNT(0)),
SECTION(Import, ENTRY_COUNT(0))};
SECTION(Global, ENTRY_COUNT(0))};
FAIL_IF_NO_EXPERIMENTAL_EH(data);
WASM_FEATURE_SCOPE(eh);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "unexpected section: Import");
EXPECT_NOT_OK(result, "unexpected section: Global");
}
TEST_F(WasmModuleVerifyTest, ExceptionImport) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment