1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[DebugInfo] Remove redundant checks for past-the-end of prologue

The V5 directory and filename tables had checks in to make sure we
hadn't read past the end of the line table prologue. Since previous
changes to the data extractor class ensure we never read past the end,
these checks are now redundant, so this patch removes them.

There is still a check to show that the whole prologue remains within
the prologue length.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D71768
This commit is contained in:
James Henderson 2019-12-20 15:13:29 +00:00
parent 9f4f919c40
commit 1824e10eb4
2 changed files with 16 additions and 35 deletions

View File

@ -196,14 +196,6 @@ parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr,
int FormatCount = DebugLineData.getU8(OffsetPtr);
bool HasPath = false;
for (int I = 0; I != FormatCount; ++I) {
if (*OffsetPtr >= EndPrologueOffset)
return createStringError(
errc::invalid_argument,
"failed to parse entry content descriptions at offset "
"0x%8.8" PRIx64
" because offset extends beyond the prologue end at offset "
"0x%8.8" PRIx64,
*OffsetPtr, EndPrologueOffset);
ContentDescriptor Descriptor;
Descriptor.Type =
dwarf::LineNumberEntryFormat(DebugLineData.getULEB128(OffsetPtr));
@ -239,14 +231,6 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
// Get the directory entries, according to the format described above.
int DirEntryCount = DebugLineData.getU8(OffsetPtr);
for (int I = 0; I != DirEntryCount; ++I) {
if (*OffsetPtr >= EndPrologueOffset)
return createStringError(
errc::invalid_argument,
"failed to parse directory entry at offset "
"0x%8.8" PRIx64
" because offset extends beyond the prologue end at offset "
"0x%8.8" PRIx64,
*OffsetPtr, EndPrologueOffset);
for (auto Descriptor : *DirDescriptors) {
DWARFFormValue Value(Descriptor.Form);
switch (Descriptor.Type) {
@ -275,14 +259,6 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
// Get the file entries, according to the format described above.
int FileEntryCount = DebugLineData.getU8(OffsetPtr);
for (int I = 0; I != FileEntryCount; ++I) {
if (*OffsetPtr >= EndPrologueOffset)
return createStringError(
errc::invalid_argument,
"failed to parse file entry at offset "
"0x%8.8" PRIx64
" because offset extends beyond the prologue end at offset "
"0x%8.8" PRIx64,
*OffsetPtr, EndPrologueOffset);
DWARFDebugLine::FileNameEntry FileEntry;
for (auto Descriptor : *FileDescriptors) {
DWARFFormValue Value(Descriptor.Form);

View File

@ -113,27 +113,35 @@
# NONFATAL: debug_line[0x000001ad]
# NONFATAL-NEXT: Line table prologue
# NONFATAL: standard_opcode_lengths[DW_LNS_set_isa] = 1
# NONFATAL-NOT: include_directories
# NONFATAL-NOT: file_names
# NONFATAL-NEXT: include_directories[ 0] = "/tmp"
# NONFATAL-NEXT: file_names[ 0]:
# NONFATAL-NEXT: name: "a.c"
# NONFATAL-NEXT: dir_index: 1
# NONFATAL-NOT: Address
## Case 9: V5 prologue ends during file table.
# NONFATAL: debug_line[0x000001ed]
# NONFATAL-NEXT: Line table prologue
# NONFATAL: include_directories[ 0] = "/tmp"
# NONFATAL-NOT: file_names
# NONFATAL-NEXT: file_names[ 0]:
# NONFATAL-NEXT: name: "a.c"
# NONFATAL-NEXT: dir_index: 1
# NONFATAL-NOT: Address
## Case 10: V5 prologue ends during directory table.
# NONFATAL: debug_line[0x0000022d]
# NONFATAL-NEXT: Line table prologue
# NONFATAL-NOT: include_directories
# NONFATAL-NOT: file_names
# NONFATAL: include_directories[ 0] = "/tmp"
# NONFATAL-NEXT: file_names[ 0]:
# NONFATAL-NEXT: name: "a.c"
# NONFATAL-NEXT: dir_index: 1
# NONFATAL-NOT: Address
## Case 11: V5 invalid MD5 hash form.
# NONFATAL: debug_line[0x0000026d]
# NONFATAL-NEXT: Line table prologue
# NONFATAL: include_directories[ 0] = "/tmp"
# NONFATAL-NOT: file_names
# NONFATAL-NOT: Address
# LAST: debug_line[0x000002af]
@ -151,12 +159,9 @@
# ALL-NEXT: warning: parsing line table prologue at 0x000000c9 should have ended at 0x00000104 but it ended at 0x00000103
# OTHER-NEXT: warning: unexpected line op length at offset 0x00000158 expected 0x02 found 0x01
# OTHER-NEXT: warning: last sequence in debug line table is not terminated!
# ALL-NEXT: warning: parsing line table prologue at 0x000001ad found an invalid directory or file table description at 0x000001cc
# ALL-NEXT: warning: failed to parse entry content descriptions at offset 0x000001cc because offset extends beyond the prologue end at offset 0x000001c8
# ALL-NEXT: warning: parsing line table prologue at 0x000001ed found an invalid directory or file table description at 0x0000021a
# ALL-NEXT: warning: failed to parse file entry at offset 0x0000021a because offset extends beyond the prologue end at offset 0x00000218
# ALL-NEXT: warning: parsing line table prologue at 0x0000022d found an invalid directory or file table description at 0x0000024f
# ALL-NEXT: warning: failed to parse directory entry at offset 0x0000024f because offset extends beyond the prologue end at offset 0x0000024f
# ALL-NEXT: warning: parsing line table prologue at 0x000001ad should have ended at 0x000001c8 but it ended at 0x000001df
# ALL-NEXT: warning: parsing line table prologue at 0x000001ed should have ended at 0x00000218 but it ended at 0x0000021f
# ALL-NEXT: warning: parsing line table prologue at 0x0000022d should have ended at 0x0000024f but it ended at 0x0000025f
# ALL-NEXT: warning: parsing line table prologue at 0x0000026d found an invalid directory or file table description at 0x000002a2
# ALL-NEXT: warning: failed to parse file entry because the MD5 hash is invalid
# ALL-NOT: warning: