diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-04-28 10:24:40 -0700 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-04-28 10:25:34 -0700 |
commit | 3e4a16d2cbfe147399342bc34f81ecd6b980718d (patch) | |
tree | 577d1d1082df2397a4eee0bfe25fac0f23c1f878 /llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp | |
parent | cbaa74a0981833537e88a8eeac9c9df0f528833c (diff) | |
download | llvm-3e4a16d2cbfe147399342bc34f81ecd6b980718d.zip llvm-3e4a16d2cbfe147399342bc34f81ecd6b980718d.tar.gz llvm-3e4a16d2cbfe147399342bc34f81ecd6b980718d.tar.bz2 |
[llvm/DebugInfo] Fix invalid verifier error for DWARF5
We unconditionally compared the DW_AT_ranges offset to the length of the
.debug_ranges section. For DWARF5 we should look at the debug_rnglists
section instead.
Differential revision: https://reviews.llvm.org/D78971
Diffstat (limited to 'llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp')
-rw-r--r-- | llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp index 2caf6ca..c4a466f 100644 --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -2013,6 +2013,44 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRanges) { "error: DW_AT_ranges offset is beyond .debug_ranges bounds: 0x00001000"); } +TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRnglists) { + // Create a single compile unit with a DW_AT_ranges whose section offset + // isn't valid. + const char *yamldata = R"( + debug_str: + - '' + - /tmp/main.c + debug_abbrev: + - Code: 0x00000001 + Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_ranges + Form: DW_FORM_sec_offset + debug_info: + - Length: + TotalLength: 17 + Version: 5 + UnitType: DW_UT_compile + AbbrOffset: 0 + AddrSize: 8 + Entries: + - AbbrCode: 0x00000001 + Values: + - Value: 0x0000000000000001 + - Value: 0x0000000000001000 + + )"; + auto ErrOrSections = DWARFYAML::EmitDebugSections(StringRef(yamldata)); + ASSERT_TRUE((bool)ErrOrSections); + std::unique_ptr<DWARFContext> DwarfContext = + DWARFContext::create(*ErrOrSections, 8); + VerifyError(*DwarfContext, "error: DW_AT_ranges offset is beyond " + ".debug_rnglists bounds: 0x00001000"); +} + TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStmtList) { // Create a single compile unit with a DW_AT_stmt_list whose section offset // isn't valid. |