1# RUN: ld64.lld -arch arm64 %s %p/Inputs/hello-world-arm64.yaml -o %t
2# RUN: obj2yaml %t | FileCheck %s
3#
4
5--- !mach-o
6arch:            arm64
7file-type:       MH_OBJECT
8flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
9sections:
10  - segment:         __TEXT
11    section:         __text
12    type:            S_REGULAR
13    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
14    alignment:       2
15    address:         0x0000000000000000
16    content:         [ 0xFD, 0x7B, 0xBF, 0xA9, 0xFD, 0x03, 0x00, 0x91,
17                       0x08, 0x00, 0x00, 0x90, 0x08, 0x01, 0x40, 0xF9,
18                       0x00, 0x01, 0x40, 0xF9, 0x01, 0x00, 0x00, 0x90,
19                       0x21, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x94,
20                       0x00, 0x00, 0x80, 0x52, 0xFD, 0x7B, 0xC1, 0xA8,
21                       0xC0, 0x03, 0x5F, 0xD6 ]
22    relocations:
23      - offset:          0x0000001C
24        type:            ARM64_RELOC_BRANCH26
25        length:          2
26        pc-rel:          true
27        extern:          true
28        symbol:          5
29      - offset:          0x00000018
30        type:            ARM64_RELOC_PAGEOFF12
31        length:          2
32        pc-rel:          false
33        extern:          true
34        symbol:          1
35      - offset:          0x00000014
36        type:            ARM64_RELOC_PAGE21
37        length:          2
38        pc-rel:          true
39        extern:          true
40        symbol:          1
41      - offset:          0x0000000C
42        type:            ARM64_RELOC_GOT_LOAD_PAGEOFF12
43        length:          2
44        pc-rel:          false
45        extern:          true
46        symbol:          4
47      - offset:          0x00000008
48        type:            ARM64_RELOC_GOT_LOAD_PAGE21
49        length:          2
50        pc-rel:          true
51        extern:          true
52        symbol:          4
53  - segment:         __TEXT
54    section:         __cstring
55    type:            S_CSTRING_LITERALS
56    attributes:      [  ]
57    address:         0x000000000000002C
58    content:         [ 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x0A, 0x00 ]
59local-symbols:
60  - name:            ltmp0
61    type:            N_SECT
62    sect:            1
63    value:           0x0000000000000000
64  - name:            l_.str
65    type:            N_SECT
66    sect:            2
67    value:           0x000000000000002C
68  - name:            ltmp1
69    type:            N_SECT
70    sect:            2
71    value:           0x000000000000002C
72global-symbols:
73  - name:            _main
74    type:            N_SECT
75    scope:           [ N_EXT ]
76    sect:            1
77    value:           0x0000000000000000
78undefined-symbols:
79  - name:            ___stdoutp
80    type:            N_UNDF
81    scope:           [ N_EXT ]
82    value:           0x0000000000000000
83  - name:            _fprintf
84    type:            N_UNDF
85    scope:           [ N_EXT ]
86    value:           0x0000000000000000
87...
88
89
90# CHECK:   BindOpcodes:
91# CHECK:     - Opcode:          BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
92# CHECK:       Imm:             1
93# CHECK:       Symbol:          ''
94# CHECK:     - Opcode:          BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
95# CHECK:       Imm:             0
96# CHECK:       Symbol:          dyld_stub_binder
97# CHECK:     - Opcode:          BIND_OPCODE_SET_TYPE_IMM
98# CHECK:       Imm:             1
99# CHECK:       Symbol:          ''
100# CHECK:     - Opcode:          BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
101# CHECK:       Imm:             2
102# CHECK:       ULEBExtraData:   [ 0x0 ]
103# CHECK:       Symbol:          ''
104# CHECK:     - Opcode:          BIND_OPCODE_DO_BIND
105# CHECK:       Imm:             0
106# CHECK:       Symbol:          ''
107# CHECK:     - Opcode:          BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
108# CHECK:       Imm:             0
109# CHECK:       Symbol:          ___stdoutp
110# CHECK:     - Opcode:          BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
111# CHECK:       Imm:             2
112# CHECK:       ULEBExtraData:   [ 0x10 ]
113# CHECK:       Symbol:          ''
114# CHECK:     - Opcode:          BIND_OPCODE_DO_BIND
115# CHECK:       Imm:             0
116# CHECK:       Symbol:          ''
117# CHECK:     - Opcode:          BIND_OPCODE_DONE
118# CHECK:       Imm:             0
119# CHECK:       Symbol:          ''
120
121# CHECK:   LazyBindOpcodes:
122# CHECK:     - Opcode:          BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
123# CHECK:       Imm:             2
124# CHECK:       ULEBExtraData:   [ 0x18 ]
125# CHECK:       Symbol:          ''
126# CHECK:     - Opcode:          BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
127# CHECK:       Imm:             1
128# CHECK:       Symbol:          ''
129# CHECK:     - Opcode:          BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
130# CHECK:       Imm:             0
131# CHECK:       Symbol:          _fprintf
132# CHECK:     - Opcode:          BIND_OPCODE_DO_BIND
133# CHECK:       Imm:             0
134# CHECK:       Symbol:          ''
135# CHECK:     - Opcode:          BIND_OPCODE_DONE
136# CHECK:       Imm:             0
137# CHECK:       Symbol:          ''
138# CHECK:     - Opcode:          BIND_OPCODE_DONE
139# CHECK:       Imm:             0
140# CHECK:       Symbol:          ''