diff options
author | George Rimar <grimar@accesssoftek.com> | 2017-10-27 10:42:04 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2017-10-27 10:42:04 +0000 |
commit | 144e4c5a32007bb2fe7b18930dcc4d806ef4f92f (patch) | |
tree | 8b87dd498dd0b4639bcfd9fc4c3dd7f2f74c57ee /llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp | |
parent | 7f92294e9b6a00784d75587800f409af23072983 (diff) | |
download | bcm5719-llvm-144e4c5a32007bb2fe7b18930dcc4d806ef4f92f.tar.gz bcm5719-llvm-144e4c5a32007bb2fe7b18930dcc4d806ef4f92f.zip |
[llvm-dwarfdump] - Teach verifier to report broken DWARF expressions.
Patch improves next things:
* Fixes assert/crash in getOpDesc when giving it a invalid expression op code.
* DWARFExpression::print() called DWARFExpression::Operation::getEndOffset() which
returned and used uninitialized field EndOffset. Patch fixes that.
* Teaches verifier to verify DW_AT_location and error out on broken expressions.
Differential revision: https://reviews.llvm.org/D39294
llvm-svn: 316756
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp index 3417fee14c0..16058e461f4 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp @@ -104,7 +104,9 @@ static DescVector getDescriptions() { static DWARFExpression::Operation::Description getOpDesc(unsigned OpCode) { // FIXME: Make this constexpr once all compilers are smart enough to do it. static DescVector Descriptions = getDescriptions(); - assert(OpCode < Descriptions.size()); + // Handle possible corrupted or unsupported operation. + if (OpCode >= Descriptions.size()) + return {}; return Descriptions[OpCode]; } @@ -117,8 +119,10 @@ bool DWARFExpression::Operation::extract(DataExtractor Data, uint16_t Version, Opcode = Data.getU8(&Offset); Desc = getOpDesc(Opcode); - if (Desc.Version == Operation::DwarfNA) + if (Desc.Version == Operation::DwarfNA) { + EndOffset = Offset; return false; + } for (unsigned Operand = 0; Operand < 2; ++Operand) { unsigned Size = Desc.Op[Operand]; @@ -221,7 +225,7 @@ bool DWARFExpression::Operation::print(raw_ostream &OS, const MCRegisterInfo *RegInfo, bool isEH) { if (Error) { - OS << "decoding error."; + OS << "<decoding error>"; return false; } |