1# RUN: yaml2obj %s -o %t
2# RUN: llvm-objdump --macho --reloc %t | FileCheck %s --check-prefix=OBJDUMP-VERIFY
3
4# OBJDUMP-VERIFY: Relocation information (__TEXT,__text) 2 entries
5# OBJDUMP-VERIFY-NEXT: address  pcrel length extern type    scattered symbolnum/value
6# OBJDUMP-VERIFY-NEXT: 00000015 True  long   True   SIGNED  False     _w
7# OBJDUMP-VERIFY-NEXT: 0000000e True  long   True   SIGNED  False     _z
8# OBJDUMP-VERIFY-NEXT: Relocation information (__TEXT,__StaticInit) 4 entries
9# OBJDUMP-VERIFY-NEXT: address  pcrel length extern type    scattered symbolnum/value
10# OBJDUMP-VERIFY-NEXT: 00000025 True  long   True   BRANCH  False     ___cxx_global_var_init
11# OBJDUMP-VERIFY-NEXT: 00000018 True  long   True   SIGNED  False     _w
12# OBJDUMP-VERIFY-NEXT: 0000000e True  long   True   SIGNED  False     _x
13# OBJDUMP-VERIFY-NEXT: 00000007 True  long   True   SIGNED  False     _y
14# OBJDUMP-VERIFY-NEXT: Relocation information (__DATA,__data) 1 entries
15# OBJDUMP-VERIFY-NEXT: address  pcrel length extern type    scattered symbolnum/value
16# OBJDUMP-VERIFY-NEXT: 00000008 False quad   True   UNSIGND False     _x
17# OBJDUMP-VERIFY-NEXT: Relocation information (__DATA,__mod_init_func) 1 entries
18# OBJDUMP-VERIFY-NEXT: address  pcrel length extern type    scattered symbolnum/value
19# OBJDUMP-VERIFY-NEXT: 00000000 False quad   True   UNSIGND False     __GLOBAL__sub_I_main.cpp
20# OBJDUMP-VERIFY-NEXT: Relocation information (__LD,__compact_unwind) 3 entries
21# OBJDUMP-VERIFY-NEXT: address  pcrel length extern type    scattered symbolnum/value
22# OBJDUMP-VERIFY-NEXT: 00000040 False quad   False  UNSIGND False     2 (__TEXT,__StaticInit)
23# OBJDUMP-VERIFY-NEXT: 00000020 False quad   False  UNSIGND False     1 (__TEXT,__text)
24# OBJDUMP-VERIFY-NEXT: 00000000 False quad   False  UNSIGND False     2 (__TEXT,__StaticInit)
25
26# RUN: obj2yaml %t | FileCheck %s
27# CHECK:    Sections:
28# CHECK-NEXT:      - sectname:        __text
29# CHECK-NEXT:        segname:         __TEXT
30# CHECK-NEXT:        addr:            0x0
31# CHECK-NEXT:        size:            27
32# CHECK-NEXT:        offset:          0x310
33# CHECK-NEXT:        align:           4
34# CHECK-NEXT:        reloff:          0x468
35# CHECK-NEXT:        nreloc:          2
36# CHECK-NEXT:        flags:           0x80000400
37# CHECK-NEXT:        reserved1:       0x0
38# CHECK-NEXT:        reserved2:       0x0
39# CHECK-NEXT:        reserved3:       0x0
40# CHECK-NEXT:        content:
41# CHECK-NEXT:        relocations:
42# CHECK-NEXT:          - address:         0x15
43# CHECK-NEXT:            symbolnum:       3
44# CHECK-NEXT:            pcrel:           true
45# CHECK-NEXT:            length:          2
46# CHECK-NEXT:            extern:          true
47# CHECK-NEXT:            type:            1
48# CHECK-NEXT:            scattered:       false
49# CHECK-NEXT:            value:           0
50# CHECK-NEXT:          - address:         0xE
51# CHECK-NEXT:            symbolnum:       6
52# CHECK-NEXT:            pcrel:           true
53# CHECK-NEXT:            length:          2
54# CHECK-NEXT:            extern:          true
55# CHECK-NEXT:            type:            1
56# CHECK-NEXT:            scattered:       false
57# CHECK-NEXT:            value:           0
58# CHECK-NEXT:      - sectname:        __StaticInit
59# CHECK-NEXT:        segname:         __TEXT
60# CHECK-NEXT:        addr:            0x20
61# CHECK-NEXT:        size:            43
62# CHECK-NEXT:        offset:          0x330
63# CHECK-NEXT:        align:           4
64# CHECK-NEXT:        reloff:          0x478
65# CHECK-NEXT:        nreloc:          4
66# CHECK-NEXT:        flags:           0x80000400
67# CHECK-NEXT:        reserved1:       0x0
68# CHECK-NEXT:        reserved2:       0x0
69# CHECK-NEXT:        reserved3:       0x0
70# CHECK-NEXT:        content:
71# CHECK-NEXT:        relocations:
72# CHECK-NEXT:          - address:         0x25
73# CHECK-NEXT:            symbolnum:       0
74# CHECK-NEXT:            pcrel:           true
75# CHECK-NEXT:            length:          2
76# CHECK-NEXT:            extern:          true
77# CHECK-NEXT:            type:            2
78# CHECK-NEXT:            scattered:       false
79# CHECK-NEXT:            value:           0
80# CHECK-NEXT:          - address:         0x18
81# CHECK-NEXT:            symbolnum:       3
82# CHECK-NEXT:            pcrel:           true
83# CHECK-NEXT:            length:          2
84# CHECK-NEXT:            extern:          true
85# CHECK-NEXT:            type:            1
86# CHECK-NEXT:            scattered:       false
87# CHECK-NEXT:            value:           0
88# CHECK-NEXT:          - address:         0xE
89# CHECK-NEXT:            symbolnum:       4
90# CHECK-NEXT:            pcrel:           true
91# CHECK-NEXT:            length:          2
92# CHECK-NEXT:            extern:          true
93# CHECK-NEXT:            type:            1
94# CHECK-NEXT:            scattered:       false
95# CHECK-NEXT:            value:           0
96# CHECK-NEXT:          - address:         0x7
97# CHECK-NEXT:            symbolnum:       5
98# CHECK-NEXT:            pcrel:           true
99# CHECK-NEXT:            length:          2
100# CHECK-NEXT:            extern:          true
101# CHECK-NEXT:            type:            1
102# CHECK-NEXT:            scattered:       false
103# CHECK-NEXT:            value:           0
104# CHECK-NEXT:      - sectname:        __data
105# CHECK-NEXT:        segname:         __DATA
106# CHECK-NEXT:        addr:            0x50
107# CHECK-NEXT:        size:            16
108# CHECK-NEXT:        offset:          0x360
109# CHECK-NEXT:        align:           3
110# CHECK-NEXT:        reloff:          0x498
111# CHECK-NEXT:        nreloc:          1
112# CHECK-NEXT:        flags:           0x0
113# CHECK-NEXT:        reserved1:       0x0
114# CHECK-NEXT:        reserved2:       0x0
115# CHECK-NEXT:        reserved3:       0x0
116# CHECK-NEXT:        content:         '01000000020000000000000000000000'
117# CHECK-NEXT:        relocations:
118# CHECK-NEXT:          - address:         0x8
119# CHECK-NEXT:            symbolnum:       4
120# CHECK-NEXT:            pcrel:           false
121# CHECK-NEXT:            length:          3
122# CHECK-NEXT:            extern:          true
123# CHECK-NEXT:            type:            0
124# CHECK-NEXT:            scattered:       false
125# CHECK-NEXT:            value:           0
126# CHECK-NEXT:      - sectname:        __common
127# CHECK-NEXT:        segname:         __DATA
128# CHECK-NEXT:        addr:            0x158
129# CHECK-NEXT:        size:            8
130# CHECK-NEXT:        offset:          0x0
131# CHECK-NEXT:        align:           3
132# CHECK-NEXT:        reloff:          0x0
133# CHECK-NEXT:        nreloc:          0
134# CHECK-NEXT:        flags:           0x1
135# CHECK-NEXT:        reserved1:       0x0
136# CHECK-NEXT:        reserved2:       0x0
137# CHECK-NEXT:        reserved3:       0x0
138# CHECK-NEXT:      - sectname:        __mod_init_func
139# CHECK-NEXT:        segname:         __DATA
140# CHECK-NEXT:        addr:            0x60
141# CHECK-NEXT:        size:            8
142# CHECK-NEXT:        offset:          0x370
143# CHECK-NEXT:        align:           3
144# CHECK-NEXT:        reloff:          0x4A0
145# CHECK-NEXT:        nreloc:          1
146# CHECK-NEXT:        flags:           0x9
147# CHECK-NEXT:        reserved1:       0x0
148# CHECK-NEXT:        reserved2:       0x0
149# CHECK-NEXT:        reserved3:       0x0
150# CHECK-NEXT:        content:
151# CHECK-NEXT:        relocations:
152# CHECK-NEXT:          - address:         0x0
153# CHECK-NEXT:            symbolnum:       1
154# CHECK-NEXT:            pcrel:           false
155# CHECK-NEXT:            length:          3
156# CHECK-NEXT:            extern:          true
157# CHECK-NEXT:            type:            0
158# CHECK-NEXT:            scattered:       false
159# CHECK-NEXT:            value:           0
160# CHECK-NEXT:      - sectname:        __compact_unwind
161# CHECK-NEXT:        segname:         __LD
162# CHECK-NEXT:        addr:            0x68
163# CHECK-NEXT:        size:            96
164# CHECK-NEXT:        offset:          0x378
165# CHECK-NEXT:        align:           3
166# CHECK-NEXT:        reloff:          0x4A8
167# CHECK-NEXT:        nreloc:          3
168# CHECK-NEXT:        flags:           0x2000000
169# CHECK-NEXT:        reserved1:       0x0
170# CHECK-NEXT:        reserved2:       0x0
171# CHECK-NEXT:        reserved3:       0x0
172# CHECK-NEXT:        content:
173# CHECK-NEXT:        relocations:
174# CHECK-NEXT:          - address:         0x40
175# CHECK-NEXT:            symbolnum:       2
176# CHECK-NEXT:            pcrel:           false
177# CHECK-NEXT:            length:          3
178# CHECK-NEXT:            extern:          false
179# CHECK-NEXT:            type:            0
180# CHECK-NEXT:            scattered:       false
181# CHECK-NEXT:            value:           0
182# CHECK-NEXT:          - address:         0x20
183# CHECK-NEXT:            symbolnum:       1
184# CHECK-NEXT:            pcrel:           false
185# CHECK-NEXT:            length:          3
186# CHECK-NEXT:            extern:          false
187# CHECK-NEXT:            type:            0
188# CHECK-NEXT:            scattered:       false
189# CHECK-NEXT:            value:           0
190# CHECK-NEXT:          - address:         0x0
191# CHECK-NEXT:            symbolnum:       2
192# CHECK-NEXT:            pcrel:           false
193# CHECK-NEXT:            length:          3
194# CHECK-NEXT:            extern:          false
195# CHECK-NEXT:            type:            0
196# CHECK-NEXT:            scattered:       false
197# CHECK-NEXT:            value:           0
198# CHECK-NEXT:      - sectname:        __eh_frame
199# CHECK-NEXT:        segname:         __TEXT
200# CHECK-NEXT:        addr:            0xC8
201# CHECK-NEXT:        size:            144
202# CHECK-NEXT:        offset:          0x3D8
203# CHECK-NEXT:        align:           3
204# CHECK-NEXT:        reloff:          0x0
205# CHECK-NEXT:        nreloc:          0
206# CHECK-NEXT:        flags:           0x6800000B
207# CHECK-NEXT:        reserved1:       0x0
208# CHECK-NEXT:        reserved2:       0x0
209# CHECK-NEXT:        reserved3:       0x0
210
211--- !mach-o
212FileHeader:
213  magic:           0xFEEDFACF
214  cputype:         0x01000007
215  cpusubtype:      0x00000003
216  filetype:        0x00000001
217  ncmds:           4
218  sizeofcmds:      752
219  flags:           0x00002000
220  reserved:        0x00000000
221LoadCommands:
222  - cmd:             LC_SEGMENT_64
223    cmdsize:         632
224    segname:         ''
225    vmaddr:          0
226    vmsize:          352
227    fileoff:         784
228    filesize:        344
229    maxprot:         7
230    initprot:        7
231    nsects:          7
232    flags:           0
233    Sections:
234      - sectname:        __text
235        segname:         __TEXT
236        addr:            0x0000000000000000
237        size:            27
238        offset:          0x00000310
239        align:           4
240        reloff:          0x00000468
241        nreloc:          2
242        flags:           0x80000400
243        reserved1:       0x00000000
244        reserved2:       0x00000000
245        reserved3:       0x00000000
246        content:         554889E5C745FC00000000488B0500000000480305000000005DC3
247        relocations:
248          - address:         0x00000015
249            symbolnum:       3
250            pcrel:           true
251            length:          2
252            extern:          true
253            type:            1
254            scattered:       false
255            value:           0
256          - address:         0x0000000E
257            symbolnum:       6
258            pcrel:           true
259            length:          2
260            extern:          true
261            type:            1
262            scattered:       false
263            value:           0
264      - sectname:        __StaticInit
265        segname:         __TEXT
266        addr:            0x0000000000000020
267        size:            43
268        offset:          0x00000330
269        align:           4
270        reloff:          0x00000478
271        nreloc:          4
272        flags:           0x80000400
273        reserved1:       0x00000000
274        reserved2:       0x00000000
275        reserved3:       0x00000000
276        content:         554889E5488D0500000000488D0D000000004829C148890D000000005DC36690554889E5E8000000005DC3
277        relocations:
278          - address:         0x00000025
279            symbolnum:       0
280            pcrel:           true
281            length:          2
282            extern:          true
283            type:            2
284            scattered:       false
285            value:           0
286          - address:         0x00000018
287            symbolnum:       3
288            pcrel:           true
289            length:          2
290            extern:          true
291            type:            1
292            scattered:       false
293            value:           0
294          - address:         0x0000000E
295            symbolnum:       4
296            pcrel:           true
297            length:          2
298            extern:          true
299            type:            1
300            scattered:       false
301            value:           0
302          - address:         0x00000007
303            symbolnum:       5
304            pcrel:           true
305            length:          2
306            extern:          true
307            type:            1
308            scattered:       false
309            value:           0
310      - sectname:        __data
311        segname:         __DATA
312        addr:            0x0000000000000050
313        size:            16
314        offset:          0x00000360
315        align:           3
316        reloff:          0x00000498
317        nreloc:          1
318        flags:           0x00000000
319        reserved1:       0x00000000
320        reserved2:       0x00000000
321        reserved3:       0x00000000
322        content:         '01000000020000000000000000000000'
323        relocations:
324          - address:         0x00000008
325            symbolnum:       4
326            pcrel:           false
327            length:          3
328            extern:          true
329            type:            0
330            scattered:       false
331            value:           0
332      - sectname:        __common
333        segname:         __DATA
334        addr:            0x0000000000000158
335        size:            8
336        offset:          0x00000000
337        align:           3
338        reloff:          0x00000000
339        nreloc:          0
340        flags:           0x00000001
341        reserved1:       0x00000000
342        reserved2:       0x00000000
343        reserved3:       0x00000000
344      - sectname:        __mod_init_func
345        segname:         __DATA
346        addr:            0x0000000000000060
347        size:            8
348        offset:          0x00000370
349        align:           3
350        reloff:          0x000004A0
351        nreloc:          1
352        flags:           0x00000009
353        reserved1:       0x00000000
354        reserved2:       0x00000000
355        reserved3:       0x00000000
356        content:         '0000000000000000'
357        relocations:
358          - address:         0x00000000
359            symbolnum:       1
360            pcrel:           false
361            length:          3
362            extern:          true
363            type:            0
364            scattered:       false
365            value:           0
366      - sectname:        __compact_unwind
367        segname:         __LD
368        addr:            0x0000000000000068
369        size:            96
370        offset:          0x00000378
371        align:           3
372        reloff:          0x000004A8
373        nreloc:          3
374        flags:           0x02000000
375        reserved1:       0x00000000
376        reserved2:       0x00000000
377        reserved3:       0x00000000
378        content:         20000000000000001E000000000000010000000000000000000000000000000000000000000000001B000000000000010000000000000000000000000000000040000000000000000B0000000000000100000000000000000000000000000000
379        relocations:
380          - address:         0x00000040
381            symbolnum:       2
382            pcrel:           false
383            length:          3
384            extern:          false
385            type:            0
386            scattered:       false
387            value:           0
388          - address:         0x00000020
389            symbolnum:       1
390            pcrel:           false
391            length:          3
392            extern:          false
393            type:            0
394            scattered:       false
395            value:           0
396          - address:         0x00000000
397            symbolnum:       2
398            pcrel:           false
399            length:          3
400            extern:          false
401            type:            0
402            scattered:       false
403            value:           0
404      - sectname:        __eh_frame
405        segname:         __TEXT
406        addr:            0x00000000000000C8
407        size:            144
408        offset:          0x000003D8
409        align:           3
410        reloff:          0x00000000
411        nreloc:          0
412        flags:           0x6800000B
413        reserved1:       0x00000000
414        reserved2:       0x00000000
415        reserved3:       0x00000000
416        content:         1400000000000000017A520001781001100C070890010000240000001C00000038FFFFFFFFFFFFFF1E0000000000000000410E108602430D06000000000000002400000044000000F0FEFFFFFFFFFFFF1B0000000000000000410E108602430D0600000000000000240000006C00000008FFFFFFFFFFFFFF0B0000000000000000410E108602430D0600000000000000
417  - cmd:             LC_VERSION_MIN_MACOSX
418    cmdsize:         16
419    version:         658944
420    sdk:             0
421  - cmd:             LC_SYMTAB
422    cmdsize:         24
423    symoff:          1216
424    nsyms:           7
425    stroff:          1328
426    strsize:         68
427  - cmd:             LC_DYSYMTAB
428    cmdsize:         80
429    ilocalsym:       0
430    nlocalsym:       2
431    iextdefsym:      2
432    nextdefsym:      5
433    iundefsym:       7
434    nundefsym:       0
435    tocoff:          0
436    ntoc:            0
437    modtaboff:       0
438    nmodtab:         0
439    extrefsymoff:    0
440    nextrefsyms:     0
441    indirectsymoff:  0
442    nindirectsyms:   0
443    extreloff:       0
444    nextrel:         0
445    locreloff:       0
446    nlocrel:         0
447LinkEditData:
448  NameList:
449    - n_strx:          13
450      n_type:          0x0E
451      n_sect:          2
452      n_desc:          0
453      n_value:         32
454    - n_strx:          36
455      n_type:          0x0E
456      n_sect:          2
457      n_desc:          0
458      n_value:         64
459    - n_strx:          61
460      n_type:          0x0F
461      n_sect:          1
462      n_desc:          0
463      n_value:         0
464    - n_strx:          10
465      n_type:          0x0F
466      n_sect:          4
467      n_desc:          0
468      n_value:         344
469    - n_strx:          7
470      n_type:          0x0F
471      n_sect:          3
472      n_desc:          0
473      n_value:         80
474    - n_strx:          4
475      n_type:          0x0F
476      n_sect:          3
477      n_desc:          0
478      n_value:         84
479    - n_strx:          1
480      n_type:          0x0F
481      n_sect:          3
482      n_desc:          0
483      n_value:         88
484  StringTable:
485    - ''
486    - _z
487    - _y
488    - _x
489    - _w
490    - ___cxx_global_var_init
491    - __GLOBAL__sub_I_main.cpp
492    - _main
493    - ''
494...
495