1# RUN: ld64.lld -arch i386 -r -print_atoms %s -o %t  | FileCheck %s
2#
3# Test parsing of old __eh_frame (dwarf unwind) section that has .eh labels
4# and relocations.
5#
6
7--- !mach-o
8arch:            x86
9file-type:       MH_OBJECT
10flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
11OS:              unknown
12sections:
13  - segment:         __TEXT
14    section:         __text
15    type:            S_REGULAR
16    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
17    address:         0x0000000000000000
18    content:         [ 0x55, 0x89, 0xE5, 0x56, 0x83, 0xEC, 0x14, 0xE8,
19                       0x00, 0x00, 0x00, 0x00, 0x5E, 0xC7, 0x04, 0x24,
20                       0x04, 0x00, 0x00, 0x00, 0xE8, 0xE7, 0xFF, 0xFF,
21                       0xFF, 0xC7, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x8B,
22                       0x8E, 0x38, 0x00, 0x00, 0x00, 0x89, 0x4C, 0x24,
23                       0x04, 0x89, 0x04, 0x24, 0xC7, 0x44, 0x24, 0x08,
24                       0x00, 0x00, 0x00, 0x00, 0xE8, 0xC7, 0xFF, 0xFF,
25                       0xFF, 0x55, 0x89, 0xE5, 0x83, 0xEC, 0x08, 0xE8,
26                       0xBC, 0xFF, 0xFF, 0xFF ]
27    relocations:
28      - offset:          0x00000040
29        type:            GENERIC_RELOC_VANILLA
30        length:          2
31        pc-rel:          true
32        extern:          false
33        symbol:          1
34      - offset:          0x00000035
35        type:            GENERIC_RELOC_VANILLA
36        length:          2
37        pc-rel:          true
38        extern:          true
39        symbol:          7
40      - offset:          0x00000021
41        scattered:       true
42        type:            GENERIC_RELOC_LOCAL_SECTDIFF
43        length:          2
44        pc-rel:          false
45        value:           0x00000044
46      - offset:          0x00000000
47        scattered:       true
48        type:            GENERIC_RELOC_PAIR
49        length:          2
50        pc-rel:          false
51        value:           0x0000000C
52      - offset:          0x00000015
53        type:            GENERIC_RELOC_VANILLA
54        length:          2
55        pc-rel:          true
56        extern:          true
57        symbol:          6
58  - segment:         __IMPORT
59    section:         __pointers
60    type:            S_NON_LAZY_SYMBOL_POINTERS
61    attributes:      [  ]
62    address:         0x0000000000000044
63    content:         [ 0x00, 0x00, 0x00, 0x00 ]
64    indirect-syms:   [ 5 ]
65  - segment:         __TEXT
66    section:         __eh_frame
67    type:            S_REGULAR
68    attributes:      [  ]
69    alignment:       2
70    address:         0x0000000000000048
71    content:         [ 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72                       0x01, 0x7A, 0x52, 0x00, 0x01, 0x7C, 0x08, 0x01,
73                       0x10, 0x0C, 0x05, 0x04, 0x88, 0x01, 0x00, 0x00,
74                       0x18, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00,
75                       0x98, 0xFF, 0xFF, 0xFF, 0x39, 0x00, 0x00, 0x00,
76                       0x00, 0x41, 0x0E, 0x08, 0x84, 0x02, 0x42, 0x0D,
77                       0x04, 0x44, 0x86, 0x03, 0x18, 0x00, 0x00, 0x00,
78                       0x38, 0x00, 0x00, 0x00, 0xB5, 0xFF, 0xFF, 0xFF,
79                       0x0B, 0x00, 0x00, 0x00, 0x00, 0x41, 0x0E, 0x08,
80                       0x84, 0x02, 0x42, 0x0D, 0x04, 0x00, 0x00, 0x00 ]
81    relocations:
82      - offset:          0x0000001C
83        scattered:       true
84        type:            GENERIC_RELOC_LOCAL_SECTDIFF
85        length:          2
86        pc-rel:          false
87        value:           0x00000064
88      - offset:          0x00000000
89        scattered:       true
90        type:            GENERIC_RELOC_PAIR
91        length:          2
92        pc-rel:          false
93        value:           0x00000048
94      - offset:          0x00000020
95        scattered:       true
96        type:            GENERIC_RELOC_SECTDIFF
97        length:          2
98        pc-rel:          false
99        value:           0x00000000
100      - offset:          0x00000000
101        scattered:       true
102        type:            GENERIC_RELOC_PAIR
103        length:          2
104        pc-rel:          false
105        value:           0x00000068
106      - offset:          0x00000038
107        scattered:       true
108        type:            GENERIC_RELOC_LOCAL_SECTDIFF
109        length:          2
110        pc-rel:          false
111        value:           0x00000080
112      - offset:          0x00000000
113        scattered:       true
114        type:            GENERIC_RELOC_PAIR
115        length:          2
116        pc-rel:          false
117        value:           0x00000048
118      - offset:          0x0000003C
119        scattered:       true
120        type:            GENERIC_RELOC_SECTDIFF
121        length:          2
122        pc-rel:          false
123        value:           0x00000039
124      - offset:          0x00000000
125        scattered:       true
126        type:            GENERIC_RELOC_PAIR
127        length:          2
128        pc-rel:          false
129        value:           0x00000084
130local-symbols:
131  - name:            EH_frame0
132    type:            N_SECT
133    sect:            3
134    value:           0x0000000000000048
135global-symbols:
136  - name:            __Z3barv
137    type:            N_SECT
138    scope:           [ N_EXT ]
139    sect:            1
140    value:           0x0000000000000039
141  - name:            __Z3barv.eh
142    type:            N_SECT
143    scope:           [ N_EXT ]
144    sect:            3
145    value:           0x000000000000007C
146  - name:            __Z3foov
147    type:            N_SECT
148    scope:           [ N_EXT ]
149    sect:            1
150    value:           0x0000000000000000
151  - name:            __Z3foov.eh
152    type:            N_SECT
153    scope:           [ N_EXT ]
154    sect:            3
155    value:           0x0000000000000060
156undefined-symbols:
157  - name:            __ZTIi
158    type:            N_UNDF
159    scope:           [ N_EXT ]
160    value:           0x0000000000000000
161  - name:            ___cxa_allocate_exception
162    type:            N_UNDF
163    scope:           [ N_EXT ]
164    value:           0x0000000000000000
165  - name:            ___cxa_throw
166    type:            N_UNDF
167    scope:           [ N_EXT ]
168    value:           0x0000000000000000
169...
170
171# CHECK: defined-atoms:
172# CHECK:   - ref-name:        [[CIE:L[L0-9]+]]
173# CHECK:     type:            unwind-cfi
174# CHECK:     content:
175# CHECK:   - type:            unwind-cfi
176# CHECK:     content:
177# CHECK:     references:
178# CHECK:       - kind:            negDelta32
179# CHECK:         offset:          4
180# CHECK:         target:          [[CIE]]
181# CHECK:       - kind:            delta32
182# CHECK:         offset:          8
183# CHECK:         target:          __Z3foov
184# CHECK:   - type:            unwind-cfi
185# CHECK:     content:
186# CHECK:     references:
187# CHECK:       - kind:            negDelta32
188# CHECK:         offset:          4
189# CHECK:         target:          [[CIE]]
190# CHECK:       - kind:            delta32
191# CHECK:         offset:          8
192# CHECK:         target:          __Z3barv
193
194