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
66 ; @objc class SimpleClass
: NSObject
{
67 ; @objc func baseClassInstanceMethod
() -> Int32
{
71 ; extension SimpleClass
{
72 ; @objc func categoryInstanceMethod
() -> Int
{
77 ;
================== Generated from Swift
: ==================
78 .section __TEXT,__text,regular,pure_instructions
79 .build_version macos, 11, 0 sdk_version 12, 0
88 .private_extern _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF
89 .globl _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF
91 _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF
:
97 _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyFTo
:
102 .private_extern _$s11SimpleClassAACABycfC
103 .globl _$s11SimpleClassAACABycfC
105 _$s11SimpleClassAACABycfC
:
110 .private_extern _$s11SimpleClassAACABycfc
111 .globl _$s11SimpleClassAACABycfc
113 _$s11SimpleClassAACABycfc
:
118 .private_extern _$s11SimpleClassAACMa
119 .globl _$s11SimpleClassAACMa
121 _$s11SimpleClassAACMa
:
125 _$s11SimpleClassAACABycfcTo
:
130 .private_extern _$s11SimpleClassAACfD
131 .globl _$s11SimpleClassAACfD
133 _$s11SimpleClassAACfD
:
138 .private_extern _$s11SimpleClassAAC22categoryInstanceMethodSiyF
139 .globl _$s11SimpleClassAAC22categoryInstanceMethodSiyF
141 _$s11SimpleClassAAC22categoryInstanceMethodSiyF
:
147 _$s11SimpleClassAAC22categoryInstanceMethodSiyFTo
:
152 .section __TEXT,__objc_methname,cstring_literals
153 "L_selector_data(init)":
156 .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip
159 .quad "L_selector_data(init)"
161 .section __TEXT,__objc_methname,cstring_literals
162 "L_selector_data(dealloc)":
165 .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip
167 "L_selector(dealloc)":
168 .quad "L_selector_data(dealloc)"
170 .section __TEXT,__swift5_entry,regular,no_dead_strip
173 .long _main-l_entry_point
176 .private_extern _OBJC_METACLASS_$__TtC11SimpleClass11SimpleClass
177 .section __DATA,__data
178 .globl _OBJC_METACLASS_$__TtC11SimpleClass11SimpleClass
180 _OBJC_METACLASS_$__TtC11SimpleClass11SimpleClass
:
181 .quad _OBJC_METACLASS_$_NSObject
182 .quad _OBJC_METACLASS_$_NSObject
183 .quad __objc_empty_cache
185 .quad __METACLASS_DATA__TtC11SimpleClass11SimpleClass
187 .section __TEXT,__cstring,cstring_literals
189 l_.str.30
._TtC11SimpleClass11SimpleClass:
190 .asciz "_TtC11SimpleClass11SimpleClass"
192 .section __DATA,__objc_const
194 __METACLASS_DATA__TtC11SimpleClass11SimpleClass
:
200 .quad l_.str.30._TtC11SimpleClass11SimpleClass
207 .section __TEXT,__objc_methname,cstring_literals
208 "L_selector_data(baseClassInstanceMethod)":
209 .asciz "baseClassInstanceMethod"
211 .section __TEXT,__cstring,cstring_literals
218 .section __DATA,__objc_data
220 __INSTANCE_METHODS__TtC11SimpleClass11SimpleClass
:
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
231 __DATA__TtC11SimpleClass11SimpleClass
:
237 .quad l_.str.30._TtC11SimpleClass11SimpleClass
238 .quad __INSTANCE_METHODS__TtC11SimpleClass11SimpleClass
244 .section __TEXT,__const
245 l_.str.11
.SimpleClass:
248 .private_extern _$s11SimpleClassMXM
249 .section __TEXT,__constg_swiftt
250 .globl _$s11SimpleClassMXM
251 .weak_definition _$s11SimpleClassMXM
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"
263 "_symbolic So8NSObjectC":
264 .ascii "So8NSObjectC"
267 .private_extern _$s11SimpleClassAACMn
268 .section __TEXT,__constg_swiftt
269 .globl _$s11SimpleClassAACMn
271 _$s11SimpleClassAACMn
:
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
286 .long (_$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF-_$s11SimpleClassAACMn)-56
288 .section __DATA,__objc_data
290 _$s11SimpleClassAACMf
:
292 .quad _$s11SimpleClassAACfD
294 .quad _OBJC_METACLASS_$__TtC11SimpleClass11SimpleClass
295 .quad _OBJC_CLASS_$_NSObject
296 .quad __objc_empty_cache
298 .quad __DATA__TtC11SimpleClass11SimpleClass+2
306 .quad _$s11SimpleClassAACMn
308 .quad _$s11SimpleClassAAC04baseB14InstanceMethods5Int32VyF
310 .private_extern "_symbolic _____ 11SimpleClassAAC"
311 .section __TEXT,__swift5_typeref
312 .globl "_symbolic _____ 11SimpleClassAAC"
313 .weak_definition "_symbolic _____ 11SimpleClassAAC"
315 "_symbolic _____ 11SimpleClassAAC":
317 .long (_$s11SimpleClassAACMn-"_symbolic _____ 11SimpleClassAAC")-1
320 .section __TEXT,__swift5_fieldmd
322 _$s11SimpleClassAACMF
:
323 .long "_symbolic _____ 11SimpleClassAAC"-_$s11SimpleClassAACMF
324 .long ("_symbolic So8NSObjectC"-_$s11SimpleClassAACMF)-4
329 .section __TEXT,__objc_methname,cstring_literals
330 "L_selector_data(categoryInstanceMethod)":
331 .asciz "categoryInstanceMethod"
333 .section __TEXT,__cstring,cstring_literals
337 .section __DATA,__objc_data
339 __CATEGORY_INSTANCE_METHODS__TtC11SimpleClass11SimpleClass_$_SimpleClass
:
342 .quad "L_selector_data(categoryInstanceMethod)"
343 .quad "l_.str.7.q16@0:8"
344 .quad _$s11SimpleClassAAC22categoryInstanceMethodSiyFTo
346 .section __DATA,__objc_const
348 __CATEGORY__TtC11SimpleClass11SimpleClass_$_SimpleClass
:
349 .quad l_.str.11.SimpleClass
350 .quad _$s11SimpleClassAACMf+24
351 .quad __CATEGORY_INSTANCE_METHODS__TtC11SimpleClass11SimpleClass_$_SimpleClass
359 .section __TEXT,__swift5_types
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
369 ___swift_reflection_version
:
372 .section __DATA,__objc_classlist,regular,no_dead_strip
374 _objc_classes_$s11SimpleClassAACN
:
375 .quad _$s11SimpleClassAACN
377 .section __DATA,__objc_catlist,regular,no_dead_strip
380 .quad __CATEGORY__TtC11SimpleClass11SimpleClass_$_SimpleClass
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
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
: