llvm-project
225 строк · 6.5 Кб
1## Tests that lld correctly resolves the custom personality referenced by objc code in an archive.
2
3# REQUIRES: x86
4# RUN: rm -rf %t; split-file %s %t
5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-iossimulator %t/defined.s -o %t/defined.o
6# RUN: yaml2obj %t/combined.yaml > %t/combined.o
7# RUN: llvm-ar r %t/pack.a %t/defined.o %t/combined.o
8# RUN: %no-arg-lld -dylib -arch x86_64 -platform_version ios-simulator 12.0.0 15.0 -ObjC %t/pack.a -o %t/a.dylib
9# RUN: llvm-objdump --macho --syms %t/a.dylib | FileCheck %s
10# RUN: %no-arg-lld -dylib -arch x86_64 -platform_version ios-simulator 12.0.0 15.0 -ObjC --start-lib %t/defined.o %t/combined.o --end-lib -o %t/a.dylib
11# RUN: llvm-objdump --macho --syms %t/a.dylib | FileCheck %s
12
13# CHECK: SYMBOL TABLE:
14# CHECK: {{.*}} l F __TEXT,__text _my_personality
15
16
17#--- defined.s
18.private_extern _my_personality
19
20.text
21.no_dead_strip _my_personality
22_my_personality:
23.cfi_startproc
24.cfi_def_cfa_offset 16
25.cfi_endproc
26nop
27.subsections_via_symbols
28
29## combined.yaml is produced from combined.o below:
30## lvm-mc -filetype=obj -triple=x86_64-apple-iossimulator %t/objc.s -o %t/objc.o
31## ld -r -o combined.o defined.o objc.o
32## // objc.s:
33## .section __TEXT,__text
34## .global _OBJC_CLASS_$_MyTest
35## .no_dead_strip _OBJC_CLASS_$_MyTest
36## _OBJC_CLASS_$_MyTest:
37## .cfi_startproc
38## .cfi_personality 155, _my_personality
39## .cfi_def_cfa_offset 16
40## ret
41## .cfi_endproc
42##
43## ret
44## .subsections_via_symbols
45
46#--- combined.yaml
47--- !mach-o
48FileHeader:
49magic: 0xFEEDFACF
50cputype: 0x1000007
51cpusubtype: 0x3
52filetype: 0x1
53ncmds: 3
54sizeofcmds: 352
55flags: 0x2000
56reserved: 0x0
57LoadCommands:
58- cmd: LC_SEGMENT_64
59cmdsize: 312
60segname: ''
61vmaddr: 0
62vmsize: 152
63fileoff: 416
64filesize: 152
65maxprot: 7
66initprot: 7
67nsects: 3
68flags: 0
69Sections:
70- sectname: __text
71segname: __TEXT
72addr: 0x0
73size: 3
74offset: 0x1A0
75align: 0
76reloff: 0x0
77nreloc: 0
78flags: 0x80000400
79reserved1: 0x0
80reserved2: 0x0
81reserved3: 0x0
82content: 90C3C3
83- sectname: __eh_frame
84segname: __TEXT
85addr: 0x8
86size: 80
87offset: 0x1A8
88align: 3
89reloff: 0x238
90nreloc: 5
91flags: 0x0
92reserved1: 0x0
93reserved2: 0x0
94reserved3: 0x0
95content: 1400000000000000017A520001781001100C0708900100001800000000000000017A505200017810069B04000000100C070890011800000004000000F8FFFFFFFFFFFFFF0100000000000000000E1000
96relocations:
97- address: 0x2A
98symbolnum: 0
99pcrel: true
100length: 2
101extern: true
102type: 4
103scattered: false
104value: 0
105- address: 0x38
106symbolnum: 2
107pcrel: false
108length: 2
109extern: true
110type: 5
111scattered: false
112value: 0
113- address: 0x38
114symbolnum: 3
115pcrel: false
116length: 2
117extern: true
118type: 0
119scattered: false
120value: 0
121- address: 0x3C
122symbolnum: 3
123pcrel: false
124length: 3
125extern: true
126type: 5
127scattered: false
128value: 0
129- address: 0x3C
130symbolnum: 4
131pcrel: false
132length: 3
133extern: true
134type: 0
135scattered: false
136value: 0
137- sectname: __compact_unwind
138segname: __LD
139addr: 0x58
140size: 64
141offset: 0x1F8
142align: 3
143reloff: 0x260
144nreloc: 3
145flags: 0x2000000
146reserved1: 0x0
147reserved2: 0x0
148reserved3: 0x0
149content: '00000000000000000100000000000202000000000000000000000000000000000000000000000000020000000000020200000000000000000000000000000000'
150relocations:
151- address: 0x0
152symbolnum: 0
153pcrel: false
154length: 3
155extern: true
156type: 0
157scattered: false
158value: 0
159- address: 0x20
160symbolnum: 4
161pcrel: false
162length: 3
163extern: true
164type: 0
165scattered: false
166value: 0
167- address: 0x30
168symbolnum: 0
169pcrel: false
170length: 3
171extern: true
172type: 0
173scattered: false
174value: 0
175- cmd: LC_SYMTAB
176cmdsize: 24
177symoff: 632
178nsyms: 5
179stroff: 712
180strsize: 64
181- cmd: LC_DATA_IN_CODE
182cmdsize: 16
183dataoff: 632
184datasize: 0
185LinkEditData:
186NameList:
187- n_strx: 23
188n_type: 0x1E
189n_sect: 1
190n_desc: 32
191n_value: 0
192- n_strx: 39
193n_type: 0xE
194n_sect: 2
195n_desc: 0
196n_value: 8
197- n_strx: 39
198n_type: 0xE
199n_sect: 2
200n_desc: 0
201n_value: 32
202- n_strx: 49
203n_type: 0xE
204n_sect: 2
205n_desc: 0
206n_value: 60
207- n_strx: 2
208n_type: 0xF
209n_sect: 1
210n_desc: 32
211n_value: 1
212StringTable:
213- ' '
214- '_OBJC_CLASS_$_MyTest'
215- _my_personality
216- EH_Frame1
217- func.eh
218- ''
219- ''
220- ''
221- ''
222- ''
223- ''
224- ''
225...
226