[PATCH] D98589: [llvm] [dwarf] Fix DWARFListTableHeader::getOffsetEntry off-by-one
Jan Kratochvil via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 14 13:43:43 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa28facba1ccd: [llvm] [dwarf] Fix DWARFListTableHeader::getOffsetEntry off-by-one (authored by jankratochvil).
Changed prior to commit:
https://reviews.llvm.org/D98589?vs=330472&id=330529#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98589/new/
https://reviews.llvm.org/D98589
Files:
llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp
Index: llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp
===================================================================
--- llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFListTableTest.cpp
@@ -73,4 +73,30 @@
EXPECT_EQ(Header.length(), 6u);
}
+TEST(DWARFListTableHeader, OffsetEntryCount) {
+ static const char SecData[] = "\x10\x00\x00\x00" // Length
+ "\x05\x00" // Version
+ "\x08" // Address size
+ "\x00" // Segment selector size
+ "\x01\x00\x00\x00" // Offset entry count
+ "\x04\x00\x00\x00" // offset[0]
+ "\x04" // DW_RLE_offset_pair
+ "\x01" // ULEB128 starting offset
+ "\x02" // ULEB128 ending offset
+ "\x00"; // DW_RLE_end_of_list
+ DWARFDataExtractor Extractor(StringRef(SecData, sizeof(SecData) - 1),
+ /*isLittleEndian=*/true,
+ /*AddrSize=*/4);
+ DWARFListTableHeader Header(/*SectionName=*/".debug_rnglists",
+ /*ListTypeString=*/"range");
+ uint64_t Offset = 0;
+ EXPECT_FALSE(!!Header.extract(Extractor, &Offset));
+ Optional<uint64_t> Offset0 = Header.getOffsetEntry(Extractor, 0);
+ EXPECT_TRUE(!!Offset0);
+ EXPECT_EQ(Offset0, uint64_t(4));
+ Optional<uint64_t> Offset1 = Header.getOffsetEntry(Extractor, 1);
+ EXPECT_FALSE(!!Offset1);
+ EXPECT_EQ(Header.length(), sizeof(SecData) - 1);
+}
+
} // end anonymous namespace
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
@@ -113,7 +113,7 @@
void dump(DataExtractor Data, raw_ostream &OS,
DIDumpOptions DumpOpts = {}) const;
Optional<uint64_t> getOffsetEntry(DataExtractor Data, uint32_t Index) const {
- if (Index > HeaderData.OffsetEntryCount)
+ if (Index >= HeaderData.OffsetEntryCount)
return None;
return getOffsetEntry(Data, getHeaderOffset() + getHeaderSize(Format), Format, Index);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98589.330529.patch
Type: text/x-patch
Size: 2408 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210314/279b16ff/attachment.bin>
More information about the llvm-commits
mailing list