llvm.org GIT mirror llvm / f4f71cd
[ObjectYAML] Fix issue with DWARF2 AddrSize 8 In my refactoring I introduced a bug where we were using the reference size instead of the offset size for DW_FORM_strp and similar forms. This patch resolves the error and adds a test case testing all the DWARF forms for DWARF2 AddrSize 8. There is similar coverage already in the DWARFDebugInfoTest sources that covers the parser. Once I migrate the DWARFGenerator APIs to be built on the YAML tools they will be fully covered under the same tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297230 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Bieneman 2 years ago
2 changed file(s) with 513 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
3333 }
3434 }
3535
36 unsigned getOffsetSize(const DWARFYAML::Unit &Unit) {
37 return Unit.Length.isDWARF64() ? 8 : 4;
38 }
39
3640 unsigned getRefSize(const DWARFYAML::Unit &Unit) {
3741 if (Unit.Version == 2)
3842 return Unit.AddrSize;
39 return Unit.Length.isDWARF64() ? 8 : 4;
43 return getOffsetSize(Unit);
4044 }
4145
4246 template void DWARFYAML::VisitorImpl::traverseDebugInfo() {
148152 case dwarf::DW_FORM_GNU_strp_alt:
149153 case dwarf::DW_FORM_line_strp:
150154 case dwarf::DW_FORM_strp_sup:
151 onVariableSizeValue(FormVal->Value, getRefSize(Unit));
155 onVariableSizeValue(FormVal->Value, getOffsetSize(Unit));
152156 break;
153157 case dwarf::DW_FORM_ref_sig8:
154158 onValue((uint64_t)FormVal->Value);
0 # RUN: yaml2obj %s | obj2yaml | FileCheck %s
1
2 --- !mach-o
3 FileHeader:
4 magic: 0xFEEDFACF
5 cputype: 0x01000007
6 cpusubtype: 0x00000003
7 filetype: 0x0000000A
8 ncmds: 5
9 sizeofcmds: 1800
10 flags: 0x00000000
11 reserved: 0x00000000
12 LoadCommands:
13 - cmd: LC_SEGMENT_64
14 cmdsize: 72
15 segname: __PAGEZERO
16 vmaddr: 0
17 vmsize: 4294967296
18 fileoff: 0
19 filesize: 0
20 maxprot: 0
21 initprot: 0
22 nsects: 0
23 flags: 0
24 - cmd: LC_SEGMENT_64
25 cmdsize: 472
26 segname: __TEXT
27 vmaddr: 4294967296
28 vmsize: 4096
29 fileoff: 0
30 filesize: 0
31 maxprot: 7
32 initprot: 5
33 nsects: 5
34 flags: 0
35 Sections:
36 - sectname: __text
37 segname: __TEXT
38 addr: 0x0000000100000F50
39 size: 52
40 offset: 0x00000000
41 align: 4
42 reloff: 0x00000000
43 nreloc: 0
44 flags: 0x80000400
45 reserved1: 0x00000000
46 reserved2: 0x00000000
47 reserved3: 0x00000000
48 - sectname: __stubs
49 segname: __TEXT
50 addr: 0x0000000100000F84
51 size: 6
52 offset: 0x00000000
53 align: 1
54 reloff: 0x00000000
55 nreloc: 0
56 flags: 0x80000408
57 reserved1: 0x00000000
58 reserved2: 0x00000006
59 reserved3: 0x00000000
60 - sectname: __stub_helper
61 segname: __TEXT
62 addr: 0x0000000100000F8C
63 size: 26
64 offset: 0x00000000
65 align: 2
66 reloff: 0x00000000
67 nreloc: 0
68 flags: 0x80000400
69 reserved1: 0x00000000
70 reserved2: 0x00000000
71 reserved3: 0x00000000
72 - sectname: __cstring
73 segname: __TEXT
74 addr: 0x0000000100000FA6
75 size: 14
76 offset: 0x00000000
77 align: 0
78 reloff: 0x00000000
79 nreloc: 0
80 flags: 0x00000002
81 reserved1: 0x00000000
82 reserved2: 0x00000000
83 reserved3: 0x00000000
84 - sectname: __unwind_info
85 segname: __TEXT
86 addr: 0x0000000100000FB4
87 size: 72
88 offset: 0x00000000
89 align: 2
90 reloff: 0x00000000
91 nreloc: 0
92 flags: 0x00000000
93 reserved1: 0x00000000
94 reserved2: 0x00000000
95 reserved3: 0x00000000
96 - cmd: LC_SEGMENT_64
97 cmdsize: 232
98 segname: __DATA
99 vmaddr: 4294971392
100 vmsize: 4096
101 fileoff: 0
102 filesize: 0
103 maxprot: 7
104 initprot: 3
105 nsects: 2
106 flags: 0
107 Sections:
108 - sectname: __nl_symbol_ptr
109 segname: __DATA
110 addr: 0x0000000100001000
111 size: 16
112 offset: 0x00000000
113 align: 3
114 reloff: 0x00000000
115 nreloc: 0
116 flags: 0x00000006
117 reserved1: 0x00000001
118 reserved2: 0x00000000
119 reserved3: 0x00000000
120 - sectname: __la_symbol_ptr
121 segname: __DATA
122 addr: 0x0000000100001010
123 size: 8
124 offset: 0x00000000
125 align: 3
126 reloff: 0x00000000
127 nreloc: 0
128 flags: 0x00000007
129 reserved1: 0x00000003
130 reserved2: 0x00000000
131 reserved3: 0x00000000
132 - cmd: LC_SEGMENT_64
133 cmdsize: 72
134 segname: __LINKEDIT
135 vmaddr: 4294975488
136 vmsize: 4096
137 fileoff: 4096
138 filesize: 60
139 maxprot: 7
140 initprot: 1
141 nsects: 0
142 flags: 0
143 - cmd: LC_SEGMENT_64
144 cmdsize: 952
145 segname: __DWARF
146 vmaddr: 4294979584
147 vmsize: 4096
148 fileoff: 8192
149 filesize: 764
150 maxprot: 7
151 initprot: 3
152 nsects: 11
153 flags: 0
154 Sections:
155 - sectname: __debug_line
156 segname: __DWARF
157 addr: 0x0000000100003000
158 size: 69
159 offset: 0x00002000
160 align: 0
161 reloff: 0x00000000
162 nreloc: 0
163 flags: 0x00000000
164 reserved1: 0x00000000
165 reserved2: 0x00000000
166 reserved3: 0x00000000
167 - sectname: __debug_pubnames
168 segname: __DWARF
169 addr: 0x0000000100003045
170 size: 27
171 offset: 0x00002045
172 align: 0
173 reloff: 0x00000000
174 nreloc: 0
175 flags: 0x00000000
176 reserved1: 0x00000000
177 reserved2: 0x00000000
178 reserved3: 0x00000000
179 - sectname: __debug_pubtypes
180 segname: __DWARF
181 addr: 0x0000000100003060
182 size: 35
183 offset: 0x00002060
184 align: 0
185 reloff: 0x00000000
186 nreloc: 0
187 flags: 0x00000000
188 reserved1: 0x00000000
189 reserved2: 0x00000000
190 reserved3: 0x00000000
191 - sectname: __debug_aranges
192 segname: __DWARF
193 addr: 0x0000000100003083
194 size: 48
195 offset: 0x00002083
196 align: 0
197 reloff: 0x00000000
198 nreloc: 0
199 flags: 0x00000000
200 reserved1: 0x00000000
201 reserved2: 0x00000000
202 reserved3: 0x00000000
203 - sectname: __debug_info
204 segname: __DWARF
205 addr: 0x00000001000030B3
206 size: 180
207 offset: 0x000020B3
208 align: 0
209 reloff: 0x00000000
210 nreloc: 0
211 flags: 0x00000000
212 reserved1: 0x00000000
213 reserved2: 0x00000000
214 reserved3: 0x00000000
215 - sectname: __debug_abbrev
216 segname: __DWARF
217 addr: 0x000000010000312C
218 size: 84
219 offset: 0x00002167
220 align: 0
221 reloff: 0x00000000
222 nreloc: 0
223 flags: 0x00000000
224 reserved1: 0x00000000
225 reserved2: 0x00000000
226 reserved3: 0x00000000
227 - sectname: __debug_str
228 segname: __DWARF
229 addr: 0x0000000100003178
230 size: 83
231 offset: 0x000021BB
232 align: 0
233 reloff: 0x00000000
234 nreloc: 0
235 flags: 0x00000000
236 reserved1: 0x00000000
237 reserved2: 0x00000000
238 reserved3: 0x00000000
239 - sectname: __apple_names
240 segname: __DWARF
241 addr: 0x0000000100003206
242 size: 36
243 offset: 0x0000221E
244 align: 0
245 reloff: 0x00000000
246 nreloc: 0
247 flags: 0x00000000
248 reserved1: 0x00000000
249 reserved2: 0x00000000
250 reserved3: 0x00000000
251 - sectname: __apple_namespac
252 segname: __DWARF
253 addr: 0x0000000100003242
254 size: 36
255 offset: 0x00002242
256 align: 0
257 reloff: 0x00000000
258 nreloc: 0
259 flags: 0x00000000
260 reserved1: 0x00000000
261 reserved2: 0x00000000
262 reserved3: 0x00000000
263 - sectname: __apple_types
264 segname: __DWARF
265 addr: 0x0000000100003266
266 size: 114
267 offset: 0x00002266
268 align: 0
269 reloff: 0x00000000
270 nreloc: 0
271 flags: 0x00000000
272 reserved1: 0x00000000
273 reserved2: 0x00000000
274 reserved3: 0x00000000
275 - sectname: __apple_objc
276 segname: __DWARF
277 addr: 0x00000001000032D8
278 size: 36
279 offset: 0x000022D8
280 align: 0
281 reloff: 0x00000000
282 nreloc: 0
283 flags: 0x00000000
284 reserved1: 0x00000000
285 reserved2: 0x00000000
286 reserved3: 0x00000000
287 DWARF:
288 debug_str:
289 - World
290 debug_abbrev:
291 - Code: 0x00000001
292 Tag: DW_TAG_compile_unit
293 Children: DW_CHILDREN_no
294 Attributes:
295 - Attribute: 0x2000
296 Form: DW_FORM_addr
297 - Attribute: 0x2001
298 Form: DW_FORM_block
299 - Attribute: DW_AT_MIPS_loop_begin
300 Form: DW_FORM_block1
301 - Attribute: DW_AT_MIPS_tail_loop_begin
302 Form: DW_FORM_block2
303 - Attribute: DW_AT_MIPS_epilog_begin
304 Form: DW_FORM_block4
305 - Attribute: DW_AT_MIPS_loop_unroll_factor
306 Form: DW_FORM_data1
307 - Attribute: DW_AT_MIPS_software_pipeline_depth
308 Form: DW_FORM_data2
309 - Attribute: DW_AT_MIPS_linkage_name
310 Form: DW_FORM_data4
311 - Attribute: DW_AT_MIPS_stride
312 Form: DW_FORM_data8
313 - Attribute: DW_AT_MIPS_abstract_name
314 Form: DW_FORM_string
315 - Attribute: DW_AT_MIPS_clone_origin
316 Form: DW_FORM_strp
317 - Attribute: DW_AT_MIPS_has_inlines
318 Form: DW_FORM_ref_addr
319 - Attribute: DW_AT_MIPS_stride_byte
320 Form: DW_FORM_ref1
321 - Attribute: DW_AT_MIPS_stride_elem
322 Form: DW_FORM_ref2
323 - Attribute: DW_AT_MIPS_ptr_dopetype
324 Form: DW_FORM_ref4
325 - Attribute: DW_AT_MIPS_allocatable_dopetype
326 Form: DW_FORM_ref8
327 - Attribute: DW_AT_MIPS_assumed_shape_dopetype
328 Form: DW_FORM_ref_sig8
329 - Attribute: DW_AT_MIPS_assumed_size
330 Form: DW_FORM_ref_udata
331 - Attribute: 0x2012
332 Form: DW_FORM_flag
333 - Attribute: 0x2013
334 Form: DW_FORM_flag
335 - Attribute: 0x2014
336 Form: DW_FORM_flag_present
337 - Attribute: 0x2015
338 Form: DW_FORM_sdata
339 - Attribute: 0x2017
340 Form: DW_FORM_udata
341 - Attribute: 0x2018
342 Form: DW_FORM_GNU_ref_alt
343 - Attribute: 0x2019
344 Form: DW_FORM_sec_offset
345 - Attribute: 0x201A
346 Form: DW_FORM_addr
347 debug_info:
348 - Length:
349 TotalLength: 168
350 Version: 2
351 AbbrOffset: 0
352 AddrSize: 8
353 Entries:
354 - AbbrCode: 0x00000001
355 Values:
356 - Value: 0x0123456789ABCDEF
357 - Value: 0x000000000000000A
358 BlockData:
359 - 0x01
360 - 0x02
361 - 0x03
362 - 0x04
363 - 0x05
364 - 0x06
365 - 0x07
366 - 0x08
367 - 0x09
368 - 0x00
369 - Value: 0x000000000000000A
370 BlockData:
371 - 0x01
372 - 0x02
373 - 0x03
374 - 0x04
375 - 0x05
376 - 0x06
377 - 0x07
378 - 0x08
379 - 0x09
380 - 0x00
381 - Value: 0x000000000000000A
382 BlockData:
383 - 0x01
384 - 0x02
385 - 0x03
386 - 0x04
387 - 0x05
388 - 0x06
389 - 0x07
390 - 0x08
391 - 0x09
392 - 0x00
393 - Value: 0x000000000000000A
394 BlockData:
395 - 0x01
396 - 0x02
397 - 0x03
398 - 0x04
399 - 0x05
400 - 0x06
401 - 0x07
402 - 0x08
403 - 0x09
404 - 0x00
405 - Value: 0x0000000000000001
406 - Value: 0x0000000000002345
407 - Value: 0x000000006789ABCD
408 - Value: 0x0011223344556677
409 - Value: 0x0000000000000000
410 CStr: Hello
411 - Value: 0x0000000000000000
412 - Value: 0x0000000012345678
413 - Value: 0x0000000000000001
414 - Value: 0x0000000000002345
415 - Value: 0x000000006789ABCD
416 - Value: 0x0011223344556677
417 - Value: 0xAABBCCDDEEFF0011
418 - Value: 0xFFFFFFFFFFFFFFFE
419 - Value: 0x0000000000000001
420 - Value: 0x0000000000000000
421 - Value: 0x0000000000000001
422 - Value: 0x8000000000000000
423 - Value: 0xFFFFFFFFFFFFFFFE
424 - Value: 0x0000000000000001
425 - Value: 0x0000000000000002
426 - Value: 0x0123456789ABCDEF
427 ...
428
429 #CHECK: debug_info:
430 #CHECK: - Length:
431 #CHECK: TotalLength: 168
432 #CHECK: Version: 2
433 #CHECK: AbbrOffset: 0
434 #CHECK: AddrSize: 8
435 #CHECK: Entries:
436 #CHECK: - AbbrCode: 0x00000001
437 #CHECK: Values:
438 #CHECK: - Value: 0x0123456789ABCDEF
439 #CHECK: - Value: 0x000000000000000A
440 #CHECK: BlockData:
441 #CHECK: - 0x01
442 #CHECK: - 0x02
443 #CHECK: - 0x03
444 #CHECK: - 0x04
445 #CHECK: - 0x05
446 #CHECK: - 0x06
447 #CHECK: - 0x07
448 #CHECK: - 0x08
449 #CHECK: - 0x09
450 #CHECK: - 0x00
451 #CHECK: - Value: 0x000000000000000A
452 #CHECK: BlockData:
453 #CHECK: - 0x01
454 #CHECK: - 0x02
455 #CHECK: - 0x03
456 #CHECK: - 0x04
457 #CHECK: - 0x05
458 #CHECK: - 0x06
459 #CHECK: - 0x07
460 #CHECK: - 0x08
461 #CHECK: - 0x09
462 #CHECK: - 0x00
463 #CHECK: - Value: 0x000000000000000A
464 #CHECK: BlockData:
465 #CHECK: - 0x01
466 #CHECK: - 0x02
467 #CHECK: - 0x03
468 #CHECK: - 0x04
469 #CHECK: - 0x05
470 #CHECK: - 0x06
471 #CHECK: - 0x07
472 #CHECK: - 0x08
473 #CHECK: - 0x09
474 #CHECK: - 0x00
475 #CHECK: - Value: 0x000000000000000A
476 #CHECK: BlockData:
477 #CHECK: - 0x01
478 #CHECK: - 0x02
479 #CHECK: - 0x03
480 #CHECK: - 0x04
481 #CHECK: - 0x05
482 #CHECK: - 0x06
483 #CHECK: - 0x07
484 #CHECK: - 0x08
485 #CHECK: - 0x09
486 #CHECK: - 0x00
487 #CHECK: - Value: 0x0000000000000001
488 #CHECK: - Value: 0x0000000000002345
489 #CHECK: - Value: 0x000000006789ABCD
490 #CHECK: - Value: 0x0011223344556677
491 #CHECK: CStr: Hello
492 #CHECK: - Value: 0x0000000000000000
493 #CHECK: - Value: 0x0000000012345678
494 #CHECK: - Value: 0x0000000000000001
495 #CHECK: - Value: 0x0000000000002345
496 #CHECK: - Value: 0x000000006789ABCD
497 #CHECK: - Value: 0x0011223344556677
498 #CHECK: - Value: 0xAABBCCDDEEFF0011
499 #CHECK: - Value: 0xFFFFFFFFFFFFFFFE
500 #CHECK: - Value: 0x0000000000000001
501 #CHECK: - Value: 0x0000000000000000
502 #CHECK: - Value: 0x0000000000000001
503 #CHECK: - Value: 0xFFFFFFFFFFFFFFFE
504 #CHECK: - Value: 0x0000000000000001
505 #CHECK: - Value: 0x0000000000000002
506 #CHECK: - Value: 0x0123456789ABCDEF