1# RUN: ld64.lld.darwinold -arch arm64 -o %t %s \
2# RUN: %p/Inputs/unwind-info-simple-arm64.yaml -e _main %p/Inputs/arm64/libSystem.yaml
3# RUN: llvm-objdump --unwind-info %t | FileCheck %s
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                       0xE0, 0x03, 0x1E, 0x32, 0x00, 0x00, 0x00, 0x94,
18                       0x48, 0x01, 0x80, 0x52, 0x08, 0x00, 0x00, 0xB9,
19                       0x02, 0x00, 0x80, 0xD2, 0x01, 0x00, 0x00, 0x90,
20                       0x21, 0x00, 0x40, 0xF9, 0x00, 0x00, 0x00, 0x94,
21                       0xFD, 0x7B, 0xBF, 0xA9, 0xFD, 0x03, 0x00, 0x91,
22                       0xE0, 0x03, 0x1E, 0x32, 0x00, 0x00, 0x00, 0x94,
23                       0x48, 0x01, 0x80, 0x52, 0x08, 0x00, 0x00, 0xB9,
24                       0x02, 0x00, 0x80, 0xD2, 0x01, 0x00, 0x00, 0x90,
25                       0x21, 0x00, 0x40, 0xF9, 0x00, 0x00, 0x00, 0x94,
26                       0x3F, 0x04, 0x00, 0x71, 0x81, 0x00, 0x00, 0x54,
27                       0x00, 0x00, 0x00, 0x94, 0xFD, 0x7B, 0xC1, 0xA8,
28                       0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x94,
29                       0xFD, 0x7B, 0xBF, 0xA9, 0xFD, 0x03, 0x00, 0x91,
30                       0x00, 0x00, 0x00, 0x94 ]
31    relocations:
32      - offset:          0x00000070
33        type:            ARM64_RELOC_BRANCH26
34        length:          2
35        pc-rel:          true
36        extern:          true
37        symbol:          5
38      - offset:          0x00000064
39        type:            ARM64_RELOC_BRANCH26
40        length:          2
41        pc-rel:          true
42        extern:          true
43        symbol:          7
44      - offset:          0x00000060
45        type:            ARM64_RELOC_BRANCH26
46        length:          2
47        pc-rel:          true
48        extern:          true
49        symbol:          12
50      - offset:          0x00000058
51        type:            ARM64_RELOC_BRANCH26
52        length:          2
53        pc-rel:          true
54        extern:          true
55        symbol:          11
56      - offset:          0x0000004C
57        type:            ARM64_RELOC_BRANCH26
58        length:          2
59        pc-rel:          true
60        extern:          true
61        symbol:          13
62      - offset:          0x00000048
63        type:            ARM64_RELOC_GOT_LOAD_PAGEOFF12
64        length:          2
65        pc-rel:          false
66        extern:          true
67        symbol:          8
68      - offset:          0x00000044
69        type:            ARM64_RELOC_GOT_LOAD_PAGE21
70        length:          2
71        pc-rel:          true
72        extern:          true
73        symbol:          8
74      - offset:          0x00000034
75        type:            ARM64_RELOC_BRANCH26
76        length:          2
77        pc-rel:          true
78        extern:          true
79        symbol:          10
80      - offset:          0x00000024
81        type:            ARM64_RELOC_BRANCH26
82        length:          2
83        pc-rel:          true
84        extern:          true
85        symbol:          13
86      - offset:          0x00000020
87        type:            ARM64_RELOC_GOT_LOAD_PAGEOFF12
88        length:          2
89        pc-rel:          false
90        extern:          true
91        symbol:          8
92      - offset:          0x0000001C
93        type:            ARM64_RELOC_GOT_LOAD_PAGE21
94        length:          2
95        pc-rel:          true
96        extern:          true
97        symbol:          8
98      - offset:          0x0000000C
99        type:            ARM64_RELOC_BRANCH26
100        length:          2
101        pc-rel:          true
102        extern:          true
103        symbol:          10
104  - segment:         __TEXT
105    section:         __gcc_except_tab
106    type:            S_REGULAR
107    attributes:      [  ]
108    alignment:       2
109    address:         0x0000000000000074
110    content:         [ 0xFF, 0x9B, 0xAF, 0x80, 0x00, 0x03, 0x27, 0x00,
111                       0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
112                       0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
113                       0x10, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
114                       0x01, 0x28, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
115                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
116                       0xD0, 0xFF, 0xFF, 0xFF ]
117    relocations:
118      - offset:          0x00000030
119        type:            ARM64_RELOC_POINTER_TO_GOT
120        length:          2
121        pc-rel:          true
122        extern:          true
123        symbol:          9
124  - segment:         __LD
125    section:         __compact_unwind
126    type:            S_REGULAR
127    attributes:      [  ]
128    alignment:       8
129    address:         0x00000000000000A8
130    content:         [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
131                       0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
132                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
133                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
134                       0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
135                       0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44,
136                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
137                       0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
138                       0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
139                       0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
140                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
141                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]
142    relocations:
143      - offset:          0x00000040
144        type:            ARM64_RELOC_UNSIGNED
145        length:          3
146        pc-rel:          false
147        extern:          false
148        symbol:          1
149      - offset:          0x00000038
150        type:            ARM64_RELOC_UNSIGNED
151        length:          3
152        pc-rel:          false
153        extern:          false
154        symbol:          2
155      - offset:          0x00000030
156        type:            ARM64_RELOC_UNSIGNED
157        length:          3
158        pc-rel:          false
159        extern:          true
160        symbol:          14
161      - offset:          0x00000020
162        type:            ARM64_RELOC_UNSIGNED
163        length:          3
164        pc-rel:          false
165        extern:          false
166        symbol:          1
167      - offset:          0x00000000
168        type:            ARM64_RELOC_UNSIGNED
169        length:          3
170        pc-rel:          false
171        extern:          false
172        symbol:          1
173local-symbols:
174  - name:            ltmp0
175    type:            N_SECT
176    sect:            1
177    value:           0x0000000000000000
178  - name:            ltmp14
179    type:            N_SECT
180    sect:            2
181    value:           0x0000000000000074
182  - name:            GCC_except_table1
183    type:            N_SECT
184    sect:            2
185    value:           0x0000000000000074
186  - name:            ltmp21
187    type:            N_SECT
188    sect:            3
189    value:           0x00000000000000A8
190global-symbols:
191  - name:            __Z3barv
192    type:            N_SECT
193    scope:           [ N_EXT ]
194    sect:            1
195    value:           0x0000000000000028
196  - name:            __Z3foov
197    type:            N_SECT
198    scope:           [ N_EXT ]
199    sect:            1
200    value:           0x0000000000000000
201  - name:            _main
202    type:            N_SECT
203    scope:           [ N_EXT ]
204    sect:            1
205    value:           0x0000000000000068
206undefined-symbols:
207  - name:            __Unwind_Resume
208    type:            N_UNDF
209    scope:           [ N_EXT ]
210    value:           0x0000000000000000
211  - name:            __ZTIi
212    type:            N_UNDF
213    scope:           [ N_EXT ]
214    value:           0x0000000000000000
215  - name:            __ZTIl
216    type:            N_UNDF
217    scope:           [ N_EXT ]
218    value:           0x0000000000000000
219  - name:            ___cxa_allocate_exception
220    type:            N_UNDF
221    scope:           [ N_EXT ]
222    value:           0x0000000000000000
223  - name:            ___cxa_begin_catch
224    type:            N_UNDF
225    scope:           [ N_EXT ]
226    value:           0x0000000000000000
227  - name:            ___cxa_end_catch
228    type:            N_UNDF
229    scope:           [ N_EXT ]
230    value:           0x0000000000000000
231  - name:            ___cxa_throw
232    type:            N_UNDF
233    scope:           [ N_EXT ]
234    value:           0x0000000000000000
235  - name:            ___gxx_personality_v0
236    type:            N_UNDF
237    scope:           [ N_EXT ]
238    value:           0x0000000000000000
239
240...
241
242
243# CHECK: Contents of __unwind_info section:
244# CHECK:   Version:                                   0x1
245# CHECK:   Common encodings array section offset:     0x1c
246# CHECK:   Number of common encodings in array:       0x0
247# CHECK:   Personality function array section offset: 0x1c
248# CHECK:   Number of personality functions in array:  0x1
249# CHECK:   Index array section offset:                0x20
250# CHECK:   Number of indices in array:                0x2
251# CHECK:   Common encodings: (count = 0)
252# CHECK:   Personality functions: (count = 1)
253# CHECK:     personality[1]: 0x00004020
254# CHECK:   Top level indices: (count = 2)
255# CHECK:     [0]: function offset=0x00003e68, 2nd level page offset=0x00000040, LSDA offset=0x00000038
256# CHECK:     [1]: function offset=0x00003edc, 2nd level page offset=0x00000000, LSDA offset=0x00000040
257# CHECK:   LSDA descriptors:
258# CHECK:     [0]: function offset=0x00003e90, LSDA offset=0x00003f6c
259# CHECK:   Second level indices:
260# CHECK:     Second level index[0]: offset in section=0x00000040, base function offset=0x00003e68
261# CHECK:       [0]: function offset=0x00003e68, encoding=0x04000000
262# CHECK:       [1]: function offset=0x00003e90, encoding=0x54000000
263# CHECK:       [2]: function offset=0x00003ed0, encoding=0x04000000
264# CHECK-NOT: Contents of __compact_unwind section
265
266
267
268