1# RUN: ld64.lld.darwinold -arch x86_64 -r -print_atoms %s -o %t | FileCheck %s
2#
3# Test parsing of x86_64 __eh_frame (dwarf unwind) relocations.
4
5--- !mach-o
6arch:            x86_64
7file-type:       MH_OBJECT
8flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
9compat-version:  0.0
10current-version: 0.0
11has-UUID:        false
12OS:              unknown
13sections:
14  - segment:         __TEXT
15    section:         __text
16    type:            S_REGULAR
17    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
18    alignment:       16
19    address:         0x0000000000000000
20    content:         [ 0x55, 0x48, 0x89, 0xE5, 0xE8, 0x00, 0x00, 0x00,
21                       0x00, 0x5D, 0xC3, 0x48, 0x89, 0xC7, 0xE8, 0x00,
22                       0x00, 0x00, 0x00, 0x5D, 0xE9, 0x00, 0x00, 0x00,
23                       0x00, 0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00,
24                       0x55, 0x48, 0x89, 0xE5, 0x5D, 0xC3, 0x66, 0x2E,
25                       0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
26                       0x55, 0x48, 0x89, 0xE5, 0xE8, 0x00, 0x00, 0x00,
27                       0x00, 0x5D, 0xC3, 0x48, 0x89, 0xC7, 0xE8, 0x00,
28                       0x00, 0x00, 0x00, 0x5D, 0xE9, 0x00, 0x00, 0x00,
29                       0x00 ]
30  - segment:         __TEXT
31    section:         __gcc_except_tab
32    type:            S_REGULAR
33    attributes:      [  ]
34    alignment:       4
35    address:         0x000000000000004C
36    content:         [ 0xFF, 0x9B, 0xA2, 0x80, 0x80, 0x00, 0x03, 0x1A,
37                       0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
38                       0x0B, 0x00, 0x00, 0x00, 0x01, 0x09, 0x00, 0x00,
39                       0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40                       0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
41                       0xFF, 0x9B, 0xA2, 0x80, 0x80, 0x00, 0x03, 0x1A,
42                       0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
43                       0x0B, 0x00, 0x00, 0x00, 0x01, 0x09, 0x00, 0x00,
44                       0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45                       0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 ]
46  - segment:         __TEXT
47    section:         __eh_frame
48    type:            S_COALESCED
49    attributes:      [  ]
50    alignment:       8
51    address:         0x0000000000000100
52    content:         [ 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53                       0x03, 0x7A, 0x50, 0x4C, 0x52, 0x00, 0x01, 0x78,
54                       0x10, 0x07, 0x9B, 0x04, 0x00, 0x00, 0x00, 0x10,
55                       0x10, 0x0C, 0x07, 0x08, 0x90, 0x01, 0x00, 0x00,
56                       0x2C, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
57                       0xD8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
58                       0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59                       0x08, 0x13, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
60                       0xFF, 0x41, 0x0E, 0x10, 0x86, 0x02, 0x43, 0x0D,
61                       0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62                       0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63                       0x03, 0x7A, 0x52, 0x00, 0x01, 0x78, 0x10, 0x01,
64                       0x10, 0x0C, 0x07, 0x08, 0x90, 0x01, 0x00, 0x00,
65                       0x24, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00,
66                       0xB0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
67                       0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68                       0x00, 0x41, 0x0E, 0x10, 0x86, 0x02, 0x43, 0x0D,
69                       0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70                       0x2C, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
71                       0x98, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
72                       0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73                       0x08, 0xCB, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
74                       0xFF, 0x41, 0x0E, 0x10, 0x86, 0x02, 0x43, 0x0D,
75                       0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]
76    relocations:
77      - offset:          0x00000013
78        type:            X86_64_RELOC_GOT
79        length:          2
80        pc-rel:          true
81        extern:          true
82        symbol:          8
83local-symbols:
84  - name:            GCC_except_table0
85    type:            N_SECT
86    sect:            2
87    value:           0x000000000000004C
88  - name:            GCC_except_table2
89    type:            N_SECT
90    sect:            2
91    value:           0x0000000000000074
92global-symbols:
93  - name:            _catchMyException1
94    type:            N_SECT
95    scope:           [ N_EXT ]
96    sect:            1
97    value:           0x0000000000000000
98  - name:            _catchMyException2
99    type:            N_SECT
100    scope:           [ N_EXT ]
101    sect:            1
102    value:           0x0000000000000030
103  - name:            _bar
104    type:            N_SECT
105    scope:           [ N_EXT ]
106    sect:            1
107    value:           0x0000000000000020
108undefined-symbols:
109  - name:            _foo
110    type:            N_UNDF
111    scope:           [ N_EXT ]
112    value:           0x0000000000000000
113  - name:            ___cxa_begin_catch
114    type:            N_UNDF
115    scope:           [ N_EXT ]
116    value:           0x0000000000000000
117  - name:            ___cxa_end_catch
118    type:            N_UNDF
119    scope:           [ N_EXT ]
120    value:           0x0000000000000000
121  - name:            ___gxx_personality_v0
122    type:            N_UNDF
123    scope:           [ N_EXT ]
124    value:           0x0000000000000000
125page-size:       0x00000000
126...
127
128# Check that LSDA fields are fixed up correctly, even when there are multiple
129# CIEs involved.
130#
131# (1) Check that we can relocate an LSDA at all. Requires correct interpretation
132#     of augmentation data strings in CIEs and augmentation data fields of FDEs.
133#
134# CHECK:       - type:            unwind-cfi
135# CHECK-NOT:   - type:
136# CHECK:         references:
137# CHECK-NEXT:      - kind:            negDelta32
138# CHECK-NEXT:        offset:          4
139# CHECK-NEXT:        target:          L002
140# CHECK-NEXT:      - kind:            unwindFDEToFunction
141# CHECK-NEXT:        offset:          8
142# CHECK-NEXT:        target:          _catchMyException1
143# CHECK-NEXT:      - kind:            unwindFDEToFunction
144# CHECK-NEXT:        offset:          25
145# CHECK-NEXT:        target:          GCC_except_table0
146#
147# (2) Check that we have an intervening FDE with a different CIE.
148#     If the test fails here then test (3) probably isn't testing what it
149#     should, and this test-case should be updated.
150#
151# CHECK:       - type:            unwind-cfi
152# CHECK-NOT:   - type:
153# CHECK:         references:
154# CHECK-NEXT:      - kind:            negDelta32
155# CHECK-NEXT:        offset:          4
156# CHECK-NEXT:        target:          L001
157# CHECK-NEXT:      - kind:            unwindFDEToFunction
158# CHECK-NEXT:        offset:          8
159# CHECK-NEXT:        target:          _bar
160#
161# (3) Check that we can relocate the LSDA on a second FDE that references the
162#     original CIE from (1). Requires us to match this FDE up with the correct
163#     CIE.
164#
165# CHECK-NEXT:  - type:            unwind-cfi
166# CHECK-NOT:   - type:
167# CHECK:         references:
168# CHECK-NEXT:      - kind:            negDelta32
169# CHECK-NEXT:        offset:          4
170# CHECK-NEXT:        target:          L002
171# CHECK-NEXT:      - kind:            unwindFDEToFunction
172# CHECK-NEXT:        offset:          8
173# CHECK-NEXT:        target:          _catchMyException2
174# CHECK-NEXT:      - kind:            unwindFDEToFunction
175# CHECK-NEXT:        offset:          25
176# CHECK-NEXT:        target:          GCC_except_table2
177