[X86][MC,LLD][NFC] Rename R_X86_64_REX2_GOTPCRELX (#116737)
[llvm-project.git] / lld / test / MachO / objc-category-merging-swift.s
blob7a084d9310d6c62bac397b991f8acda577e0f1ea
1 # REQUIRES: aarch64
2 # RUN: rm -rf %t; mkdir %t && cd %t
4 ############ Test merging multiple categories into a single category ############
5 ## Apply category merging to swiftc code just make sure we can handle addends
6 ## and don't erase category names for swift -- in order to not crash
7 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o cat_swift.o %s
8 # RUN: %lld -arch arm64 -dylib -o cat_swift.dylib cat_swift.o -objc_category_merging -no_objc_relative_method_lists
9 # RUN: llvm-objdump --objc-meta-data --macho cat_swift.dylib | FileCheck %s --check-prefixes=CHECK-MERGE
11 ; CHECK-MERGE: Contents of (__DATA_CONST,__objc_classlist) section
12 ; CHECK-MERGE-NEXT: _$s11SimpleClassAACN
13 ; CHECK-MERGE-NEXT: isa {{.+}} _OBJC_METACLASS_$__TtC11SimpleClass11SimpleClass
14 ; CHECK-MERGE-NEXT: superclass 0x0
15 ; CHECK-MERGE-NEXT: cache 0x0
16 ; CHECK-MERGE-NEXT: vtable 0x0
17 ; CHECK-MERGE-NEXT: data {{.+}} (struct class_ro_t *) Swift class
18 ; CHECK-MERGE-NEXT: flags 0x80
19 ; CHECK-MERGE-NEXT: instanceStart 8
20 ; CHECK-MERGE-NEXT: instanceSize 8
21 ; CHECK-MERGE-NEXT: reserved 0x0
22 ; CHECK-MERGE-NEXT: ivarLayout 0x0
23 ; CHECK-MERGE-NEXT: name {{.+}} _TtC11SimpleClass11SimpleClass
24 ; CHECK-MERGE-NEXT: baseMethods {{.+}} (struct method_list_t *)
25 ; CHECK-MERGE-NEXT: entsize 24
26 ; CHECK-MERGE-NEXT: count 3
27 ; CHECK-MERGE-NEXT: name {{.+}} categoryInstanceMethod
28 ; CHECK-MERGE-NEXT: types {{.+}} q16@0:8
29 ; CHECK-MERGE-NEXT: imp _$s11SimpleClassAAC22categoryInstanceMethodSiyFTo
30 ; CHECK-MERGE-NEXT: name {{.+}} baseClassInstanceMethod
31 ; CHECK-MERGE-NEXT: types {{.+}} i16@0:8
32 ; CHECK-MERGE-NEXT: imp _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyFTo
33 ; CHECK-MERGE-NEXT: name {{.+}} init
34 ; CHECK-MERGE-NEXT: types {{.+}} @16@0:8
35 ; CHECK-MERGE-NEXT: imp _$s11SimpleClassAACABycfcTo
36 ; CHECK-MERGE-NEXT: baseProtocols 0x0
37 ; CHECK-MERGE-NEXT: ivars 0x0
38 ; CHECK-MERGE-NEXT: weakIvarLayout 0x0
39 ; CHECK-MERGE-NEXT: baseProperties 0x0
40 ; CHECK-MERGE-NEXT: Meta Class
41 ; CHECK-MERGE-NEXT: isa 0x0
42 ; CHECK-MERGE-NEXT: superclass 0x0
43 ; CHECK-MERGE-NEXT: cache 0x0
44 ; CHECK-MERGE-NEXT: vtable 0x0
45 ; CHECK-MERGE-NEXT: data {{.+}} (struct class_ro_t *)
46 ; CHECK-MERGE-NEXT: flags 0x81 RO_META
47 ; CHECK-MERGE-NEXT: instanceStart 40
48 ; CHECK-MERGE-NEXT: instanceSize 40
49 ; CHECK-MERGE-NEXT: reserved 0x0
50 ; CHECK-MERGE-NEXT: ivarLayout 0x0
51 ; CHECK-MERGE-NEXT: name {{.+}} _TtC11SimpleClass11SimpleClass
52 ; CHECK-MERGE-NEXT: baseMethods 0x0 (struct method_list_t *)
53 ; CHECK-MERGE-NEXT: baseProtocols 0x0
54 ; CHECK-MERGE-NEXT: ivars 0x0
55 ; CHECK-MERGE-NEXT: weakIvarLayout 0x0
56 ; CHECK-MERGE-NEXT: baseProperties 0x0
57 ; CHECK-MERGE-NEXT: Contents of (__DATA_CONST,__objc_imageinfo) section
58 ; CHECK-MERGE-NEXT: version 0
59 ; CHECK-MERGE-NEXT: flags 0x740 OBJC_IMAGE_HAS_CATEGORY_CLASS_PROPERTIES Swift 5 or later
61 ; ================== Generated from Swift: ==================
62 ;; > xcrun swiftc --version
63 ;; swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)
64 ;; > xcrun swiftc -S SimpleClass.swift -o SimpleClass.s
65 ; import Foundation
66 ; @objc class SimpleClass: NSObject {
67 ; @objc func baseClassInstanceMethod() -> Int32 {
68 ; return 2
69 ; }
70 ; }
71 ; extension SimpleClass {
72 ; @objc func categoryInstanceMethod() -> Int {
73 ; return 3
74 ; }
75 ; }
77 ; ================== Generated from Swift: ==================
78 .section __TEXT,__text,regular,pure_instructions
79 .build_version macos, 11, 0 sdk_version 12, 0
80 .globl _main
81 .p2align 2
82 _main:
83 .cfi_startproc
84 mov w0, #0
85 ret
86 .cfi_endproc
88 .private_extern _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF
89 .globl _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF
90 .p2align 2
91 _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF:
92 .cfi_startproc
93 ret
94 .cfi_endproc
96 .p2align 2
97 _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyFTo:
98 .cfi_startproc
99 ret
100 .cfi_endproc
102 .private_extern _$s11SimpleClassAACABycfC
103 .globl _$s11SimpleClassAACABycfC
104 .p2align 2
105 _$s11SimpleClassAACABycfC:
106 .cfi_startproc
108 .cfi_endproc
110 .private_extern _$s11SimpleClassAACABycfc
111 .globl _$s11SimpleClassAACABycfc
112 .p2align 2
113 _$s11SimpleClassAACABycfc:
114 .cfi_startproc
116 .cfi_endproc
118 .private_extern _$s11SimpleClassAACMa
119 .globl _$s11SimpleClassAACMa
120 .p2align 2
121 _$s11SimpleClassAACMa:
124 .p2align 2
125 _$s11SimpleClassAACABycfcTo:
126 .cfi_startproc
128 .cfi_endproc
130 .private_extern _$s11SimpleClassAACfD
131 .globl _$s11SimpleClassAACfD
132 .p2align 2
133 _$s11SimpleClassAACfD:
134 .cfi_startproc
136 .cfi_endproc
138 .private_extern _$s11SimpleClassAAC22categoryInstanceMethodSiyF
139 .globl _$s11SimpleClassAAC22categoryInstanceMethodSiyF
140 .p2align 2
141 _$s11SimpleClassAAC22categoryInstanceMethodSiyF:
142 .cfi_startproc
144 .cfi_endproc
146 .p2align 2
147 _$s11SimpleClassAAC22categoryInstanceMethodSiyFTo:
148 .cfi_startproc
150 .cfi_endproc
152 .section __TEXT,__objc_methname,cstring_literals
153 "L_selector_data(init)":
154 .asciz "init"
156 .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip
157 .p2align 3, 0x0
158 "L_selector(init)":
159 .quad "L_selector_data(init)"
161 .section __TEXT,__objc_methname,cstring_literals
162 "L_selector_data(dealloc)":
163 .asciz "dealloc"
165 .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip
166 .p2align 3, 0x0
167 "L_selector(dealloc)":
168 .quad "L_selector_data(dealloc)"
170 .section __TEXT,__swift5_entry,regular,no_dead_strip
171 .p2align 2, 0x0
172 l_entry_point:
173 .long _main-l_entry_point
174 .long 0
176 .private_extern _OBJC_METACLASS_$__TtC11SimpleClass11SimpleClass
177 .section __DATA,__data
178 .globl _OBJC_METACLASS_$__TtC11SimpleClass11SimpleClass
179 .p2align 3, 0x0
180 _OBJC_METACLASS_$__TtC11SimpleClass11SimpleClass:
181 .quad _OBJC_METACLASS_$_NSObject
182 .quad _OBJC_METACLASS_$_NSObject
183 .quad __objc_empty_cache
184 .quad 0
185 .quad __METACLASS_DATA__TtC11SimpleClass11SimpleClass
187 .section __TEXT,__cstring,cstring_literals
188 .p2align 4, 0x0
189 l_.str.30._TtC11SimpleClass11SimpleClass:
190 .asciz "_TtC11SimpleClass11SimpleClass"
192 .section __DATA,__objc_const
193 .p2align 3, 0x0
194 __METACLASS_DATA__TtC11SimpleClass11SimpleClass:
195 .long 129
196 .long 40
197 .long 40
198 .long 0
199 .quad 0
200 .quad l_.str.30._TtC11SimpleClass11SimpleClass
201 .quad 0
202 .quad 0
203 .quad 0
204 .quad 0
205 .quad 0
207 .section __TEXT,__objc_methname,cstring_literals
208 "L_selector_data(baseClassInstanceMethod)":
209 .asciz "baseClassInstanceMethod"
211 .section __TEXT,__cstring,cstring_literals
212 "l_.str.7.i16@0:8":
213 .asciz "i16@0:8"
215 "l_.str.7.@16@0:8":
216 .asciz "@16@0:8"
218 .section __DATA,__objc_data
219 .p2align 3, 0x0
220 __INSTANCE_METHODS__TtC11SimpleClass11SimpleClass:
221 .long 24
222 .long 2
223 .quad "L_selector_data(baseClassInstanceMethod)"
224 .quad "l_.str.7.i16@0:8"
225 .quad _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyFTo
226 .quad "L_selector_data(init)"
227 .quad "l_.str.7.@16@0:8"
228 .quad _$s11SimpleClassAACABycfcTo
230 .p2align 3, 0x0
231 __DATA__TtC11SimpleClass11SimpleClass:
232 .long 128
233 .long 8
234 .long 8
235 .long 0
236 .quad 0
237 .quad l_.str.30._TtC11SimpleClass11SimpleClass
238 .quad __INSTANCE_METHODS__TtC11SimpleClass11SimpleClass
239 .quad 0
240 .quad 0
241 .quad 0
242 .quad 0
244 .section __TEXT,__const
245 l_.str.11.SimpleClass:
246 .asciz "SimpleClass"
248 .private_extern _$s11SimpleClassMXM
249 .section __TEXT,__constg_swiftt
250 .globl _$s11SimpleClassMXM
251 .weak_definition _$s11SimpleClassMXM
252 .p2align 2, 0x0
253 _$s11SimpleClassMXM:
254 .long 0
255 .long 0
256 .long (l_.str.11.SimpleClass-_$s11SimpleClassMXM)-8
258 .private_extern "_symbolic So8NSObjectC"
259 .section __TEXT,__swift5_typeref
260 .globl "_symbolic So8NSObjectC"
261 .weak_definition "_symbolic So8NSObjectC"
262 .p2align 1, 0x0
263 "_symbolic So8NSObjectC":
264 .ascii "So8NSObjectC"
265 .byte 0
267 .private_extern _$s11SimpleClassAACMn
268 .section __TEXT,__constg_swiftt
269 .globl _$s11SimpleClassAACMn
270 .p2align 2, 0x0
271 _$s11SimpleClassAACMn:
272 .long 2147483728
273 .long (_$s11SimpleClassMXM-_$s11SimpleClassAACMn)-4
274 .long (l_.str.11.SimpleClass-_$s11SimpleClassAACMn)-8
275 .long (_$s11SimpleClassAACMa-_$s11SimpleClassAACMn)-12
276 .long (_$s11SimpleClassAACMF-_$s11SimpleClassAACMn)-16
277 .long ("_symbolic So8NSObjectC"-_$s11SimpleClassAACMn)-20
278 .long 3
279 .long 11
280 .long 1
281 .long 0
282 .long 10
283 .long 10
284 .long 1
285 .long 16
286 .long (_$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF-_$s11SimpleClassAACMn)-56
288 .section __DATA,__objc_data
289 .p2align 3, 0x0
290 _$s11SimpleClassAACMf:
291 .quad 0
292 .quad _$s11SimpleClassAACfD
293 .quad _$sBOWV
294 .quad _OBJC_METACLASS_$__TtC11SimpleClass11SimpleClass
295 .quad _OBJC_CLASS_$_NSObject
296 .quad __objc_empty_cache
297 .quad 0
298 .quad __DATA__TtC11SimpleClass11SimpleClass+2
299 .long 0
300 .long 0
301 .long 8
302 .short 7
303 .short 0
304 .long 112
305 .long 24
306 .quad _$s11SimpleClassAACMn
307 .quad 0
308 .quad _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF
310 .private_extern "_symbolic _____ 11SimpleClassAAC"
311 .section __TEXT,__swift5_typeref
312 .globl "_symbolic _____ 11SimpleClassAAC"
313 .weak_definition "_symbolic _____ 11SimpleClassAAC"
314 .p2align 1, 0x0
315 "_symbolic _____ 11SimpleClassAAC":
316 .byte 1
317 .long (_$s11SimpleClassAACMn-"_symbolic _____ 11SimpleClassAAC")-1
318 .byte 0
320 .section __TEXT,__swift5_fieldmd
321 .p2align 2, 0x0
322 _$s11SimpleClassAACMF:
323 .long "_symbolic _____ 11SimpleClassAAC"-_$s11SimpleClassAACMF
324 .long ("_symbolic So8NSObjectC"-_$s11SimpleClassAACMF)-4
325 .short 7
326 .short 12
327 .long 0
329 .section __TEXT,__objc_methname,cstring_literals
330 "L_selector_data(categoryInstanceMethod)":
331 .asciz "categoryInstanceMethod"
333 .section __TEXT,__cstring,cstring_literals
334 "l_.str.7.q16@0:8":
335 .asciz "q16@0:8"
337 .section __DATA,__objc_data
338 .p2align 3, 0x0
339 __CATEGORY_INSTANCE_METHODS__TtC11SimpleClass11SimpleClass_$_SimpleClass:
340 .long 24
341 .long 1
342 .quad "L_selector_data(categoryInstanceMethod)"
343 .quad "l_.str.7.q16@0:8"
344 .quad _$s11SimpleClassAAC22categoryInstanceMethodSiyFTo
346 .section __DATA,__objc_const
347 .p2align 3, 0x0
348 __CATEGORY__TtC11SimpleClass11SimpleClass_$_SimpleClass:
349 .quad l_.str.11.SimpleClass
350 .quad _$s11SimpleClassAACMf+24
351 .quad __CATEGORY_INSTANCE_METHODS__TtC11SimpleClass11SimpleClass_$_SimpleClass
352 .quad 0
353 .quad 0
354 .quad 0
355 .quad 0
356 .long 60
357 .space 4
359 .section __TEXT,__swift5_types
360 .p2align 2, 0x0
361 l_$s11SimpleClassAACHn:
362 .long _$s11SimpleClassAACMn-l_$s11SimpleClassAACHn
364 .private_extern ___swift_reflection_version
365 .section __TEXT,__const
366 .globl ___swift_reflection_version
367 .weak_definition ___swift_reflection_version
368 .p2align 1, 0x0
369 ___swift_reflection_version:
370 .short 3
372 .section __DATA,__objc_classlist,regular,no_dead_strip
373 .p2align 3, 0x0
374 _objc_classes_$s11SimpleClassAACN:
375 .quad _$s11SimpleClassAACN
377 .section __DATA,__objc_catlist,regular,no_dead_strip
378 .p2align 3, 0x0
379 _objc_categories:
380 .quad __CATEGORY__TtC11SimpleClass11SimpleClass_$_SimpleClass
382 .no_dead_strip _main
383 .no_dead_strip l_entry_point
384 .no_dead_strip _$s11SimpleClassAACMF
385 .no_dead_strip l_$s11SimpleClassAACHn
386 .no_dead_strip ___swift_reflection_version
387 .no_dead_strip _objc_classes_$s11SimpleClassAACN
388 .no_dead_strip _objc_categories
389 .section __DATA,__objc_imageinfo,regular,no_dead_strip
390 L_OBJC_IMAGE_INFO:
391 .long 0
392 .long 100665152
394 .globl _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyFTq
395 .private_extern _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyFTq
396 .alt_entry _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyFTq
397 .set _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyFTq, _$s11SimpleClassAACMn+52
398 .globl _$s11SimpleClassAACN
399 .private_extern _$s11SimpleClassAACN
400 .alt_entry _$s11SimpleClassAACN
401 .set _$s11SimpleClassAACN, _$s11SimpleClassAACMf+24
402 .globl _OBJC_CLASS_$__TtC11SimpleClass11SimpleClass
403 .private_extern _OBJC_CLASS_$__TtC11SimpleClass11SimpleClass
404 .subsections_via_symbols
406 _OBJC_CLASS_$_NSObject:
407 _OBJC_METACLASS_$_NSObject:
408 __objc_empty_cache:
409 _$sBOWV:
410 .quad 0