• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## a) Test that yaml2obj is able to emit the __debug_abbrev section and obj2yaml is
2## able to convert it back.
3
4# RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s
5
6--- !mach-o
7FileHeader:      
8  magic:           0xFEEDFACF
9  cputype:         0x01000007
10  cpusubtype:      0x00000003
11  filetype:        0x0000000A
12  ncmds:           5
13  sizeofcmds:      1800
14  flags:           0x00000000
15  reserved:        0x00000000
16LoadCommands:    
17  - cmd:             LC_SEGMENT_64
18    cmdsize:         72
19    segname:         __PAGEZERO
20    vmaddr:          0
21    vmsize:          4294967296
22    fileoff:         0
23    filesize:        0
24    maxprot:         0
25    initprot:        0
26    nsects:          0
27    flags:           0
28  - cmd:             LC_SEGMENT_64
29    cmdsize:         472
30    segname:         __TEXT
31    vmaddr:          4294967296
32    vmsize:          4096
33    fileoff:         0
34    filesize:        0
35    maxprot:         7
36    initprot:        5
37    nsects:          5
38    flags:           0
39    Sections:        
40      - sectname:        __text
41        segname:         __TEXT
42        addr:            0x0000000100000F50
43        size:            52
44        offset:          0x00000000
45        align:           4
46        reloff:          0x00000000
47        nreloc:          0
48        flags:           0x80000400
49        reserved1:       0x00000000
50        reserved2:       0x00000000
51        reserved3:       0x00000000
52      - sectname:        __stubs
53        segname:         __TEXT
54        addr:            0x0000000100000F84
55        size:            6
56        offset:          0x00000000
57        align:           1
58        reloff:          0x00000000
59        nreloc:          0
60        flags:           0x80000408
61        reserved1:       0x00000000
62        reserved2:       0x00000006
63        reserved3:       0x00000000
64      - sectname:        __stub_helper
65        segname:         __TEXT
66        addr:            0x0000000100000F8C
67        size:            26
68        offset:          0x00000000
69        align:           2
70        reloff:          0x00000000
71        nreloc:          0
72        flags:           0x80000400
73        reserved1:       0x00000000
74        reserved2:       0x00000000
75        reserved3:       0x00000000
76      - sectname:        __cstring
77        segname:         __TEXT
78        addr:            0x0000000100000FA6
79        size:            14
80        offset:          0x00000000
81        align:           0
82        reloff:          0x00000000
83        nreloc:          0
84        flags:           0x00000002
85        reserved1:       0x00000000
86        reserved2:       0x00000000
87        reserved3:       0x00000000
88      - sectname:        __unwind_info
89        segname:         __TEXT
90        addr:            0x0000000100000FB4
91        size:            72
92        offset:          0x00000000
93        align:           2
94        reloff:          0x00000000
95        nreloc:          0
96        flags:           0x00000000
97        reserved1:       0x00000000
98        reserved2:       0x00000000
99        reserved3:       0x00000000
100  - cmd:             LC_SEGMENT_64
101    cmdsize:         232
102    segname:         __DATA
103    vmaddr:          4294971392
104    vmsize:          4096
105    fileoff:         0
106    filesize:        0
107    maxprot:         7
108    initprot:        3
109    nsects:          2
110    flags:           0
111    Sections:        
112      - sectname:        __nl_symbol_ptr
113        segname:         __DATA
114        addr:            0x0000000100001000
115        size:            16
116        offset:          0x00000000
117        align:           3
118        reloff:          0x00000000
119        nreloc:          0
120        flags:           0x00000006
121        reserved1:       0x00000001
122        reserved2:       0x00000000
123        reserved3:       0x00000000
124      - sectname:        __la_symbol_ptr
125        segname:         __DATA
126        addr:            0x0000000100001010
127        size:            8
128        offset:          0x00000000
129        align:           3
130        reloff:          0x00000000
131        nreloc:          0
132        flags:           0x00000007
133        reserved1:       0x00000003
134        reserved2:       0x00000000
135        reserved3:       0x00000000
136  - cmd:             LC_SEGMENT_64
137    cmdsize:         72
138    segname:         __LINKEDIT
139    vmaddr:          4294975488
140    vmsize:          4096
141    fileoff:         4096
142    filesize:        60
143    maxprot:         7
144    initprot:        1
145    nsects:          0
146    flags:           0
147  - cmd:             LC_SEGMENT_64
148    cmdsize:         952
149    segname:         __DWARF
150    vmaddr:          4294979584
151    vmsize:          4096
152    fileoff:         8192
153    filesize:        764
154    maxprot:         7
155    initprot:        3
156    nsects:          11
157    flags:           0
158    Sections:        
159      - sectname:        __debug_line
160        segname:         __DWARF
161        addr:            0x0000000100003000
162        size:            69
163        offset:          0x00002000
164        align:           0
165        reloff:          0x00000000
166        nreloc:          0
167        flags:           0x00000000
168        reserved1:       0x00000000
169        reserved2:       0x00000000
170        reserved3:       0x00000000
171      - sectname:        __debug_pubnames
172        segname:         __DWARF
173        addr:            0x0000000100003045
174        size:            27
175        offset:          0x00002045
176        align:           0
177        reloff:          0x00000000
178        nreloc:          0
179        flags:           0x00000000
180        reserved1:       0x00000000
181        reserved2:       0x00000000
182        reserved3:       0x00000000
183      - sectname:        __debug_pubtypes
184        segname:         __DWARF
185        addr:            0x0000000100003060
186        size:            35
187        offset:          0x00002060
188        align:           0
189        reloff:          0x00000000
190        nreloc:          0
191        flags:           0x00000000
192        reserved1:       0x00000000
193        reserved2:       0x00000000
194        reserved3:       0x00000000
195      - sectname:        __debug_info
196        segname:         __DWARF
197        addr:            0x00000001000030B3
198        size:            121
199        offset:          0x000020B3
200        align:           0
201        reloff:          0x00000000
202        nreloc:          0
203        flags:           0x00000000
204        reserved1:       0x00000000
205        reserved2:       0x00000000
206        reserved3:       0x00000000
207      - sectname:        __debug_abbrev
208        segname:         __DWARF
209        addr:            0x000000010000312C
210        size:            76
211        offset:          0x0000212C
212        align:           0
213        reloff:          0x00000000
214        nreloc:          0
215        flags:           0x00000000
216        reserved1:       0x00000000
217        reserved2:       0x00000000
218        reserved3:       0x00000000
219      - sectname:        __debug_str
220        segname:         __DWARF
221        addr:            0x0000000100003178
222        size:            142
223        offset:          0x00002178
224        align:           0
225        reloff:          0x00000000
226        nreloc:          0
227        flags:           0x00000000
228        reserved1:       0x00000000
229        reserved2:       0x00000000
230        reserved3:       0x00000000
231      - sectname:        __apple_names
232        segname:         __DWARF
233        addr:            0x0000000100003206
234        size:            60
235        offset:          0x00002206
236        align:           0
237        reloff:          0x00000000
238        nreloc:          0
239        flags:           0x00000000
240        reserved1:       0x00000000
241        reserved2:       0x00000000
242        reserved3:       0x00000000
243      - sectname:        __apple_namespac
244        segname:         __DWARF
245        addr:            0x0000000100003242
246        size:            36
247        offset:          0x00002242
248        align:           0
249        reloff:          0x00000000
250        nreloc:          0
251        flags:           0x00000000
252        reserved1:       0x00000000
253        reserved2:       0x00000000
254        reserved3:       0x00000000
255      - sectname:        __apple_types
256        segname:         __DWARF
257        addr:            0x0000000100003266
258        size:            114
259        offset:          0x00002266
260        align:           0
261        reloff:          0x00000000
262        nreloc:          0
263        flags:           0x00000000
264        reserved1:       0x00000000
265        reserved2:       0x00000000
266        reserved3:       0x00000000
267      - sectname:        __apple_objc
268        segname:         __DWARF
269        addr:            0x00000001000032D8
270        size:            36
271        offset:          0x000022D8
272        align:           0
273        reloff:          0x00000000
274        nreloc:          0
275        flags:           0x00000000
276        reserved1:       0x00000000
277        reserved2:       0x00000000
278        reserved3:       0x00000000
279DWARF:           
280  debug_abbrev:     
281    - Table:
282        - Code:            0x00000001
283          Tag:             DW_TAG_compile_unit
284          Children:        DW_CHILDREN_yes
285          Attributes:      
286            - Attribute:       DW_AT_producer
287              Form:            DW_FORM_strp
288            - Attribute:       DW_AT_language
289              Form:            DW_FORM_data2
290            - Attribute:       DW_AT_name
291              Form:            DW_FORM_strp
292            - Attribute:       DW_AT_stmt_list
293              Form:            DW_FORM_sec_offset
294            - Attribute:       DW_AT_comp_dir
295              Form:            DW_FORM_strp
296            - Attribute:       DW_AT_low_pc
297              Form:            DW_FORM_addr
298            - Attribute:       DW_AT_high_pc
299              Form:            DW_FORM_data4
300        - Code:            0x00000002
301          Tag:             DW_TAG_subprogram
302          Children:        DW_CHILDREN_yes
303          Attributes:      
304            - Attribute:       DW_AT_low_pc
305              Form:            DW_FORM_addr
306            - Attribute:       DW_AT_high_pc
307              Form:            DW_FORM_data4
308            - Attribute:       DW_AT_frame_base
309              Form:            DW_FORM_exprloc
310            - Attribute:       DW_AT_name
311              Form:            DW_FORM_strp
312            - Attribute:       DW_AT_decl_file
313              Form:            DW_FORM_data1
314            - Attribute:       DW_AT_decl_line
315              Form:            DW_FORM_data1
316            - Attribute:       DW_AT_prototyped
317              Form:            DW_FORM_flag_present
318            - Attribute:       DW_AT_type
319              Form:            DW_FORM_ref4
320            - Attribute:       DW_AT_external
321              Form:            DW_FORM_flag_present
322        - Code:            0x00000003
323          Tag:             DW_TAG_formal_parameter
324          Children:        DW_CHILDREN_no
325          Attributes:      
326            - Attribute:       DW_AT_location
327              Form:            DW_FORM_exprloc
328            - Attribute:       DW_AT_name
329              Form:            DW_FORM_strp
330            - Attribute:       DW_AT_decl_file
331              Form:            DW_FORM_data1
332            - Attribute:       DW_AT_decl_line
333              Form:            DW_FORM_data1
334            - Attribute:       DW_AT_type
335              Form:            DW_FORM_ref4
336        - Code:            0x00000004
337          Tag:             DW_TAG_base_type
338          Children:        DW_CHILDREN_no
339          Attributes:      
340            - Attribute:       DW_AT_name
341              Form:            DW_FORM_strp
342            - Attribute:       DW_AT_encoding
343              Form:            DW_FORM_data1
344            - Attribute:       DW_AT_byte_size
345              Form:            DW_FORM_data1
346        - Code:            0x00000005
347          Tag:             DW_TAG_pointer_type
348          Children:        DW_CHILDREN_no
349          Attributes:      
350            - Attribute:       DW_AT_type
351              Form:            DW_FORM_ref4
352...
353
354#CHECK: DWARF:
355#CHECK:   debug_abbrev:
356#CHECK:     - Code:            0x1
357#CHECK:       Tag:             DW_TAG_compile_unit
358#CHECK:       Children:        DW_CHILDREN_yes
359#CHECK:       Attributes:
360#CHECK:         - Attribute:       DW_AT_producer
361#CHECK:           Form:            DW_FORM_strp
362#CHECK:         - Attribute:       DW_AT_language
363#CHECK:           Form:            DW_FORM_data2
364#CHECK:         - Attribute:       DW_AT_name
365#CHECK:           Form:            DW_FORM_strp
366#CHECK:         - Attribute:       DW_AT_stmt_list
367#CHECK:           Form:            DW_FORM_sec_offset
368#CHECK:         - Attribute:       DW_AT_comp_dir
369#CHECK:           Form:            DW_FORM_strp
370#CHECK:         - Attribute:       DW_AT_low_pc
371#CHECK:           Form:            DW_FORM_addr
372#CHECK:         - Attribute:       DW_AT_high_pc
373#CHECK:           Form:            DW_FORM_data4
374#CHECK:     - Code:            0x2
375#CHECK:       Tag:             DW_TAG_subprogram
376#CHECK:       Children:        DW_CHILDREN_yes
377#CHECK:       Attributes:
378#CHECK:         - Attribute:       DW_AT_low_pc
379#CHECK:           Form:            DW_FORM_addr
380#CHECK:         - Attribute:       DW_AT_high_pc
381#CHECK:           Form:            DW_FORM_data4
382#CHECK:         - Attribute:       DW_AT_frame_base
383#CHECK:           Form:            DW_FORM_exprloc
384#CHECK:         - Attribute:       DW_AT_name
385#CHECK:           Form:            DW_FORM_strp
386#CHECK:         - Attribute:       DW_AT_decl_file
387#CHECK:           Form:            DW_FORM_data1
388#CHECK:         - Attribute:       DW_AT_decl_line
389#CHECK:           Form:            DW_FORM_data1
390#CHECK:         - Attribute:       DW_AT_prototyped
391#CHECK:           Form:            DW_FORM_flag_present
392#CHECK:         - Attribute:       DW_AT_type
393#CHECK:           Form:            DW_FORM_ref4
394#CHECK:         - Attribute:       DW_AT_external
395#CHECK:           Form:            DW_FORM_flag_present
396#CHECK:     - Code:            0x3
397#CHECK:       Tag:             DW_TAG_formal_parameter
398#CHECK:       Children:        DW_CHILDREN_no
399#CHECK:       Attributes:
400#CHECK:         - Attribute:       DW_AT_location
401#CHECK:           Form:            DW_FORM_exprloc
402#CHECK:         - Attribute:       DW_AT_name
403#CHECK:           Form:            DW_FORM_strp
404#CHECK:         - Attribute:       DW_AT_decl_file
405#CHECK:           Form:            DW_FORM_data1
406#CHECK:         - Attribute:       DW_AT_decl_line
407#CHECK:           Form:            DW_FORM_data1
408#CHECK:         - Attribute:       DW_AT_type
409#CHECK:           Form:            DW_FORM_ref4
410#CHECK:     - Code:            0x4
411#CHECK:       Tag:             DW_TAG_base_type
412#CHECK:       Children:        DW_CHILDREN_no
413#CHECK:       Attributes:
414#CHECK:         - Attribute:       DW_AT_name
415#CHECK:           Form:            DW_FORM_strp
416#CHECK:         - Attribute:       DW_AT_encoding
417#CHECK:           Form:            DW_FORM_data1
418#CHECK:         - Attribute:       DW_AT_byte_size
419#CHECK:           Form:            DW_FORM_data1
420#CHECK:     - Code:            0x5
421#CHECK:       Tag:             DW_TAG_pointer_type
422#CHECK:       Children:        DW_CHILDREN_no
423#CHECK:       Attributes:
424#CHECK:         - Attribute:       DW_AT_type
425#CHECK:           Form:            DW_FORM_ref4
426
427## b) Test that yaml2obj emits an error message when there are non-empty compilation
428## units and multiple abbrev tables are assigned the same ID.
429
430# RUN: not yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=ID-COLLISION
431
432# ID-COLLISION: yaml2obj: error: the ID (1) of abbrev table with index 1 has been used by abbrev table with index 0
433
434--- !mach-o
435FileHeader:
436  magic:      0xFEEDFACF
437  cputype:    0x01000007
438  cpusubtype: 0x00000003
439  filetype:   0x0000000A
440  ncmds:      1
441  sizeofcmds: 232
442  flags:      0x00000000
443  reserved:   0x00000000
444LoadCommands:
445  - cmd:      LC_SEGMENT_64
446    cmdsize:  232
447    segname:  __DWARF
448    vmaddr:   0x00
449    vmsize:   0x00
450    fileoff:  0x00
451    filesize: 0x00
452    maxprot:  0
453    initprot: 0
454    nsects:   2
455    flags:    0
456    Sections:
457      - sectname:  __debug_abbrev
458        segname:   __DWARF
459        addr:      0x00
460        size:      24
461        offset:    528
462        align:     0
463        reloff:    0x00000000
464        nreloc:    0
465        flags:     0x00000000
466        reserved1: 0x00000000
467        reserved2: 0x00000000
468        reserved3: 0x00000000
469      - sectname:  __debug_info
470        segname:   __DWARF
471        addr:      0x00
472        size:      64
473        offset:    1070
474        align:     0
475        reloff:    0x00000000
476        nreloc:    0
477        flags:     0x00000000
478        reserved1: 0x00000000
479        reserved2: 0x00000000
480        reserved3: 0x00000000
481DWARF:
482  debug_abbrev:
483    - ID: 1
484    - ID: 1
485  debug_info:
486    - Version:    4
487      AbbrOffset: 0x00
488      Entries:
489        - AbbrCode: 1
490          Values:
491            - Value: 0x1234
492