From 70d35e102ef8dbba10e2db84ea2dcbe95bbbfd38 Mon Sep 17 00:00:00 2001 From: Spyridoula Gravani Date: Mon, 31 Jul 2017 18:01:16 +0000 Subject: [DWARF] Added verification check for tags in accelerator tables. This patch verifies that the atom tag is actually the same with the tag of the DIE that we retrieve from the table. Differential Revision: https://reviews.llvm.org/D35963 llvm-svn: 309596 --- llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp') diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp index 9ae7c9a07f7..f17b00e5605 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -73,6 +73,8 @@ bool DWARFAcceleratorTable::validateForms() { DWARFFormValue FormValue(Atom.second); switch (Atom.first) { case dwarf::DW_ATOM_die_offset: + case dwarf::DW_ATOM_die_tag: + case dwarf::DW_ATOM_type_flags: if ((!FormValue.isFormClass(DWARFFormValue::FC_Constant) && !FormValue.isFormClass(DWARFFormValue::FC_Flag)) || FormValue.getForm() == dwarf::DW_FORM_sdata) @@ -84,8 +86,10 @@ bool DWARFAcceleratorTable::validateForms() { return true; } -uint32_t DWARFAcceleratorTable::readAtoms(uint32_t &HashDataOffset) { +std::pair +DWARFAcceleratorTable::readAtoms(uint32_t &HashDataOffset) { uint32_t DieOffset = dwarf::DW_INVALID_OFFSET; + dwarf::Tag DieTag = dwarf::DW_TAG_null; for (auto Atom : getAtomsDesc()) { DWARFFormValue FormValue(Atom.second); @@ -94,11 +98,14 @@ uint32_t DWARFAcceleratorTable::readAtoms(uint32_t &HashDataOffset) { case dwarf::DW_ATOM_die_offset: DieOffset = *FormValue.getAsUnsignedConstant(); break; + case dwarf::DW_ATOM_die_tag: + DieTag = (dwarf::Tag)*FormValue.getAsUnsignedConstant(); + break; default: break; } } - return DieOffset; + return {DieOffset, DieTag}; } LLVM_DUMP_METHOD void DWARFAcceleratorTable::dump(raw_ostream &OS) const { -- cgit v1.2.3