Skip to content

Commit 71aaebc

Browse files
committed
[DWARF5][DWARFVerifier] Check that Skeleton compilation unit does not have children.
That patch adds checking into DWARFVerifier that the Skeleton compilation unit does not have children. Differential Revision: https://reviews.llvm.org/D71244
1 parent f8ff3bf commit 71aaebc

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ unsigned DWARFVerifier::verifyUnitContents(DWARFUnit &Unit) {
196196
NumUnitErrors++;
197197
}
198198

199+
// According to DWARF Debugging Information Format Version 5,
200+
// 3.1.2 Skeleton Compilation Unit Entries:
201+
// "A skeleton compilation unit has no children."
202+
if (Die.getTag() == dwarf::DW_TAG_skeleton_unit && Die.hasChildren()) {
203+
error() << "Skeleton compilation unit has children.\n";
204+
NumUnitErrors++;
205+
}
206+
199207
DieRangeInfo RI;
200208
NumUnitErrors += verifyDieRanges(Die, RI);
201209

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
2+
# RUN: not llvm-dwarfdump --verify %t.o | FileCheck %s
3+
4+
# CHECK: Verifying .debug_abbrev...
5+
# CHECK-NEXT: Verifying .debug_info Unit Header Chain...
6+
# CHECK-NEXT: error: Skeleton compilation unit has children.
7+
# CHECK-NEXT: Verifying .debug_info references...
8+
# CHECK-NEXT: Verifying .debug_types Unit Header Chain...
9+
# CHECK-NEXT: Errors detected.
10+
11+
.section .debug_abbrev,"",@progbits
12+
.byte 1 # Abbreviation Code
13+
.byte 74 # DW_TAG_skeleton_unit
14+
.byte 0 # DW_CHILDREN_no
15+
.byte 0 # EOM(1)
16+
.byte 0 # EOM(2)
17+
.byte 2 # Abbreviation Code
18+
.byte 74 # DW_TAG_skeleton_unit
19+
.byte 1 # DW_CHILDREN_yes
20+
.byte 0 # EOM(1)
21+
.byte 0 # EOM(2)
22+
.byte 0 # EOM(3)
23+
24+
.section .debug_info,"",@progbits
25+
.Lcu_begin0:
26+
.long .Lcu_end0-.Lcu_start0 # Length of Unit
27+
.Lcu_start0:
28+
.short 5 # DWARF version number
29+
.byte 4 # DWARF Unit Type
30+
.byte 8 # Address Size (in bytes)
31+
.long .debug_abbrev # Offset Into Abbrev. Section
32+
.quad -6573227469967412476
33+
.byte 1 # Abbrev [1]
34+
.byte 0
35+
.Lcu_end0:
36+
.long .Lcu_end1-.Lcu_start1 # Length of Unit
37+
.Lcu_start1:
38+
.short 5 # DWARF version number
39+
.byte 4 # DWARF Unit Type
40+
.byte 8 # Address Size (in bytes)
41+
.long .debug_abbrev # Offset Into Abbrev. Section
42+
.quad -6573227469967412476
43+
.byte 2 # Abbrev [2]
44+
.byte 0
45+
.Lcu_end1:
46+
47+

0 commit comments

Comments
 (0)