| Index: test/unittests/wasm/module-decoder-unittest.cc
|
| diff --git a/test/unittests/wasm/module-decoder-unittest.cc b/test/unittests/wasm/module-decoder-unittest.cc
|
| index f254358fc90dfbb8923d199289eca95ff0f57cdd..588cec52a8a8d2874360da408274d52c3bcc656c 100644
|
| --- a/test/unittests/wasm/module-decoder-unittest.cc
|
| +++ b/test/unittests/wasm/module-decoder-unittest.cc
|
| @@ -417,6 +417,86 @@ TEST_F(WasmModuleVerifyTest, MultipleSignatures) {
|
| EXPECT_OFF_END_FAILURE(data, 1, sizeof(data));
|
| }
|
|
|
| +TEST_F(WasmModuleVerifyTest, DataSegmentWithImmutableImportedGlobal) {
|
| + const byte data[] = {
|
| + SECTION(Import, 8), // section header
|
| + 1, // number of imports
|
| + NAME_LENGTH(1), // --
|
| + 'm', // module name
|
| + NAME_LENGTH(1), // --
|
| + 'f', // global name
|
| + kExternalGlobal, // import kind
|
| + kLocalI32, // type
|
| + 0, // mutability
|
| + SECTION(Memory, 4),
|
| + ENTRY_COUNT(1),
|
| + kResizableMaximumFlag,
|
| + 28,
|
| + 28,
|
| + SECTION(Data, 9),
|
| + ENTRY_COUNT(1),
|
| + LINEAR_MEMORY_INDEX_0,
|
| + WASM_INIT_EXPR_GLOBAL(0), // dest addr
|
| + U32V_1(3), // source size
|
| + 'a',
|
| + 'b',
|
| + 'c' // data bytes
|
| + };
|
| + EXPECT_VERIFIES(data);
|
| +}
|
| +TEST_F(WasmModuleVerifyTest, DataSegmentWithMutableImportedGlobal) {
|
| + // Only an immutable imported global can be used as an init_expr.
|
| + const byte data[] = {
|
| + SECTION(Import, 8), // section header
|
| + 1, // number of imports
|
| + NAME_LENGTH(1), // --
|
| + 'm', // module name
|
| + NAME_LENGTH(1), // --
|
| + 'f', // global name
|
| + kExternalGlobal, // import kind
|
| + kLocalI32, // type
|
| + 1, // mutability
|
| + SECTION(Memory, 4),
|
| + ENTRY_COUNT(1),
|
| + kResizableMaximumFlag,
|
| + 28,
|
| + 28,
|
| + SECTION(Data, 9),
|
| + ENTRY_COUNT(1),
|
| + LINEAR_MEMORY_INDEX_0,
|
| + WASM_INIT_EXPR_GLOBAL(0), // dest addr
|
| + U32V_1(3), // source size
|
| + 'a',
|
| + 'b',
|
| + 'c' // data bytes
|
| + };
|
| + EXPECT_FAILURE(data);
|
| +}
|
| +TEST_F(WasmModuleVerifyTest, DataSegmentWithImmutableGlobal) {
|
| + // Only an immutable imported global can be used as an init_expr.
|
| + const byte data[] = {
|
| + SECTION(Memory, 4),
|
| + ENTRY_COUNT(1),
|
| + kResizableMaximumFlag,
|
| + 28,
|
| + 28,
|
| + SECTION(Global, 8), // --
|
| + 1,
|
| + kLocalI32, // local type
|
| + 0, // immutable
|
| + WASM_INIT_EXPR_I32V_3(0x9bbaa), // init
|
| + SECTION(Data, 9),
|
| + ENTRY_COUNT(1),
|
| + LINEAR_MEMORY_INDEX_0,
|
| + WASM_INIT_EXPR_GLOBAL(0), // dest addr
|
| + U32V_1(3), // source size
|
| + 'a',
|
| + 'b',
|
| + 'c' // data bytes
|
| + };
|
| + EXPECT_FAILURE(data);
|
| +}
|
| +
|
| TEST_F(WasmModuleVerifyTest, OneDataSegment) {
|
| const byte kDataSegmentSourceOffset = 24;
|
| const byte data[] = {
|
|
|