diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2024-01-24 19:17:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:24:44 +0000 |
commit | ab50317e96e57dee5b3ff4ad3f16f205b2a3359e (patch) | |
tree | 4b1f388eb6a07e574417aaacecd3ec4a83550718 /contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp | |
parent | 412542983a5ba62902141a8a7e155cceb9196a66 (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp b/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp index 94cd96968ff2..b9a8e970216b 100644 --- a/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp +++ b/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp @@ -258,7 +258,7 @@ static wasm::WasmLimits readLimits(WasmObjectFile::ReadContext &Ctx) { static wasm::WasmTableType readTableType(WasmObjectFile::ReadContext &Ctx) { wasm::WasmTableType TableType; - TableType.ElemType = readUint8(Ctx); + TableType.ElemType = wasm::ValType(readVaruint32(Ctx)); TableType.Limits = readLimits(Ctx); return TableType; } @@ -1163,8 +1163,8 @@ Error WasmObjectFile::parseImportSection(ReadContext &Ctx) { Im.Table = readTableType(Ctx); NumImportedTables++; auto ElemType = Im.Table.ElemType; - if (ElemType != wasm::WASM_TYPE_FUNCREF && - ElemType != wasm::WASM_TYPE_EXTERNREF) + if (ElemType != wasm::ValType::FUNCREF && + ElemType != wasm::ValType::EXTERNREF) return make_error<GenericBinaryError>("invalid table element type", object_error::parse_failed); break; @@ -1220,8 +1220,8 @@ Error WasmObjectFile::parseTableSection(ReadContext &Ctx) { T.Index = NumImportedTables + Tables.size(); Tables.push_back(T); auto ElemType = Tables.back().Type.ElemType; - if (ElemType != wasm::WASM_TYPE_FUNCREF && - ElemType != wasm::WASM_TYPE_EXTERNREF) { + if (ElemType != wasm::ValType::FUNCREF && + ElemType != wasm::ValType::EXTERNREF) { return make_error<GenericBinaryError>("invalid table element type", object_error::parse_failed); } @@ -1534,21 +1534,22 @@ Error WasmObjectFile::parseElemSection(ReadContext &Ctx) { } if (Segment.Flags & wasm::WASM_ELEM_SEGMENT_MASK_HAS_ELEM_KIND) { - Segment.ElemKind = readUint8(Ctx); + auto ElemKind = readVaruint32(Ctx); if (Segment.Flags & wasm::WASM_ELEM_SEGMENT_HAS_INIT_EXPRS) { - if (Segment.ElemKind != uint8_t(wasm::ValType::FUNCREF) && - Segment.ElemKind != uint8_t(wasm::ValType::EXTERNREF)) { + Segment.ElemKind = wasm::ValType(ElemKind); + if (Segment.ElemKind != wasm::ValType::FUNCREF && + Segment.ElemKind != wasm::ValType::EXTERNREF) { return make_error<GenericBinaryError>("invalid reference type", object_error::parse_failed); } } else { - if (Segment.ElemKind != 0) + if (ElemKind != 0) return make_error<GenericBinaryError>("invalid elemtype", object_error::parse_failed); - Segment.ElemKind = uint8_t(wasm::ValType::FUNCREF); + Segment.ElemKind = wasm::ValType::FUNCREF; } } else { - Segment.ElemKind = uint8_t(wasm::ValType::FUNCREF); + Segment.ElemKind = wasm::ValType::FUNCREF; } if (Segment.Flags & wasm::WASM_ELEM_SEGMENT_HAS_INIT_EXPRS) |