diff options
| author | Sam Clegg <sbc@chromium.org> | 2017-08-31 21:43:45 +0000 |
|---|---|---|
| committer | Sam Clegg <sbc@chromium.org> | 2017-08-31 21:43:45 +0000 |
| commit | a3b9fe6acdf60b91b460358858daf57bdb88bdbd (patch) | |
| tree | 35418c04a71ff8f058c3aa479cca1966b9d036b9 /llvm/test | |
| parent | 67419e39475f20e6b3164206f3233a0b1db896bf (diff) | |
| download | bcm5719-llvm-a3b9fe6acdf60b91b460358858daf57bdb88bdbd.tar.gz bcm5719-llvm-a3b9fe6acdf60b91b460358858daf57bdb88bdbd.zip | |
[WebAssembly] Validate exports when parsing object files
Subscribers: jfb, dschuff, jgravelle-google, aheejin
Differential Revision: https://reviews.llvm.org/D37358
llvm-svn: 312286
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/ObjectYAML/wasm/export_section.yaml | 14 | ||||
| -rw-r--r-- | llvm/test/ObjectYAML/wasm/invalid_export.yaml | 13 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-nm/wasm/exports.yaml | 19 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-nm/wasm/weak-symbols.yaml | 19 |
4 files changed, 65 insertions, 0 deletions
diff --git a/llvm/test/ObjectYAML/wasm/export_section.yaml b/llvm/test/ObjectYAML/wasm/export_section.yaml index 89ebee32824..8c5f57c2992 100644 --- a/llvm/test/ObjectYAML/wasm/export_section.yaml +++ b/llvm/test/ObjectYAML/wasm/export_section.yaml @@ -3,6 +3,20 @@ FileHeader: Version: 0x00000001 Sections: + - Type: FUNCTION + FunctionTypes: [ 0, 0 ] + - Type: GLOBAL + Globals: + - Type: I32 + Mutable: false + InitExpr: + Opcode: I64_CONST + Value: 32 + - Type: I32 + Mutable: false + InitExpr: + Opcode: I64_CONST + Value: 64 - Type: EXPORT Exports: - Name: function_export diff --git a/llvm/test/ObjectYAML/wasm/invalid_export.yaml b/llvm/test/ObjectYAML/wasm/invalid_export.yaml new file mode 100644 index 00000000000..a61f8c4cfde --- /dev/null +++ b/llvm/test/ObjectYAML/wasm/invalid_export.yaml @@ -0,0 +1,13 @@ +# RUN: yaml2obj < %s | not obj2yaml 2>&1 | FileCheck %s + +--- !WASM +FileHeader: + Version: 0x00000001 +Sections: + - Type: EXPORT + Exports: + - Name: invalid_function_index + Kind: FUNCTION + Index: 0x00000001 + +# CHECK: Error reading file: <stdin>: Invalid function export diff --git a/llvm/test/tools/llvm-nm/wasm/exports.yaml b/llvm/test/tools/llvm-nm/wasm/exports.yaml index c8cb2db0db7..6d2f12d1feb 100644 --- a/llvm/test/tools/llvm-nm/wasm/exports.yaml +++ b/llvm/test/tools/llvm-nm/wasm/exports.yaml @@ -12,6 +12,25 @@ Sections: - ReturnType: I32 ParamTypes: - I32 + - Type: FUNCTION + FunctionTypes: [ 0, 0, 0, 0, 0 ] + - Type: GLOBAL + Globals: + - Type: I32 + Mutable: false + InitExpr: + Opcode: I64_CONST + Value: 32 + - Type: I32 + Mutable: false + InitExpr: + Opcode: I64_CONST + Value: 64 + - Type: I32 + Mutable: false + InitExpr: + Opcode: I64_CONST + Value: 1024 - Type: EXPORT Exports: - Name: foo diff --git a/llvm/test/tools/llvm-nm/wasm/weak-symbols.yaml b/llvm/test/tools/llvm-nm/wasm/weak-symbols.yaml index d46ca1afe8e..b0796d607e5 100644 --- a/llvm/test/tools/llvm-nm/wasm/weak-symbols.yaml +++ b/llvm/test/tools/llvm-nm/wasm/weak-symbols.yaml @@ -12,6 +12,8 @@ Sections: - ReturnType: I32 ParamTypes: - I32 + - Type: FUNCTION + FunctionTypes: [ 0, 0, 0, 0 ] - Type: IMPORT Imports: - Module: env @@ -23,6 +25,23 @@ Sections: Kind: GLOBAL GlobalType: I32 GlobalMutable: false + - Type: GLOBAL + Globals: + - Type: I32 + Mutable: false + InitExpr: + Opcode: I64_CONST + Value: 32 + - Type: I32 + Mutable: false + InitExpr: + Opcode: I64_CONST + Value: 64 + - Type: I32 + Mutable: false + InitExpr: + Opcode: I64_CONST + Value: 1024 - Type: EXPORT Exports: - Name: weak_global_func |

