[llvm] r302560 - [WebAssembly] Fix validation of start function
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 10:51:38 PDT 2017
Author: sbc
Date: Tue May 9 12:51:38 2017
New Revision: 302560
URL: http://llvm.org/viewvc/llvm-project?rev=302560&view=rev
Log:
[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
Added:
llvm/trunk/test/Object/wasm-invalid-start.test
Modified:
llvm/trunk/lib/Object/WasmObjectFile.cpp
llvm/trunk/test/ObjectYAML/wasm/function_section.yaml
llvm/trunk/test/ObjectYAML/wasm/start_section.yaml
Modified: llvm/trunk/lib/Object/WasmObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WasmObjectFile.cpp?rev=302560&r1=302559&r2=302560&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp Tue May 9 12:51:38 2017
@@ -507,7 +507,7 @@ Error WasmObjectFile::parseExportSection
Error WasmObjectFile::parseStartSection(const uint8_t *Ptr, const uint8_t *End) {
StartFunction = readVaruint32(Ptr);
- if (StartFunction < FunctionTypes.size())
+ if (StartFunction >= FunctionTypes.size())
return make_error<GenericBinaryError>("Invalid start function",
object_error::parse_failed);
return Error::success();
Added: llvm/trunk/test/Object/wasm-invalid-start.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/wasm-invalid-start.test?rev=302560&view=auto
==============================================================================
--- llvm/trunk/test/Object/wasm-invalid-start.test (added)
+++ llvm/trunk/test/Object/wasm-invalid-start.test Tue May 9 12:51:38 2017
@@ -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
Modified: llvm/trunk/test/ObjectYAML/wasm/function_section.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/wasm/function_section.yaml?rev=302560&r1=302559&r2=302560&view=diff
==============================================================================
--- llvm/trunk/test/ObjectYAML/wasm/function_section.yaml (original)
+++ llvm/trunk/test/ObjectYAML/wasm/function_section.yaml Tue May 9 12:51:38 2017
@@ -4,9 +4,7 @@ FileHeader:
Version: 0x00000001
Sections:
- Type: FUNCTION
- FunctionTypes:
- - 1
- - 0
+ FunctionTypes: [ 1, 0 ]
...
# CHECK: --- !WASM
# CHECK: FileHeader:
Modified: llvm/trunk/test/ObjectYAML/wasm/start_section.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/wasm/start_section.yaml?rev=302560&r1=302559&r2=302560&view=diff
==============================================================================
--- llvm/trunk/test/ObjectYAML/wasm/start_section.yaml (original)
+++ llvm/trunk/test/ObjectYAML/wasm/start_section.yaml Tue May 9 12:51:38 2017
@@ -1,8 +1,17 @@
# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+
--- !WASM
FileHeader:
Version: 0x00000001
Sections:
+ - Type: TYPE
+ Signatures:
+ - ReturnType: I32
+ ParamTypes:
+ - F32
+ - F32
+ - Type: FUNCTION
+ FunctionTypes: [ 0, 0, 0 ]
- Type: START
StartFunction: 1
...
More information about the llvm-commits
mailing list