Skip to content

Commit d7795ec

Browse files
Merge pull request swiftlang#7942 from rastogishubham/VerifyFix
Cherry-pick PR llvm#77004 from llvm.org/main to stable/20230725
2 parents 22c7b7d + df020c6 commit d7795ec

File tree

2 files changed

+363
-2
lines changed

2 files changed

+363
-2
lines changed

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,13 @@ void DWARFVerifier::verifyDebugLineRows() {
940940
OS << '\n';
941941
}
942942

943-
// Verify file index.
944-
if (!LineTable->hasFileAtIndex(Row.File)) {
943+
// If the prologue contains no file names and the line table has only one
944+
// row, do not verify the file index, this is a line table of an empty
945+
// file with an end_sequence, but the DWARF standard sets the file number
946+
// to 1 by default, otherwise verify file index.
947+
if ((LineTable->Prologue.FileNames.size() ||
948+
LineTable->Rows.size() != 1) &&
949+
!LineTable->hasFileAtIndex(Row.File)) {
945950
++NumDebugLineErrors;
946951
error() << ".debug_line["
947952
<< format("0x%08" PRIx64,
Lines changed: 356 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,356 @@
1+
# RUN: yaml2obj %s -o %t.o
2+
# RUN: llvm-dwarfdump -arch arm64 --debug-line --verify %t.o 2>&1 | FileCheck %s
3+
# REQUIRES: system-darwin
4+
5+
# CHECK-NOT: error: .debug_line[0x{{[0-9a-f]+}}][0] has invalid file index 1 (valid values are [1,0]):
6+
--- !mach-o
7+
FileHeader:
8+
magic: 0xFEEDFACF
9+
cputype: 0x100000C
10+
cpusubtype: 0x0
11+
filetype: 0x1
12+
ncmds: 4
13+
sizeofcmds: 1000
14+
flags: 0x2000
15+
reserved: 0x0
16+
LoadCommands:
17+
- cmd: LC_SEGMENT_64
18+
cmdsize: 872
19+
segname: ''
20+
vmaddr: 0
21+
vmsize: 635
22+
fileoff: 1032
23+
filesize: 635
24+
maxprot: 7
25+
initprot: 7
26+
nsects: 10
27+
flags: 0
28+
Sections:
29+
- sectname: __text
30+
segname: __TEXT
31+
addr: 0x0
32+
size: 4
33+
offset: 0x408
34+
align: 2
35+
reloff: 0x0
36+
nreloc: 0
37+
flags: 0x80000400
38+
reserved1: 0x0
39+
reserved2: 0x0
40+
reserved3: 0x0
41+
content: C0035FD6
42+
- sectname: __debug_abbrev
43+
segname: __DWARF
44+
addr: 0x4
45+
size: 50
46+
offset: 0x40C
47+
align: 0
48+
reloff: 0x0
49+
nreloc: 0
50+
flags: 0x2000000
51+
reserved1: 0x0
52+
reserved2: 0x0
53+
reserved3: 0x0
54+
- sectname: __debug_info
55+
segname: __DWARF
56+
addr: 0x36
57+
size: 76
58+
offset: 0x43E
59+
align: 0
60+
reloff: 0x688
61+
nreloc: 2
62+
flags: 0x2000000
63+
reserved1: 0x0
64+
reserved2: 0x0
65+
reserved3: 0x0
66+
relocations:
67+
- address: 0x33
68+
symbolnum: 1
69+
pcrel: false
70+
length: 3
71+
extern: false
72+
type: 0
73+
scattered: false
74+
value: 0
75+
- address: 0x26
76+
symbolnum: 1
77+
pcrel: false
78+
length: 3
79+
extern: false
80+
type: 0
81+
scattered: false
82+
value: 0
83+
- sectname: __debug_str
84+
segname: __DWARF
85+
addr: 0x82
86+
size: 196
87+
offset: 0x48A
88+
align: 0
89+
reloff: 0x0
90+
nreloc: 0
91+
flags: 0x2000000
92+
reserved1: 0x0
93+
reserved2: 0x0
94+
reserved3: 0x0
95+
- sectname: __apple_names
96+
segname: __DWARF
97+
addr: 0x146
98+
size: 88
99+
offset: 0x54E
100+
align: 0
101+
reloff: 0x0
102+
nreloc: 0
103+
flags: 0x2000000
104+
reserved1: 0x0
105+
reserved2: 0x0
106+
reserved3: 0x0
107+
content: 485341480100000002000000020000000C000000000000000100000001000600FFFFFFFF000000008973880BEB28616A3800000048000000B8000000010000003200000000000000BC000000010000003200000000000000
108+
- sectname: __apple_objc
109+
segname: __DWARF
110+
addr: 0x19E
111+
size: 36
112+
offset: 0x5A6
113+
align: 0
114+
reloff: 0x0
115+
nreloc: 0
116+
flags: 0x2000000
117+
reserved1: 0x0
118+
reserved2: 0x0
119+
reserved3: 0x0
120+
content: 485341480100000001000000000000000C000000000000000100000001000600FFFFFFFF
121+
- sectname: __apple_namespac
122+
segname: __DWARF
123+
addr: 0x1C2
124+
size: 36
125+
offset: 0x5CA
126+
align: 0
127+
reloff: 0x0
128+
nreloc: 0
129+
flags: 0x2000000
130+
reserved1: 0x0
131+
reserved2: 0x0
132+
reserved3: 0x0
133+
content: 485341480100000001000000000000000C000000000000000100000001000600FFFFFFFF
134+
- sectname: __apple_types
135+
segname: __DWARF
136+
addr: 0x1E6
137+
size: 44
138+
offset: 0x5EE
139+
align: 0
140+
reloff: 0x0
141+
nreloc: 0
142+
flags: 0x2000000
143+
reserved1: 0x0
144+
reserved2: 0x0
145+
reserved3: 0x0
146+
content: 48534148010000000100000000000000140000000000000003000000010006000300050004000B00FFFFFFFF
147+
- sectname: __compact_unwind
148+
segname: __LD
149+
addr: 0x218
150+
size: 32
151+
offset: 0x620
152+
align: 3
153+
reloff: 0x698
154+
nreloc: 1
155+
flags: 0x2000000
156+
reserved1: 0x0
157+
reserved2: 0x0
158+
reserved3: 0x0
159+
content: '0000000000000000040000000000000200000000000000000000000000000000'
160+
relocations:
161+
- address: 0x0
162+
symbolnum: 1
163+
pcrel: false
164+
length: 3
165+
extern: false
166+
type: 0
167+
scattered: false
168+
value: 0
169+
- sectname: __debug_line
170+
segname: __DWARF
171+
addr: 0x238
172+
size: 67
173+
offset: 0x640
174+
align: 0
175+
reloff: 0x6A0
176+
nreloc: 1
177+
flags: 0x2000000
178+
reserved1: 0x0
179+
reserved2: 0x0
180+
reserved3: 0x0
181+
relocations:
182+
- address: 0x35
183+
symbolnum: 1
184+
pcrel: false
185+
length: 3
186+
extern: false
187+
type: 0
188+
scattered: false
189+
value: 0
190+
- cmd: LC_BUILD_VERSION
191+
cmdsize: 24
192+
platform: 1
193+
minos: 917504
194+
sdk: 918528
195+
ntools: 0
196+
- cmd: LC_SYMTAB
197+
cmdsize: 24
198+
symoff: 1704
199+
nsyms: 3
200+
stroff: 1752
201+
strsize: 24
202+
- cmd: LC_DYSYMTAB
203+
cmdsize: 80
204+
ilocalsym: 0
205+
nlocalsym: 2
206+
iextdefsym: 2
207+
nextdefsym: 1
208+
iundefsym: 3
209+
nundefsym: 0
210+
tocoff: 0
211+
ntoc: 0
212+
modtaboff: 0
213+
nmodtab: 0
214+
extrefsymoff: 0
215+
nextrefsyms: 0
216+
indirectsymoff: 0
217+
nindirectsyms: 0
218+
extreloff: 0
219+
nextrel: 0
220+
locreloff: 0
221+
nlocrel: 0
222+
LinkEditData:
223+
NameList:
224+
- n_strx: 16
225+
n_type: 0xE
226+
n_sect: 1
227+
n_desc: 0
228+
n_value: 0
229+
- n_strx: 10
230+
n_type: 0xE
231+
n_sect: 9
232+
n_desc: 0
233+
n_value: 536
234+
- n_strx: 1
235+
n_type: 0xF
236+
n_sect: 1
237+
n_desc: 0
238+
n_value: 0
239+
StringTable:
240+
- ''
241+
- __Z3foov
242+
- ltmp1
243+
- ltmp0
244+
- ''
245+
- ''
246+
DWARF:
247+
debug_str:
248+
- 'Apple clang version 16.0.0 (clang-1600.0.9.14)'
249+
- '/tmp/test.cpp'
250+
- '/Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk'
251+
- MacOSX14.4.sdk
252+
- '/Users/shubham/Development/llvm-project/build_ninja'
253+
- foo
254+
- _Z3foov
255+
debug_abbrev:
256+
- ID: 0
257+
Table:
258+
- Code: 0x1
259+
Tag: DW_TAG_compile_unit
260+
Children: DW_CHILDREN_yes
261+
Attributes:
262+
- Attribute: DW_AT_producer
263+
Form: DW_FORM_strp
264+
- Attribute: DW_AT_language
265+
Form: DW_FORM_data2
266+
- Attribute: DW_AT_name
267+
Form: DW_FORM_strp
268+
- Attribute: DW_AT_LLVM_sysroot
269+
Form: DW_FORM_strp
270+
- Attribute: DW_AT_APPLE_sdk
271+
Form: DW_FORM_strp
272+
- Attribute: DW_AT_stmt_list
273+
Form: DW_FORM_sec_offset
274+
- Attribute: DW_AT_comp_dir
275+
Form: DW_FORM_strp
276+
- Attribute: DW_AT_low_pc
277+
Form: DW_FORM_addr
278+
- Attribute: DW_AT_high_pc
279+
Form: DW_FORM_data4
280+
- Code: 0x2
281+
Tag: DW_TAG_subprogram
282+
Children: DW_CHILDREN_no
283+
Attributes:
284+
- Attribute: DW_AT_low_pc
285+
Form: DW_FORM_addr
286+
- Attribute: DW_AT_high_pc
287+
Form: DW_FORM_data4
288+
- Attribute: DW_AT_APPLE_omit_frame_ptr
289+
Form: DW_FORM_flag_present
290+
- Attribute: DW_AT_frame_base
291+
Form: DW_FORM_exprloc
292+
- Attribute: DW_AT_linkage_name
293+
Form: DW_FORM_strp
294+
- Attribute: DW_AT_name
295+
Form: DW_FORM_strp
296+
- Attribute: DW_AT_decl_file
297+
Form: DW_FORM_data1
298+
- Attribute: DW_AT_decl_line
299+
Form: DW_FORM_data1
300+
- Attribute: DW_AT_external
301+
Form: DW_FORM_flag_present
302+
debug_info:
303+
- Length: 0x48
304+
Version: 4
305+
AbbrevTableID: 0
306+
AbbrOffset: 0x0
307+
AddrSize: 8
308+
Entries:
309+
- AbbrCode: 0x1
310+
Values:
311+
- Value: 0x0
312+
- Value: 0x4
313+
- Value: 0x2F
314+
- Value: 0x3D
315+
- Value: 0x75
316+
- Value: 0x0
317+
- Value: 0x84
318+
- Value: 0x0
319+
- Value: 0x4
320+
- AbbrCode: 0x2
321+
Values:
322+
- Value: 0x0
323+
- Value: 0x4
324+
- Value: 0x1
325+
- Value: 0x1
326+
BlockData: [ 0x6F ]
327+
- Value: 0xBC
328+
- Value: 0xB8
329+
- Value: 0x1
330+
- Value: 0x1
331+
- Value: 0x1
332+
- AbbrCode: 0x0
333+
debug_line:
334+
- Length: 38
335+
Version: 4
336+
PrologueLength: 29
337+
MinInstLength: 1
338+
MaxOpsPerInst: 1
339+
DefaultIsStmt: 1
340+
LineBase: 251
341+
LineRange: 14
342+
OpcodeBase: 13
343+
StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
344+
IncludeDirs:
345+
- '/tmp'
346+
Files:
347+
- Name: ''
348+
DirIdx: 10
349+
ModTime: 11
350+
Length: 12
351+
Opcodes:
352+
- Opcode: DW_LNS_extended_op
353+
ExtLen: 1
354+
SubOpcode: DW_LNE_end_sequence
355+
Data: 0
356+
...

0 commit comments

Comments
 (0)