From: Sam Clegg Date: Tue, 25 Apr 2017 17:11:56 +0000 (+0000) Subject: [WebAssembly] Read global index in init expression as LEB X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2854ea835f72ca6adceeb66fdbe5432175c3ec69;p=llvm [WebAssembly] Read global index in init expression as LEB Subscribers: jfb, dschuff Differential Revision: https://reviews.llvm.org/D32462 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301330 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Object/WasmObjectFile.cpp b/lib/Object/WasmObjectFile.cpp index 5b254b2957a..e1b3c4e1f39 100644 --- a/lib/Object/WasmObjectFile.cpp +++ b/lib/Object/WasmObjectFile.cpp @@ -144,7 +144,7 @@ static Error readInitExpr(wasm::WasmInitExpr &Expr, const uint8_t *&Ptr) { Expr.Value.Float64 = readFloat64(Ptr); break; case wasm::WASM_OPCODE_GET_GLOBAL: - Expr.Value.Global = readUint32(Ptr); + Expr.Value.Global = readULEB128(Ptr); break; default: return make_error("Invalid opcode in init_expr", diff --git a/lib/ObjectYAML/WasmYAML.cpp b/lib/ObjectYAML/WasmYAML.cpp index 3e1bed19d61..1c7c07ae29e 100644 --- a/lib/ObjectYAML/WasmYAML.cpp +++ b/lib/ObjectYAML/WasmYAML.cpp @@ -294,6 +294,9 @@ void MappingTraits::mapping(IO &IO, case wasm::WASM_OPCODE_F64_CONST: IO.mapRequired("Value", Expr.Value.Float64); break; + case wasm::WASM_OPCODE_GET_GLOBAL: + IO.mapRequired("Index", Expr.Value.Global); + break; } } diff --git a/test/ObjectYAML/wasm/elem_section.yaml b/test/ObjectYAML/wasm/elem_section.yaml index 498c9aa93ea..c55e94ce2d0 100644 --- a/test/ObjectYAML/wasm/elem_section.yaml +++ b/test/ObjectYAML/wasm/elem_section.yaml @@ -18,8 +18,8 @@ Sections: Functions: - 1 - Offset: - Opcode: I32_CONST - Value: 5 + Opcode: GET_GLOBAL + Index: 1 Functions: - 4 ... @@ -34,7 +34,7 @@ Sections: # CHECK: Value: 3 # CHECK: Functions: [ 1 ] # CHECK: - Offset: -# CHECK: Opcode: I32_CONST -# CHECK: Value: 5 +# CHECK: Opcode: GET_GLOBAL +# CHECK: Index: 1 # CHECK: Functions: [ 4 ] # CHECK: ...