diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:12:03 +0000 |
| commit | c9157d925c489f07ba9c0b2ce47e5149b75969a5 (patch) | |
| tree | 08bc4a3d9cad3f9ebffa558ddf140b9d9257b219 /contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp | |
| parent | 2a66844f606a35d68ad8a8061f4bea204274b3bc (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; } |
