diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -362,6 +362,10 @@ return version == 2 || version == 3 || version == 4 || version == 5; } + static bool isAddressSizeSupported(unsigned AddressSize) { + return AddressSize == 2 || AddressSize == 4 || AddressSize == 8; + } + std::shared_ptr getDWOContext(StringRef AbsolutePath); const MCRegisterInfo *getRegisterInfo() const { return RegInfo.get(); } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -300,7 +300,7 @@ TypeOffset < getLength() + getUnitLengthFieldByteSize(); bool LengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1); bool VersionOK = DWARFContext::isSupportedVersion(getVersion()); - bool AddrSizeOK = getAddressByteSize() == 4 || getAddressByteSize() == 8; + bool AddrSizeOK = DWARFContext::isAddressSizeSupported(getAddressByteSize()); if (!LengthOK || !VersionOK || !AddrSizeOK || !TypeOffsetOK) return false; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -133,7 +133,7 @@ ValidLength = DebugInfoData.isValidOffset(OffsetStart + Length + 3); ValidVersion = DWARFContext::isSupportedVersion(Version); - ValidAddrSize = AddrSize == 4 || AddrSize == 8; + ValidAddrSize = DWARFContext::isAddressSizeSupported(AddrSize); if (!ValidLength || !ValidVersion || !ValidAddrSize || !ValidAbbrevOffset || !ValidType) { Success = false; diff --git a/llvm/test/DebugInfo/Inputs/dwarfdump-16bit-addr.o b/llvm/test/DebugInfo/Inputs/dwarfdump-16bit-addr.o new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@