[lld] 5279f96 - [MachO] Fix detecting malformed DWARF.
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 17 00:03:50 PST 2019
Author: Igor Kudrin
Date: 2019-12-17T15:03:23+07:00
New Revision: 5279f96577af1457a973c071ec5ee3554c9f6cbe
URL: https://github.com/llvm/llvm-project/commit/5279f96577af1457a973c071ec5ee3554c9f6cbe
DIFF: https://github.com/llvm/llvm-project/commit/5279f96577af1457a973c071ec5ee3554c9f6cbe.diff
LOG: [MachO] Fix detecting malformed DWARF.
This fixes an invalid constant used to detect the reserved range when
reading the compilation unit header. See also: D64622 and D65039.
Differential Revision: https://reviews.llvm.org/D71546
Added:
Modified:
lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
Removed:
################################################################################
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
index 0163c90189fd..6f294b1ecd0f 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -879,11 +879,11 @@ readCompUnit(const NormalizedFile &normalizedFile,
llvm::dwarf::DwarfFormat Format = llvm::dwarf::DwarfFormat::DWARF32;
auto infoData = dataExtractorFromSection(normalizedFile, info);
uint32_t length = infoData.getU32(&offset);
- if (length == 0xffffffff) {
+ if (length == llvm::dwarf::DW_LENGTH_DWARF64) {
Format = llvm::dwarf::DwarfFormat::DWARF64;
infoData.getU64(&offset);
}
- else if (length > 0xffffff00)
+ else if (length >= llvm::dwarf::DW_LENGTH_lo_reserved)
return llvm::make_error<GenericError>("Malformed DWARF in " + path);
uint16_t version = infoData.getU16(&offset);
More information about the llvm-commits
mailing list