diff options
author | James Henderson <jh7370@my.bristol.ac.uk> | 2020-01-03 13:59:46 +0000 |
---|---|---|
committer | James Henderson <james.henderson@sony.com> | 2020-01-27 15:32:41 +0000 |
commit | f1be770ff6886a145db08b63397e8ddb6ac59bd0 (patch) | |
tree | edc08d4ebb798949efd08ee48d0786ac1500cf5c /llvm/lib | |
parent | ac0b9b4ccf3e356061f66f54b99588bc71071e73 (diff) | |
download | llvm-f1be770ff6886a145db08b63397e8ddb6ac59bd0.zip llvm-f1be770ff6886a145db08b63397e8ddb6ac59bd0.tar.gz llvm-f1be770ff6886a145db08b63397e8ddb6ac59bd0.tar.bz2 |
[DebugInfo] Make incorrect debug line extended opcode length non-fatal
It is possible to try to keep parsing a debug line program even when the
length of an extended opcode does not match what is expected for that
opcode. This patch changes what was previously a fatal error to be
non-fatal. The parser now continues by assuming the the claimed length
is correct, even if it means moving the offset backwards.
Reviewed by: dblaikie
Differential Revision: https://reviews.llvm.org/D72155
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index 2eceadb..b97753e 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -685,13 +685,18 @@ Error DWARFDebugLine::LineTable::parse( (*OffsetPtr) += Len - 1; break; } - // Make sure the stated and parsed lengths are the same. - // Otherwise we have an unparseable line-number program. - if (*OffsetPtr - ExtOffset != Len) - return createStringError(errc::illegal_byte_sequence, - "unexpected line op length at offset 0x%8.8" PRIx64 - " expected 0x%2.2" PRIx64 " found 0x%2.2" PRIx64, - ExtOffset, Len, *OffsetPtr - ExtOffset); + // Make sure the length as recorded in the table and the standard length + // for the opcode match. If they don't, continue from the end as claimed + // by the table. + uint64_t End = ExtOffset + Len; + if (*OffsetPtr != End) { + RecoverableErrorCallback(createStringError( + errc::illegal_byte_sequence, + "unexpected line op length at offset 0x%8.8" PRIx64 + " expected 0x%2.2" PRIx64 " found 0x%2.2" PRIx64, + ExtOffset, Len, *OffsetPtr - ExtOffset)); + *OffsetPtr = End; + } } else if (Opcode < Prologue.OpcodeBase) { if (OS) *OS << LNStandardString(Opcode); |