[PATCH] D75117: [DWARF] Use getInitialLength in range list parsing
Pavel Labath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 02:30:49 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG164e2c851230: [DWARF] Use getInitialLength in range list parsing (authored by labath).
Changed prior to commit:
https://reviews.llvm.org/D75117?vs=246464&id=247578#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75117/new/
https://reviews.llvm.org/D75117
Files:
llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_invalid.s
llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_reserved_length.s
Index: llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_reserved_length.s
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_reserved_length.s
+++ llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_reserved_length.s
@@ -2,7 +2,7 @@
# RUN: llvm-dwarfdump --debug-rnglists - 2>&1 | \
# RUN: FileCheck %s --implicit-check-not=error
-# CHECK: error: .debug_rnglists table at offset 0x0 has unsupported reserved unit length of value 0xfffffff0
+# CHECK: error: parsing .debug_rnglists table at offset 0x0: unsupported reserved unit length of value 0xfffffff0
.section .debug_rnglists,"", at progbits
.long 0xfffffff0
Index: llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_invalid.s
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_invalid.s
+++ llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_invalid.s
@@ -2,7 +2,7 @@
# RUN: llvm-dwarfdump --debug-rnglists - 2>&1 | FileCheck %s --check-prefix=SHORT
# SHORT-NOT: error:
# SHORT-NOT: range list header
-# SHORT: error: section is not large enough to contain a .debug_rnglists table length at offset 0
+# SHORT: error: parsing .debug_rnglists table at offset 0x0: unexpected end of data at offset 0x0
# SHORT-NOT: range list header
# SHORT-NOT: error:
Index: llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
@@ -18,25 +18,15 @@
Error DWARFListTableHeader::extract(DWARFDataExtractor Data,
uint64_t *OffsetPtr) {
HeaderOffset = *OffsetPtr;
- // Read and verify the length field.
- if (!Data.isValidOffsetForDataOfSize(*OffsetPtr, sizeof(uint32_t)))
- return createStringError(errc::invalid_argument,
- "section is not large enough to contain a "
- "%s table length at offset 0x%" PRIx64,
- SectionName.data(), *OffsetPtr);
- Format = dwarf::DwarfFormat::DWARF32;
- uint8_t OffsetByteSize = 4;
- HeaderData.Length = Data.getRelocatedValue(4, OffsetPtr);
- if (HeaderData.Length == dwarf::DW_LENGTH_DWARF64) {
- Format = dwarf::DwarfFormat::DWARF64;
- OffsetByteSize = 8;
- HeaderData.Length = Data.getU64(OffsetPtr);
- } else if (HeaderData.Length >= dwarf::DW_LENGTH_lo_reserved) {
- return createStringError(errc::invalid_argument,
- "%s table at offset 0x%" PRIx64
- " has unsupported reserved unit length of value 0x%8.8" PRIx64,
- SectionName.data(), HeaderOffset, HeaderData.Length);
- }
+ Error Err = Error::success();
+
+ std::tie(HeaderData.Length, Format) = Data.getInitialLength(OffsetPtr, &Err);
+ if (Err)
+ return createStringError(
+ errc::invalid_argument, "parsing %s table at offset 0x%" PRIx64 ": %s",
+ SectionName.data(), HeaderOffset, toString(std::move(Err)).c_str());
+
+ uint8_t OffsetByteSize = Format == dwarf::DWARF64 ? 8 : 4;
uint64_t FullLength =
HeaderData.Length + dwarf::getUnitLengthFieldByteSize(Format);
assert(FullLength == length());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75117.247578.patch
Type: text/x-patch
Size: 3222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200302/b5e97ac8/attachment-0001.bin>
More information about the llvm-commits
mailing list