llvm.org GIT mirror llvm / 072e32f
[WebAssembly] Fix validation of start function The check for valid start function was inverted. Added a new test in test/Object to check this case and fixed the existing tests in for ObjectYAML. Differential Revision: https://reviews.llvm.org/D32986 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302560 91177308-0d34-0410-b5e6-96231b3b80d8 Sam Clegg 2 years ago
4 changed file(s) with 21 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
506506
507507 Error WasmObjectFile::parseStartSection(const uint8_t *Ptr, const uint8_t *End) {
508508 StartFunction = readVaruint32(Ptr);
509 if (StartFunction < FunctionTypes.size())
509 if (StartFunction >= FunctionTypes.size())
510510 return make_error("Invalid start function",
511511 object_error::parse_failed);
512512 return Error::success();
0 # RUN: yaml2obj %s | not llvm-objdump -h - 2>&1 | FileCheck %s
1
2 !WASM
3 FileHeader:
4 Version: 0x00000001
5 Sections:
6 - Type: START
7 StartFunction: 0
8
9 # CHECK: {{.*}}: Invalid start function
33 Version: 0x00000001
44 Sections:
55 - Type: FUNCTION
6 FunctionTypes:
7 - 1
8 - 0
6 FunctionTypes: [ 1, 0 ]
97 ...
108 # CHECK: --- !WASM
119 # CHECK: FileHeader:
0 # RUN: yaml2obj %s | obj2yaml | FileCheck %s
1
12 --- !WASM
23 FileHeader:
34 Version: 0x00000001
45 Sections:
6 - Type: TYPE
7 Signatures:
8 - ReturnType: I32
9 ParamTypes:
10 - F32
11 - F32
12 - Type: FUNCTION
13 FunctionTypes: [ 0, 0, 0 ]
514 - Type: START
615 StartFunction: 1
716 ...