Skip to content

Commit

Permalink
[WebAssembly] Read global index in init expression as LEB
Browse files Browse the repository at this point in the history
Subscribers: jfb, dschuff

Differential Revision: https://reviews.llvm.org/D32462

llvm-svn: 301330
  • Loading branch information
sbc100 committed Apr 25, 2017
1 parent 0b650d3 commit 7fb391f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Object/WasmObjectFile.cpp
Expand Up @@ -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<GenericBinaryError>("Invalid opcode in init_expr",
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/ObjectYAML/WasmYAML.cpp
Expand Up @@ -294,6 +294,9 @@ void MappingTraits<wasm::WasmInitExpr>::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;
}
}

Expand Down
8 changes: 4 additions & 4 deletions llvm/test/ObjectYAML/wasm/elem_section.yaml
Expand Up @@ -18,8 +18,8 @@ Sections:
Functions:
- 1
- Offset:
Opcode: I32_CONST
Value: 5
Opcode: GET_GLOBAL
Index: 1
Functions:
- 4
...
Expand All @@ -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: ...

0 comments on commit 7fb391f

Please sign in to comment.