1## This file contains test cases for generating a DAWRFv4 .debug_info
2## section in object files from the DWARF entry of Mach-O YAML inputs.
3
4## a) Test that yaml2obj emits a DWARF32 .debug_info sections and obj2yaml
5## converts it back.
6
7# RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s --check-prefix=DWARF32
8
9--- !mach-o
10FileHeader:
11  magic:           0xFEEDFACF
12  cputype:         0x01000007
13  cpusubtype:      0x00000003
14  filetype:        0x0000000A
15  ncmds:           5
16  sizeofcmds:      1800
17  flags:           0x00000000
18  reserved:        0x00000000
19LoadCommands:
20  - cmd:             LC_SEGMENT_64
21    cmdsize:         72
22    segname:         __PAGEZERO
23    vmaddr:          0
24    vmsize:          4294967296
25    fileoff:         0
26    filesize:        0
27    maxprot:         0
28    initprot:        0
29    nsects:          0
30    flags:           0
31  - cmd:             LC_SEGMENT_64
32    cmdsize:         472
33    segname:         __TEXT
34    vmaddr:          4294967296
35    vmsize:          4096
36    fileoff:         0
37    filesize:        0
38    maxprot:         7
39    initprot:        5
40    nsects:          5
41    flags:           0
42    Sections:
43      - sectname:        __text
44        segname:         __TEXT
45        addr:            0x0000000100000F50
46        size:            52
47        offset:          0x00000000
48        align:           4
49        reloff:          0x00000000
50        nreloc:          0
51        flags:           0x80000400
52        reserved1:       0x00000000
53        reserved2:       0x00000000
54        reserved3:       0x00000000
55      - sectname:        __stubs
56        segname:         __TEXT
57        addr:            0x0000000100000F84
58        size:            6
59        offset:          0x00000000
60        align:           1
61        reloff:          0x00000000
62        nreloc:          0
63        flags:           0x80000408
64        reserved1:       0x00000000
65        reserved2:       0x00000006
66        reserved3:       0x00000000
67      - sectname:        __stub_helper
68        segname:         __TEXT
69        addr:            0x0000000100000F8C
70        size:            26
71        offset:          0x00000000
72        align:           2
73        reloff:          0x00000000
74        nreloc:          0
75        flags:           0x80000400
76        reserved1:       0x00000000
77        reserved2:       0x00000000
78        reserved3:       0x00000000
79      - sectname:        __cstring
80        segname:         __TEXT
81        addr:            0x0000000100000FA6
82        size:            14
83        offset:          0x00000000
84        align:           0
85        reloff:          0x00000000
86        nreloc:          0
87        flags:           0x00000002
88        reserved1:       0x00000000
89        reserved2:       0x00000000
90        reserved3:       0x00000000
91      - sectname:        __unwind_info
92        segname:         __TEXT
93        addr:            0x0000000100000FB4
94        size:            72
95        offset:          0x00000000
96        align:           2
97        reloff:          0x00000000
98        nreloc:          0
99        flags:           0x00000000
100        reserved1:       0x00000000
101        reserved2:       0x00000000
102        reserved3:       0x00000000
103  - cmd:             LC_SEGMENT_64
104    cmdsize:         232
105    segname:         __DATA
106    vmaddr:          4294971392
107    vmsize:          4096
108    fileoff:         0
109    filesize:        0
110    maxprot:         7
111    initprot:        3
112    nsects:          2
113    flags:           0
114    Sections:
115      - sectname:        __nl_symbol_ptr
116        segname:         __DATA
117        addr:            0x0000000100001000
118        size:            16
119        offset:          0x00000000
120        align:           3
121        reloff:          0x00000000
122        nreloc:          0
123        flags:           0x00000006
124        reserved1:       0x00000001
125        reserved2:       0x00000000
126        reserved3:       0x00000000
127      - sectname:        __la_symbol_ptr
128        segname:         __DATA
129        addr:            0x0000000100001010
130        size:            8
131        offset:          0x00000000
132        align:           3
133        reloff:          0x00000000
134        nreloc:          0
135        flags:           0x00000007
136        reserved1:       0x00000003
137        reserved2:       0x00000000
138        reserved3:       0x00000000
139  - cmd:             LC_SEGMENT_64
140    cmdsize:         72
141    segname:         __LINKEDIT
142    vmaddr:          4294975488
143    vmsize:          4096
144    fileoff:         4096
145    filesize:        60
146    maxprot:         7
147    initprot:        1
148    nsects:          0
149    flags:           0
150  - cmd:             LC_SEGMENT_64
151    cmdsize:         952
152    segname:         __DWARF
153    vmaddr:          4294979584
154    vmsize:          4096
155    fileoff:         8192
156    filesize:        764
157    maxprot:         7
158    initprot:        3
159    nsects:          11
160    flags:           0
161    Sections:
162      - sectname:        __debug_line
163        segname:         __DWARF
164        addr:            0x0000000100003000
165        size:            69
166        offset:          0x00002000
167        align:           0
168        reloff:          0x00000000
169        nreloc:          0
170        flags:           0x00000000
171        reserved1:       0x00000000
172        reserved2:       0x00000000
173        reserved3:       0x00000000
174      - sectname:        __debug_pubnames
175        segname:         __DWARF
176        addr:            0x0000000100003045
177        size:            27
178        offset:          0x00002045
179        align:           0
180        reloff:          0x00000000
181        nreloc:          0
182        flags:           0x00000000
183        reserved1:       0x00000000
184        reserved2:       0x00000000
185        reserved3:       0x00000000
186      - sectname:        __debug_pubtypes
187        segname:         __DWARF
188        addr:            0x0000000100003060
189        size:            35
190        offset:          0x00002060
191        align:           0
192        reloff:          0x00000000
193        nreloc:          0
194        flags:           0x00000000
195        reserved1:       0x00000000
196        reserved2:       0x00000000
197        reserved3:       0x00000000
198      - sectname:        __debug_aranges
199        segname:         __DWARF
200        addr:            0x0000000100003083
201        size:            48
202        offset:          0x00002083
203        align:           0
204        reloff:          0x00000000
205        nreloc:          0
206        flags:           0x00000000
207        reserved1:       0x00000000
208        reserved2:       0x00000000
209        reserved3:       0x00000000
210      - sectname:        __debug_info
211        segname:         __DWARF
212        addr:            0x00000001000030B3
213        size:            121
214        offset:          0x000020B3
215        align:           0
216        reloff:          0x00000000
217        nreloc:          0
218        flags:           0x00000000
219        reserved1:       0x00000000
220        reserved2:       0x00000000
221        reserved3:       0x00000000
222      - sectname:        __debug_abbrev
223        segname:         __DWARF
224        addr:            0x000000010000312C
225        size:            76
226        offset:          0x0000212C
227        align:           0
228        reloff:          0x00000000
229        nreloc:          0
230        flags:           0x00000000
231        reserved1:       0x00000000
232        reserved2:       0x00000000
233        reserved3:       0x00000000
234      - sectname:        __debug_str
235        segname:         __DWARF
236        addr:            0x0000000100003178
237        size:            142
238        offset:          0x00002178
239        align:           0
240        reloff:          0x00000000
241        nreloc:          0
242        flags:           0x00000000
243        reserved1:       0x00000000
244        reserved2:       0x00000000
245        reserved3:       0x00000000
246      - sectname:        __apple_names
247        segname:         __DWARF
248        addr:            0x0000000100003206
249        size:            60
250        offset:          0x00002206
251        align:           0
252        reloff:          0x00000000
253        nreloc:          0
254        flags:           0x00000000
255        reserved1:       0x00000000
256        reserved2:       0x00000000
257        reserved3:       0x00000000
258      - sectname:        __apple_namespac
259        segname:         __DWARF
260        addr:            0x0000000100003242
261        size:            36
262        offset:          0x00002242
263        align:           0
264        reloff:          0x00000000
265        nreloc:          0
266        flags:           0x00000000
267        reserved1:       0x00000000
268        reserved2:       0x00000000
269        reserved3:       0x00000000
270      - sectname:        __apple_types
271        segname:         __DWARF
272        addr:            0x0000000100003266
273        size:            114
274        offset:          0x00002266
275        align:           0
276        reloff:          0x00000000
277        nreloc:          0
278        flags:           0x00000000
279        reserved1:       0x00000000
280        reserved2:       0x00000000
281        reserved3:       0x00000000
282      - sectname:        __apple_objc
283        segname:         __DWARF
284        addr:            0x00000001000032D8
285        size:            36
286        offset:          0x000022D8
287        align:           0
288        reloff:          0x00000000
289        nreloc:          0
290        flags:           0x00000000
291        reserved1:       0x00000000
292        reserved2:       0x00000000
293        reserved3:       0x00000000
294LinkEditData:
295  NameList:
296    - n_strx:          2
297      n_type:          0x0F
298      n_sect:          1
299      n_desc:          16
300      n_value:         4294967296
301    - n_strx:          22
302      n_type:          0x0F
303      n_sect:          1
304      n_desc:          0
305      n_value:         4294971216
306  StringTable:
307    - ''
308    - ''
309    - __mh_execute_header
310    - _main
311DWARF:
312  debug_abbrev:
313    - Table:
314        - Code:            0x00000001
315          Tag:             DW_TAG_compile_unit
316          Children:        DW_CHILDREN_yes
317          Attributes:
318            - Attribute:       DW_AT_producer
319              Form:            DW_FORM_strp
320            - Attribute:       DW_AT_language
321              Form:            DW_FORM_data2
322            - Attribute:       DW_AT_name
323              Form:            DW_FORM_strp
324            - Attribute:       DW_AT_stmt_list
325              Form:            DW_FORM_sec_offset
326            - Attribute:       DW_AT_comp_dir
327              Form:            DW_FORM_strp
328            - Attribute:       DW_AT_low_pc
329              Form:            DW_FORM_addr
330            - Attribute:       DW_AT_high_pc
331              Form:            DW_FORM_data4
332        - Code:            0x00000002
333          Tag:             DW_TAG_subprogram
334          Children:        DW_CHILDREN_yes
335          Attributes:
336            - Attribute:       DW_AT_low_pc
337              Form:            DW_FORM_addr
338            - Attribute:       DW_AT_high_pc
339              Form:            DW_FORM_data4
340            - Attribute:       DW_AT_frame_base
341              Form:            DW_FORM_exprloc
342            - Attribute:       DW_AT_name
343              Form:            DW_FORM_strp
344            - Attribute:       DW_AT_decl_file
345              Form:            DW_FORM_data1
346            - Attribute:       DW_AT_decl_line
347              Form:            DW_FORM_data1
348            - Attribute:       DW_AT_prototyped
349              Form:            DW_FORM_flag_present
350            - Attribute:       DW_AT_type
351              Form:            DW_FORM_ref4
352            - Attribute:       DW_AT_external
353              Form:            DW_FORM_flag_present
354        - Code:            0x00000003
355          Tag:             DW_TAG_formal_parameter
356          Children:        DW_CHILDREN_no
357          Attributes:
358            - Attribute:       DW_AT_location
359              Form:            DW_FORM_exprloc
360            - Attribute:       DW_AT_name
361              Form:            DW_FORM_strp
362            - Attribute:       DW_AT_decl_file
363              Form:            DW_FORM_data1
364            - Attribute:       DW_AT_decl_line
365              Form:            DW_FORM_data1
366            - Attribute:       DW_AT_type
367              Form:            DW_FORM_ref4
368        - Code:            0x00000004
369          Tag:             DW_TAG_base_type
370          Children:        DW_CHILDREN_no
371          Attributes:
372            - Attribute:       DW_AT_name
373              Form:            DW_FORM_strp
374            - Attribute:       DW_AT_encoding
375              Form:            DW_FORM_data1
376            - Attribute:       DW_AT_byte_size
377              Form:            DW_FORM_data1
378        - Code:            0x00000005
379          Tag:             DW_TAG_pointer_type
380          Children:        DW_CHILDREN_no
381          Attributes:
382            - Attribute:       DW_AT_type
383              Form:            DW_FORM_ref4
384  debug_aranges:
385    - Length:              44
386      Version:             2
387      CuOffset:            0
388      AddressSize:         8
389      SegmentSelectorSize: 0
390      Descriptors:
391        - Address:         0x0000000100000F50
392          Length:          52
393  debug_info:
394    - Length:          117
395      Version:         4
396      AbbrOffset:      0
397      AddrSize:        8
398      Entries:
399        - AbbrCode:        0x00000001
400          Values:
401            - Value:           0x0000000000000001
402            - Value:           0x000000000000000C
403            - Value:           0x0000000000000038
404            - Value:           0x0000000000000000
405            - Value:           0x0000000000000046
406            - Value:           0x0000000100000F50
407            - Value:           0x0000000000000034
408        - AbbrCode:        0x00000002
409          Values:
410            - Value:           0x0000000100000F50
411            - Value:           0x0000000000000034
412            - Value:           0x0000000000000001
413              BlockData:
414                - 0x56
415            - Value:           0x0000000000000076
416            - Value:           0x0000000000000001
417            - Value:           0x0000000000000003
418            - Value:           0x0000000000000001
419            - Value:           0x0000000000000060
420            - Value:           0x0000000000000001
421        - AbbrCode:        0x00000003
422          Values:
423            - Value:           0x0000000000000002
424              BlockData:
425                - 0x91
426                - 0x78
427            - Value:           0x000000000000007B
428            - Value:           0x0000000000000001
429            - Value:           0x0000000000000003
430            - Value:           0x0000000000000060
431        - AbbrCode:        0x00000003
432          Values:
433            - Value:           0x0000000000000002
434              BlockData:
435                - 0x91
436                - 0x70
437            - Value:           0x0000000000000080
438            - Value:           0x0000000000000001
439            - Value:           0x0000000000000003
440            - Value:           0x0000000000000067
441        - AbbrCode:        0x00000000
442        - AbbrCode:        0x00000004
443          Values:
444            - Value:           0x0000000000000085
445            - Value:           0x0000000000000005
446            - Value:           0x0000000000000004
447        - AbbrCode:        0x00000005
448          Values:
449            - Value:           0x000000000000006C
450        - AbbrCode:        0x00000005
451          Values:
452            - Value:           0x0000000000000071
453        - AbbrCode:        0x00000004
454          Values:
455            - Value:           0x0000000000000089
456            - Value:           0x0000000000000006
457            - Value:           0x0000000000000001
458        - AbbrCode:        0x00000000
459  debug_line:
460    - Length:          65
461      Version:         2
462      PrologueLength:  36
463      MinInstLength:   1
464      DefaultIsStmt:   1
465      LineBase:        251
466      LineRange:       14
467      OpcodeBase:      13
468      StandardOpcodeLengths:
469        - 0
470        - 1
471        - 1
472        - 1
473        - 1
474        - 0
475        - 0
476        - 0
477        - 1
478        - 0
479        - 0
480        - 1
481      Files:
482        - Name:            hello_world.c
483          DirIdx:          0
484          ModTime:         0
485          Length:          0
486      Opcodes:
487        - Opcode:          DW_LNS_extended_op
488          ExtLen:          9
489          SubOpcode:       DW_LNE_set_address
490          Data:            4294971216
491        - Opcode:          0x14
492          Data:            4294971216
493        - Opcode:          DW_LNS_set_column
494          Data:            3
495        - Opcode:          DW_LNS_set_prologue_end
496          Data:            3
497        - Opcode:          DW_LNS_const_add_pc
498          Data:            3
499        - Opcode:          0xBB
500          Data:            3
501        - Opcode:          0xBB
502          Data:            3
503        - Opcode:          DW_LNS_advance_pc
504          Data:            11
505        - Opcode:          DW_LNS_extended_op
506          ExtLen:          1
507          SubOpcode:       DW_LNE_end_sequence
508          Data:            11
509...
510...
511
512#      DWARF32: DWARF:
513#      DWARF32:   debug_info:
514# DWARF32-NEXT:     - Length:        0x75
515# DWARF32-NEXT:       Version:       4
516# DWARF32-NEXT:       AbbrevTableID: 0
517# DWARF32-NEXT:       AbbrOffset:    0
518# DWARF32-NEXT:       AddrSize:      8
519# DWARF32-NEXT:       Entries:
520# DWARF32-NEXT:         - AbbrCode: 0x1
521# DWARF32-NEXT:           Values:
522# DWARF32-NEXT:             - Value: 0x1
523# DWARF32-NEXT:             - Value: 0xC
524# DWARF32-NEXT:             - Value: 0x38
525# DWARF32-NEXT:             - Value: 0x0
526# DWARF32-NEXT:             - Value: 0x46
527# DWARF32-NEXT:             - Value: 0x100000F50
528# DWARF32-NEXT:             - Value: 0x34
529# DWARF32-NEXT:         - AbbrCode: 0x2
530# DWARF32-NEXT:           Values:
531# DWARF32-NEXT:             - Value: 0x100000F50
532# DWARF32-NEXT:             - Value: 0x34
533# DWARF32-NEXT:             - Value: 0x1
534# DWARF32-NEXT:               BlockData: [ 0x56 ]
535# DWARF32-NEXT:             - Value: 0x76
536# DWARF32-NEXT:             - Value: 0x1
537# DWARF32-NEXT:             - Value: 0x3
538# DWARF32-NEXT:             - Value: 0x1
539# DWARF32-NEXT:             - Value: 0x60
540# DWARF32-NEXT:             - Value: 0x1
541# DWARF32-NEXT:         - AbbrCode:        0x3
542# DWARF32-NEXT:           Values:
543# DWARF32-NEXT:             - Value: 0x2
544# DWARF32-NEXT:               BlockData: [ 0x91, 0x78 ]
545# DWARF32-NEXT:             - Value: 0x7B
546# DWARF32-NEXT:             - Value: 0x1
547# DWARF32-NEXT:             - Value: 0x3
548# DWARF32-NEXT:             - Value: 0x60
549# DWARF32-NEXT:         - AbbrCode: 0x3
550# DWARF32-NEXT:           Values:
551# DWARF32-NEXT:             - Value: 0x2
552# DWARF32-NEXT:               BlockData: [ 0x91, 0x70 ]
553# DWARF32-NEXT:             - Value: 0x80
554# DWARF32-NEXT:             - Value: 0x1
555# DWARF32-NEXT:             - Value: 0x3
556# DWARF32-NEXT:             - Value: 0x67
557# DWARF32-NEXT:         - AbbrCode: 0x0
558# DWARF32-NEXT:         - AbbrCode: 0x4
559# DWARF32-NEXT:           Values:
560# DWARF32-NEXT:             - Value: 0x85
561# DWARF32-NEXT:             - Value: 0x5
562# DWARF32-NEXT:             - Value: 0x4
563# DWARF32-NEXT:         - AbbrCode: 0x5
564# DWARF32-NEXT:           Values:
565# DWARF32-NEXT:             - Value: 0x6C
566# DWARF32-NEXT:         - AbbrCode: 0x5
567# DWARF32-NEXT:           Values:
568# DWARF32-NEXT:             - Value: 0x71
569# DWARF32-NEXT:         - AbbrCode: 0x4
570# DWARF32-NEXT:           Values:
571# DWARF32-NEXT:             - Value: 0x89
572# DWARF32-NEXT:             - Value: 0x6
573# DWARF32-NEXT:             - Value: 0x1
574# DWARF32-NEXT:         - AbbrCode: 0x0
575
576## b) Test that yaml2obj emits a correct unit header and obj2yaml is able to convert it back.
577
578## Test DWARF32 unit header.
579
580# RUN: yaml2obj --docnum=2 -DFORMAT=DWARF32 %s | \
581# RUN:   obj2yaml | FileCheck %s --check-prefix=DWARF32-YAML
582
583#      DWARF32-YAML: debug_info:
584# DWARF32-YAML-NEXT:   - Length:        0xC
585# DWARF32-YAML-NEXT:     Version:       4
586# DWARF32-YAML-NEXT:     AbbrevTableID: 0
587# DWARF32-YAML-NEXT:     AbbrOffset:    0
588# DWARF32-YAML-NEXT:     AddrSize:      8
589# DWARF32-YAML-NEXT:     Entries:
590# DWARF32-YAML-NEXT:       - AbbrCode: 0x1
591# DWARF32-YAML-NEXT:         Values:
592# DWARF32-YAML-NEXT:           - Value: 0x1234
593
594--- !mach-o
595FileHeader:
596  magic:      0xFEEDFACF
597  cputype:    0x01000007
598  cpusubtype: 0x00000003
599  filetype:   0x0000000A
600  ncmds:      1
601  sizeofcmds: 232
602  flags:      0x00000000
603  reserved:   0x00000000
604LoadCommands:
605  - cmd:      LC_SEGMENT_64
606    cmdsize:  232
607    segname:  __DWARF
608    vmaddr:   0x00
609    vmsize:   0x00
610    fileoff:  0x00
611    filesize: 0x00
612    maxprot:  0
613    initprot: 0
614    nsects:   2
615    flags:    0
616    Sections:
617      - sectname:  __debug_abbrev
618        segname:   __DWARF
619        addr:      0x00
620        size:      12
621        offset:    528
622        align:     0
623        reloff:    0x00000000
624        nreloc:    0
625        flags:     0x00000000
626        reserved1: 0x00000000
627        reserved2: 0x00000000
628        reserved3: 0x00000000
629      - sectname:  __debug_info
630        segname:   __DWARF
631        addr:      0x00
632        size:      0xffff
633        offset:    1070
634        align:     0
635        reloff:    0x00000000
636        nreloc:    0
637        flags:     0x00000000
638        reserved1: 0x00000000
639        reserved2: 0x00000000
640        reserved3: 0x00000000
641DWARF:
642  debug_abbrev:
643    - Table:
644        - Code:     1
645          Tag:      DW_TAG_compile_unit
646          Children: DW_CHILDREN_no
647          Attributes:
648            - Attribute: DW_AT_low_pc
649              Form:      DW_FORM_addr
650  debug_info:
651    - Format:     [[FORMAT]]
652      Length:     12
653      Version:    4
654      AbbrOffset: 0
655      AddrSize:   8
656      Entries:
657        - AbbrCode: 1
658          Values:
659            - Value: 0x1234
660
661## Test DWARF64 unit header.
662
663# RUN: yaml2obj --docnum=2 -DFORMAT=DWARF64 %s | \
664# RUN:   obj2yaml | FileCheck %s --check-prefix=DWARF64-YAML
665
666#      DWARF64-YAML: debug_info:
667# DWARF64-YAML-NEXT:   - Format:        DWARF64
668# DWARF64-YAML-NEXT:     Length:        0xC
669# DWARF64-YAML-NEXT:     Version:       4
670# DWARF64-YAML-NEXT:     AbbrevTableID: 0
671# DWARF64-YAML-NEXT:     AbbrOffset:    0
672# DWARF64-YAML-NEXT:     AddrSize:      8
673# DWARF64-YAML-NEXT:     Entries:
674# DWARF64-YAML-NEXT:       - AbbrCode: 0x1
675# DWARF64-YAML-NEXT:         Values:
676# DWARF64-YAML-NEXT:           - Value: 0x1234
677
678## c) Test that yaml2obj is able to generate compilation units according to the
679## associated abbrev table that is referenced by the 'AbbrevTableID' and obj2yaml
680## is able to convert it back.
681
682# RUN: yaml2obj --docnum=3 %s | obj2yaml | FileCheck %s --check-prefix=MULTI-TABLES
683
684#      MULTI-TABLES: DWARF:
685# MULTI-TABLES-NEXT:   debug_abbrev:
686# MULTI-TABLES-NEXT:     - ID: 0
687# MULTI-TABLES-NEXT:       Table:
688# MULTI-TABLES-NEXT:         - Code:     0x1
689# MULTI-TABLES-NEXT:           Tag:      DW_TAG_compile_unit
690# MULTI-TABLES-NEXT:           Children: DW_CHILDREN_no
691# MULTI-TABLES-NEXT:           Attributes:
692# MULTI-TABLES-NEXT:             - Attribute: DW_AT_low_pc
693# MULTI-TABLES-NEXT:               Form:      DW_FORM_addr
694# MULTI-TABLES-NEXT:     - ID: 1
695# MULTI-TABLES-NEXT:       Table:
696# MULTI-TABLES-NEXT:         - Code:     0x1
697# MULTI-TABLES-NEXT:           Tag:      DW_TAG_compile_unit
698# MULTI-TABLES-NEXT:           Children: DW_CHILDREN_no
699# MULTI-TABLES-NEXT:           Attributes:
700# MULTI-TABLES-NEXT:             - Attribute: DW_AT_low_pc
701# MULTI-TABLES-NEXT:               Form:      DW_FORM_data4
702# MULTI-TABLES-NEXT:         - Code:     0x2
703# MULTI-TABLES-NEXT:           Tag:      DW_TAG_compile_unit
704# MULTI-TABLES-NEXT:           Children: DW_CHILDREN_no
705# MULTI-TABLES-NEXT:           Attributes:
706# MULTI-TABLES-NEXT:             - Attribute: DW_AT_low_pc
707# MULTI-TABLES-NEXT:               Form:      DW_FORM_data4
708# MULTI-TABLES-NEXT:     - ID: 2
709# MULTI-TABLES-NEXT:       Table:
710# MULTI-TABLES-NEXT:         - Code:     0x1
711# MULTI-TABLES-NEXT:           Tag:      DW_TAG_compile_unit
712# MULTI-TABLES-NEXT:           Children: DW_CHILDREN_no
713# MULTI-TABLES-NEXT:           Attributes:
714# MULTI-TABLES-NEXT:             - Attribute: DW_AT_low_pc
715# MULTI-TABLES-NEXT:               Form:      DW_FORM_udata
716# MULTI-TABLES-NEXT:     - ID: 3
717# MULTI-TABLES-NEXT:   debug_info:
718# MULTI-TABLES-NEXT:     - Length:        0xC
719# MULTI-TABLES-NEXT:       Version:       4
720# MULTI-TABLES-NEXT:       AbbrevTableID: 1
721# MULTI-TABLES-NEXT:       AbbrOffset:    0x8
722# MULTI-TABLES-NEXT:       AddrSize:      8
723# MULTI-TABLES-NEXT:       Entries:
724# MULTI-TABLES-NEXT:         - AbbrCode: 0x1
725# MULTI-TABLES-NEXT:           Values:
726# MULTI-TABLES-NEXT:             - Value: 0x1234
727# MULTI-TABLES-NEXT:     - Length:        0xC
728# MULTI-TABLES-NEXT:       Version:       4
729# MULTI-TABLES-NEXT:       AbbrevTableID: 1
730# MULTI-TABLES-NEXT:       AbbrOffset:    0x8
731# MULTI-TABLES-NEXT:       AddrSize:      8
732# MULTI-TABLES-NEXT:       Entries:
733# MULTI-TABLES-NEXT:         - AbbrCode: 0x1
734# MULTI-TABLES-NEXT:           Values:
735# MULTI-TABLES-NEXT:             - Value: 0x4321
736# MULTI-TABLES-NEXT:     - Length:        0x10
737# MULTI-TABLES-NEXT:       Version:       4
738# MULTI-TABLES-NEXT:       AbbrevTableID: 0
739# MULTI-TABLES-NEXT:       AbbrOffset:    0x0
740# MULTI-TABLES-NEXT:       AddrSize:      8
741# MULTI-TABLES-NEXT:       Entries:
742# MULTI-TABLES-NEXT:         - AbbrCode: 0x1
743# MULTI-TABLES-NEXT:           Values:
744# MULTI-TABLES-NEXT:             - Value: 0x5678
745# MULTI-TABLES-NEXT:     - Length:        0xB
746# MULTI-TABLES-NEXT:       Version:       4
747# MULTI-TABLES-NEXT:       AbbrevTableID: 2
748# MULTI-TABLES-NEXT:       AbbrOffset:    0x17
749# MULTI-TABLES-NEXT:       AddrSize:      8
750# MULTI-TABLES-NEXT:       Entries:
751# MULTI-TABLES-NEXT:         - AbbrCode: 0x1
752# MULTI-TABLES-NEXT:           Values:
753# MULTI-TABLES-NEXT:             - Value: 0x8765
754# MULTI-TABLES-NEXT: ...
755
756--- !mach-o
757FileHeader:
758  magic:      0xFEEDFACF
759  cputype:    0x01000007
760  cpusubtype: 0x00000003
761  filetype:   0x0000000A
762  ncmds:      1
763  sizeofcmds: 232
764  flags:      0x00000000
765  reserved:   0x00000000
766LoadCommands:
767  - cmd:      LC_SEGMENT_64
768    cmdsize:  232
769    segname:  __DWARF
770    vmaddr:   0x00
771    vmsize:   0x00
772    fileoff:  0x00
773    filesize: 0x00
774    maxprot:  0
775    initprot: 0
776    nsects:   2
777    flags:    0
778    Sections:
779      - sectname:  __debug_abbrev
780        segname:   __DWARF
781        addr:      0x00
782        size:      32
783        offset:    528
784        align:     0
785        reloff:    0x00000000
786        nreloc:    0
787        flags:     0x00000000
788        reserved1: 0x00000000
789        reserved2: 0x00000000
790        reserved3: 0x00000000
791      - sectname:  __debug_info
792        segname:   __DWARF
793        addr:      0x00
794        size:      67
795        offset:    1070
796        align:     0
797        reloff:    0x00000000
798        nreloc:    0
799        flags:     0x00000000
800        reserved1: 0x00000000
801        reserved2: 0x00000000
802        reserved3: 0x00000000
803DWARF:
804  debug_abbrev:
805    - Table:
806        - Code:     1
807          Tag:      DW_TAG_compile_unit
808          Children: DW_CHILDREN_no
809          Attributes:
810            - Attribute: DW_AT_low_pc
811              Form:      DW_FORM_addr
812    - ID: 2
813      Table:
814        - Code:     1
815          Tag:      DW_TAG_compile_unit
816          Children: DW_CHILDREN_no
817          Attributes:
818            - Attribute: DW_AT_low_pc
819              Form:      DW_FORM_data4
820        - Code:     2
821          Tag:      DW_TAG_compile_unit
822          Children: DW_CHILDREN_no
823          Attributes:
824            - Attribute: DW_AT_low_pc
825              Form:      DW_FORM_data4
826    - ID: 1
827      Table:
828        - Code:     1
829          Tag:      DW_TAG_compile_unit
830          Children: DW_CHILDREN_no
831          Attributes:
832            - Attribute: DW_AT_low_pc
833              Form:      DW_FORM_udata
834    - ID: 3
835  debug_info:
836    - Version:       4
837      AbbrevTableID: 2
838      Entries:
839        - AbbrCode: 1
840          Values:
841            - Value: 0x1234
842    - Version:       4
843      AbbrevTableID: 2
844      Entries:
845        - AbbrCode: 1
846          Values:
847            - Value: 0x4321
848    - Version:       4
849      AbbrevTableID: 0
850      Entries:
851        - AbbrCode: 1
852          Values:
853            - Value: 0x5678
854    - Version:       4
855      AbbrevTableID: 1
856      Entries:
857        - AbbrCode: 1
858          Values:
859            - Value: 0x8765
860
861## d) Test that yaml2obj emits an error message when a compilation unit doesn't have
862## an associated abbrev table.
863
864# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=MISSING-ABBREV
865
866# MISSING-ABBREV: yaml2obj: error: cannot find abbrev table whose ID is 0 for compilation unit with index 0
867
868--- !mach-o
869FileHeader:
870  magic:      0xFEEDFACF
871  cputype:    0x01000007
872  cpusubtype: 0x00000003
873  filetype:   0x0000000A
874  ncmds:      1
875  sizeofcmds: 232
876  flags:      0x00000000
877  reserved:   0x00000000
878LoadCommands:
879  - cmd:      LC_SEGMENT_64
880    cmdsize:  152
881    segname:  __DWARF
882    vmaddr:   0x00
883    vmsize:   0x00
884    fileoff:  0x00
885    filesize: 0x00
886    maxprot:  0
887    initprot: 0
888    nsects:   2
889    flags:    0
890    Sections:
891      - sectname:  __debug_info
892        segname:   __DWARF
893        addr:      0x00
894        size:      64
895        offset:    1070
896        align:     0
897        reloff:    0x00000000
898        nreloc:    0
899        flags:     0x00000000
900        reserved1: 0x00000000
901        reserved2: 0x00000000
902        reserved3: 0x00000000
903DWARF:
904  debug_info:
905    - Version:    4
906      AbbrOffset: 0x00
907      Entries:
908        - AbbrCode: 1
909          Values:
910            - Value: 0x1234
911