diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-06 20:11:55 +0000 |
commit | 5f757f3ff9144b609b3c433dfd370cc6bdc191ad (patch) | |
tree | 1b4e980b866cd26a00af34c0a653eb640bd09caf /contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp | |
parent | 3e1c8a35f741a5d114d0ba670b15191355711fe9 (diff) | |
parent | 312c0ed19cc5276a17bacf2120097bec4515b0f1 (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp b/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp index 11b9b579a8d7..168fb57935d6 100644 --- a/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp +++ b/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp @@ -723,17 +723,21 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) { Info.Name = readString(Ctx); if (IsDefined) { auto Index = readVaruint32(Ctx); - if (Index >= DataSegments.size()) - return make_error<GenericBinaryError>("invalid data symbol index", - object_error::parse_failed); auto Offset = readVaruint64(Ctx); auto Size = readVaruint64(Ctx); - size_t SegmentSize = DataSegments[Index].Data.Content.size(); - if (Offset > SegmentSize) - return make_error<GenericBinaryError>( - "invalid data symbol offset: `" + Info.Name + "` (offset: " + - Twine(Offset) + " segment size: " + Twine(SegmentSize) + ")", - object_error::parse_failed); + if (!(Info.Flags & wasm::WASM_SYMBOL_ABSOLUTE)) { + if (static_cast<size_t>(Index) >= DataSegments.size()) + return make_error<GenericBinaryError>( + "invalid data segment index: " + Twine(Index), + object_error::parse_failed); + size_t SegmentSize = DataSegments[Index].Data.Content.size(); + if (Offset > SegmentSize) + return make_error<GenericBinaryError>( + "invalid data symbol offset: `" + Info.Name + + "` (offset: " + Twine(Offset) + + " segment size: " + Twine(SegmentSize) + ")", + object_error::parse_failed); + } Info.DataRef = wasm::WasmDataReference{Index, Offset, Size}; } break; @@ -1088,7 +1092,7 @@ Error WasmObjectFile::parseCustomSection(WasmSection &Sec, ReadContext &Ctx) { } else if (Sec.Name == "target_features") { if (Error Err = parseTargetFeaturesSection(Ctx)) return Err; - } else if (Sec.Name.startswith("reloc.")) { + } else if (Sec.Name.starts_with("reloc.")) { if (Error Err = parseRelocSection(Sec.Name, Ctx)) return Err; } |