1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[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

llvm-svn: 302560
This commit is contained in:
Sam Clegg 2017-05-09 17:51:38 +00:00
parent 688762900b
commit c698370461
4 changed files with 21 additions and 4 deletions

View File

@ -507,7 +507,7 @@ Error WasmObjectFile::parseExportSection(const uint8_t *Ptr, const uint8_t *End)
Error WasmObjectFile::parseStartSection(const uint8_t *Ptr, const uint8_t *End) { Error WasmObjectFile::parseStartSection(const uint8_t *Ptr, const uint8_t *End) {
StartFunction = readVaruint32(Ptr); StartFunction = readVaruint32(Ptr);
if (StartFunction < FunctionTypes.size()) if (StartFunction >= FunctionTypes.size())
return make_error<GenericBinaryError>("Invalid start function", return make_error<GenericBinaryError>("Invalid start function",
object_error::parse_failed); object_error::parse_failed);
return Error::success(); return Error::success();

View File

@ -0,0 +1,10 @@
# RUN: yaml2obj %s | not llvm-objdump -h - 2>&1 | FileCheck %s
!WASM
FileHeader:
Version: 0x00000001
Sections:
- Type: START
StartFunction: 0
# CHECK: {{.*}}: Invalid start function

View File

@ -4,9 +4,7 @@ FileHeader:
Version: 0x00000001 Version: 0x00000001
Sections: Sections:
- Type: FUNCTION - Type: FUNCTION
FunctionTypes: FunctionTypes: [ 1, 0 ]
- 1
- 0
... ...
# CHECK: --- !WASM # CHECK: --- !WASM
# CHECK: FileHeader: # CHECK: FileHeader:

View File

@ -1,8 +1,17 @@
# RUN: yaml2obj %s | obj2yaml | FileCheck %s # RUN: yaml2obj %s | obj2yaml | FileCheck %s
--- !WASM --- !WASM
FileHeader: FileHeader:
Version: 0x00000001 Version: 0x00000001
Sections: Sections:
- Type: TYPE
Signatures:
- ReturnType: I32
ParamTypes:
- F32
- F32
- Type: FUNCTION
FunctionTypes: [ 0, 0, 0 ]
- Type: START - Type: START
StartFunction: 1 StartFunction: 1
... ...