• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: ld64.lld -arch arm64 -r -print_atoms %s -o %t | FileCheck %s
2# RUN: ld64.lld -arch arm64 -r -print_atoms %t -o %t2 | FileCheck %s
3# RUN: llvm-objdump -r -s --section="__eh_frame" --macho %t | FileCheck --check-prefix=CODE %s
4# RUN: llvm-objdump -r -s --section="__eh_frame" --macho %t2 | FileCheck --check-prefix=CODE %s
5
6
7--- !mach-o
8arch:            arm64
9file-type:       MH_OBJECT
10flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
11compat-version:  0.0
12current-version: 0.0
13has-UUID:        false
14OS:              unknown
15sections:
16  - segment:         __TEXT
17    section:         __text
18    type:            S_REGULAR
19    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
20    alignment:       4
21    address:         0x0000000000000000
22    content:         [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23                       0xC0, 0x03, 0x5F, 0xD6, 0xC0, 0x03, 0x5F, 0xD6,
24                       0xC0, 0x03, 0x5F, 0xD6 ]
25  - segment:         __TEXT
26    section:         __gcc_except_tab
27    type:            S_REGULAR
28    attributes:      [  ]
29    address:         0x0000000000000014
30    content:         [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]
31  - segment:         __DATA
32    section:         __data
33    type:            S_REGULAR
34    attributes:      [  ]
35    address:         0x000000000000001C
36    content:         [ 0x00, 0x00, 0x00, 0x00 ]
37  - segment:         __LD
38    section:         __compact_unwind
39    type:            S_REGULAR
40    attributes:      [  ]
41    alignment:       8
42    address:         0x0000000000000020
43    content:         [ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44                       0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
45                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47                       0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48                       0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
49                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]
51    relocations:
52      - offset:          0x00000020
53        type:            ARM64_RELOC_UNSIGNED
54        length:          3
55        pc-rel:          false
56        extern:          false
57        symbol:          1
58      - offset:          0x00000000
59        type:            ARM64_RELOC_UNSIGNED
60        length:          3
61        pc-rel:          false
62        extern:          false
63        symbol:          1
64  - segment:         __TEXT
65    section:         __eh_frame
66    type:            S_COALESCED
67    attributes:      [  ]
68    alignment:       8
69    address:         0x0000000000000060
70    content:         [ 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71                       0x03, 0x7A, 0x50, 0x4C, 0x52, 0x00, 0x01, 0x78,
72                       0x1E, 0x07, 0x9B, 0xED, 0xFF, 0xFF, 0xFF, 0x10,
73                       0x10, 0x0C, 0x1F, 0x00, 0x28, 0x00, 0x00, 0x00,
74                       0x20, 0x00, 0x00, 0x00, 0xDC, 0xFF, 0xFF, 0xFF,
75                       0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00,
76                       0x00, 0x00, 0x00, 0x00, 0x08, 0xCB, 0xFF, 0xFF,
77                       0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0E, 0x10, 0x9E,
78                       0x01, 0x9D, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
79                       0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
80                       0x03, 0x7A, 0x50, 0x4C, 0x52, 0x00, 0x01, 0x78,
81                       0x1E, 0x07, 0x9B, 0xA9, 0xFF, 0xFF, 0xFF, 0x10,
82                       0x10, 0x0C, 0x1F, 0x00, 0x28, 0x00, 0x00, 0x00,
83                       0x20, 0x00, 0x00, 0x00, 0x94, 0xFF, 0xFF, 0xFF,
84                       0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0x00,
85                       0x00, 0x00, 0x00, 0x00, 0x08, 0x83, 0xFF, 0xFF,
86                       0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0E, 0x10, 0x9E,
87                       0x01, 0x9D, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 ]
88    relocations:
89      - offset:          0x0000007D
90        type:            ARM64_RELOC_SUBTRACTOR
91        length:          3
92        pc-rel:          false
93        extern:          true
94        symbol:          6
95      - offset:          0x0000007D
96        type:            ARM64_RELOC_UNSIGNED
97        length:          3
98        pc-rel:          false
99        extern:          true
100        symbol:          3
101      - offset:          0x0000006C
102        type:            ARM64_RELOC_SUBTRACTOR
103        length:          3
104        pc-rel:          false
105        extern:          true
106        symbol:          6
107      - offset:          0x0000006C
108        type:            ARM64_RELOC_UNSIGNED
109        length:          3
110        pc-rel:          false
111        extern:          true
112        symbol:          8
113      - offset:          0x0000005B
114        type:            ARM64_RELOC_POINTER_TO_GOT
115        length:          2
116        pc-rel:          true
117        extern:          true
118        symbol:          10
119      - offset:          0x00000035
120        type:            ARM64_RELOC_SUBTRACTOR
121        length:          3
122        pc-rel:          false
123        extern:          true
124        symbol:          6
125      - offset:          0x00000035
126        type:            ARM64_RELOC_UNSIGNED
127        length:          3
128        pc-rel:          false
129        extern:          true
130        symbol:          2
131      - offset:          0x00000024
132        type:            ARM64_RELOC_SUBTRACTOR
133        length:          3
134        pc-rel:          false
135        extern:          true
136        symbol:          6
137      - offset:          0x00000024
138        type:            ARM64_RELOC_UNSIGNED
139        length:          3
140        pc-rel:          false
141        extern:          true
142        symbol:          7
143      - offset:          0x00000013
144        type:            ARM64_RELOC_POINTER_TO_GOT
145        length:          2
146        pc-rel:          true
147        extern:          true
148        symbol:          9
149local-symbols:
150  - name:            ltmp0
151    type:            N_SECT
152    sect:            1
153    value:           0x0000000000000000
154  - name:            ltmp1
155    type:            N_SECT
156    sect:            2
157    value:           0x0000000000000014
158  - name:            _bar1
159    type:            N_SECT
160    sect:            2
161    value:           0x0000000000000014
162  - name:            _bar2
163    type:            N_SECT
164    sect:            2
165    value:           0x0000000000000018
166  - name:            ltmp12
167    type:            N_SECT
168    sect:            3
169    value:           0x000000000000001C
170  - name:            ltmp13
171    type:            N_SECT
172    sect:            4
173    value:           0x0000000000000020
174  - name:            ltmp16
175    type:            N_SECT
176    sect:            5
177    value:           0x0000000000000060
178global-symbols:
179  - name:            __Z3fooi
180    type:            N_SECT
181    scope:           [ N_EXT ]
182    sect:            1
183    value:           0x0000000000000008
184  - name:            __Z4foo2i
185    type:            N_SECT
186    scope:           [ N_EXT ]
187    sect:            1
188    value:           0x000000000000000C
189  - name:            __gxx_personality_v0
190    type:            N_SECT
191    scope:           [ N_EXT ]
192    sect:            1
193    value:           0x0000000000000000
194  - name:            __gxx_personality_v1
195    type:            N_SECT
196    scope:           [ N_EXT ]
197    sect:            1
198    value:           0x0000000000000004
199  - name:            _main
200    type:            N_SECT
201    scope:           [ N_EXT ]
202    sect:            1
203    value:           0x0000000000000010
204  - name:            _someData
205    type:            N_SECT
206    scope:           [ N_EXT ]
207    sect:            3
208    value:           0x000000000000001C
209page-size:       0x00000000
210...
211
212# CHECK: --- !native
213# CHECK: path:            '<linker-internal>'
214# CHECK: defined-atoms:
215# CHECK:   - ref-name:        L000
216# CHECK:     type:            unwind-cfi
217# CHECK:     content:         [ 18, 00, 00, 00, 00, 00, 00, 00, 03, 7A, 50, 4C,
218# CHECK:                        52, 00, 01, 78, 1E, 07, 9B, {{..}}, {{..}}, {{..}}, {{..}}, 10,
219# CHECK:                        10, 0C, 1F, 00 ]
220# CHECK:     alignment:       8
221# CHECK:     references:
222# CHECK:       - kind:            unwindCIEToPersonalityFunction
223# CHECK:         offset:          19
224# CHECK:         target:          __gxx_personality_v0
225# CHECK:   - type:            unwind-cfi
226# CHECK:     content:         [ 28, 00, 00, 00, 20, 00, 00, 00, {{..}}, {{..}}, {{..}}, {{..}},
227# CHECK:                        {{..}}, {{..}}, {{..}}, {{..}}, 04, 00, 00, 00, 00, 00, 00, 00,
228# CHECK:                        08, {{..}}, {{..}}, {{..}}, {{..}}, {{..}}, {{..}}, {{..}}, {{..}}, 0E, 10, 9E,
229# CHECK:                        01, 9D, 02, 00, 00, 00, 00, 00 ]
230# CHECK:     alignment:       4 mod 8
231# CHECK:     references:
232# CHECK:       - kind:            negDelta32
233# CHECK:         offset:          4
234# CHECK:         target:          L000
235# CHECK:       - kind:            unwindFDEToFunction
236# CHECK:         offset:          8
237# CHECK:         target:          __Z3fooi
238# CHECK:       - kind:            unwindFDEToFunction
239# CHECK:         offset:          25
240# CHECK:         target:          _bar1
241# CHECK:   - ref-name:        L001
242# CHECK:     type:            unwind-cfi
243# CHECK:     content:         [ 18, 00, 00, 00, 00, 00, 00, 00, 03, 7A, 50, 4C,
244# CHECK:                        52, 00, 01, 78, 1E, 07, 9B, {{..}}, {{..}}, {{..}}, {{..}}, 10,
245# CHECK:                        10, 0C, 1F, 00 ]
246# CHECK:     alignment:       8
247# CHECK:     references:
248# CHECK:       - kind:            unwindCIEToPersonalityFunction
249# CHECK:         offset:          19
250# CHECK:         target:          __gxx_personality_v1
251# CHECK:   - type:            unwind-cfi
252# CHECK:     content:         [ 28, 00, 00, 00, 20, 00, 00, 00, {{..}}, {{..}}, {{..}}, {{..}},
253# CHECK:                        {{..}}, {{..}}, {{..}}, {{..}}, 04, 00, 00, 00, 00, 00, 00, 00,
254# CHECK:                        08, {{..}}, {{..}}, {{..}}, {{..}}, {{..}}, {{..}}, {{..}}, {{..}}, 0E, 10, 9E,
255# CHECK:                        01, 9D, 02, 00, 00, 00, 00, 00 ]
256# CHECK:     alignment:       4 mod 8
257# CHECK:     references:
258# CHECK:       - kind:            negDelta32
259# CHECK:         offset:          4
260# CHECK:         target:          L001
261# CHECK:       - kind:            unwindFDEToFunction
262# CHECK:         offset:          8
263# CHECK:         target:          __Z4foo2i
264# CHECK:       - kind:            unwindFDEToFunction
265# CHECK:         offset:          25
266# CHECK:         target:          _bar2
267# CHECK:   - name:            _bar1
268# CHECK:     type:            unwind-lsda
269# CHECK:     content:         [ 00, 00, 00, 00 ]
270# CHECK:   - name:            _bar2
271# CHECK:     type:            unwind-lsda
272# CHECK:     content:         [ 00, 00, 00, 00 ]
273# CHECK:   - name:            _someData
274# CHECK:     scope:           global
275# CHECK:     type:            data
276# CHECK:     content:         [ 00, 00, 00, 00 ]
277# CHECK:   - name:            __gxx_personality_v0
278# CHECK:     scope:           global
279# CHECK:     content:         [ 00, 00, 00, 00 ]
280# CHECK:     alignment:       4
281# CHECK:   - name:            __gxx_personality_v1
282# CHECK:     scope:           global
283# CHECK:     content:         [ 00, 00, 00, 00 ]
284# CHECK:     alignment:       4
285# CHECK:   - name:            __Z3fooi
286# CHECK:     scope:           global
287# CHECK:     content:         [ C0, 03, 5F, D6 ]
288# CHECK:     alignment:       4
289# CHECK:   - name:            __Z4foo2i
290# CHECK:     scope:           global
291# CHECK:     content:         [ C0, 03, 5F, D6 ]
292# CHECK:     alignment:       4
293# CHECK:   - name:            _main
294# CHECK:     scope:           global
295# CHECK:     content:         [ C0, 03, 5F, D6 ]
296# CHECK:     alignment:       4
297# CHECK: ...
298
299# # Make sure we don't have any relocations in the __eh_frame section
300# CODE-NOT: RELOCATION RECORDS FOR [__eh_frame]
301
302# Also make sure the reloc for the CIE->personality function is the
303# correct offset
304# It should be the offset from the fixup location back to the address
305# of the function we are referencing
306# CODE: Contents of section __TEXT,__eh_frame:
307# This is the CIE:
308# CODE-NEXT: {{[0-9abcdef]*}} 18000000 00000000 037a504c 52000178
309# CODE-NEXT: {{[0-9abcdef]*}} 1e079bd1 ffffff10 100c1f00 28000000
310# This is the important offset for CIE->pfunc
311#                                   ^~~~~~~~~
312# Then we have an FDE starting from 28000000 above
313# CODE-NEXT: {{[0-9abcdef]*}} 20000000 c8ffffff ffffffff 04000000
314# CODE-NEXT: {{[0-9abcdef]*}} 00000000 08c3ffff ffffffff ff0e109e
315# And a new CIE starts at this 00000018 right below here
316# CODE-NEXT: {{[0-9abcdef]*}} 019d0200 00000000 18000000 00000000
317# CODE-NEXT: {{[0-9abcdef]*}} 037a504c 52000178 1e079b8d ffffff10
318# This is the important offset for its CIE->pfunc     ^~~~~~~~~
319