[PATCH] D85313: [DebugInfo] Don't error for zero-length arange entries
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 07:44:22 PDT 2020
jhenderson created this revision.
jhenderson added reviewers: ikudrin, dblaikie, probinson, JDevlieghere, MaskRay, aprantl.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
jhenderson requested review of this revision.
Although the DWARF specification states that .debug_aranges entries can't have length zero, these can occur in the wild. There's no particular reason to enforce this part of the spec, since functionally they have no impact, so this patch removes the error.
Fixes https://bugs.llvm.org/show_bug.cgi?id=46805. See also https://reviews.llvm.org/D71932 which originally introduced the error.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85313
Files:
llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp
Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp
===================================================================
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugArangeSetTest.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
+#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
using namespace llvm;
@@ -168,7 +169,7 @@
TEST(DWARFDebugArangeSet, ZeroLengthEntry) {
static const char DebugArangesSecRaw[] =
- "\x24\x00\x00\x00" // Length
+ "\x2c\x00\x00\x00" // Length
"\x02\x00" // Version
"\x00\x00\x00\x00" // Debug Info Offset
"\x04" // Address Size
@@ -177,13 +178,29 @@
"\x00\x00\x00\x00" // Entry1: Address
"\x01\x00\x00\x00" // Length
"\x01\x00\x00\x00" // Entry2: Address
- "\x00\x00\x00\x00" // Length (invalid)
+ "\x00\x00\x00\x00" // Length
+ "\x00\x00\x00\x00" // Entry3: Address
+ "\x00\x00\x00\x00" // Length
"\x00\x00\x00\x00" // Termination tuple
"\x00\x00\x00\x00";
- ExpectExtractError(
- DebugArangesSecRaw,
- "address range table at offset 0x0 has an invalid tuple (length = 0) "
- "at offset 0x18");
+ DWARFDataExtractor Extractor(
+ StringRef(DebugArangesSecRaw, sizeof(DebugArangesSecRaw) - 1),
+ /*IsLittleEndian=*/true,
+ /*AddressSize=*/4);
+ DWARFDebugArangeSet Set;
+ uint64_t Offset = 0;
+ ASSERT_THAT_ERROR(Set.extract(Extractor, &Offset), Succeeded());
+ auto Range = Set.descriptors();
+ auto Iter = Range.begin();
+ ASSERT_EQ(std::distance(Iter, Range.end()), 3u);
+ EXPECT_EQ(Iter->Address, 0u);
+ EXPECT_EQ(Iter->Length, 1u);
+ ++Iter;
+ EXPECT_EQ(Iter->Address, 1u);
+ EXPECT_EQ(Iter->Length, 0u);
+ ++Iter;
+ EXPECT_EQ(Iter->Address, 0u);
+ EXPECT_EQ(Iter->Length, 0u);
}
} // end anonymous namespace
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
@@ -140,11 +140,6 @@
// for the length.
if (arangeDescriptor.Address == 0 && *offset_ptr == end_offset)
return ErrorSuccess();
- return createStringError(
- errc::invalid_argument,
- "address range table at offset 0x%" PRIx64
- " has an invalid tuple (length = 0) at offset 0x%" PRIx64,
- Offset, *offset_ptr - tuple_size);
}
ArangeDescriptors.push_back(arangeDescriptor);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85313.283237.patch
Type: text/x-patch
Size: 2718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200805/66f51da6/attachment.bin>
More information about the llvm-commits
mailing list