llvm-project
250 строк · 8.2 Кб
1# REQUIRES: aarch64
2# UNSUPPORTED: target=arm{{.*}}-unknown-linux-gnueabihf
3# RUN: rm -rf %t; split-file %s %t && cd %t
4
5## Compile a64_rel_dylib.o
6# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o a64_rel_dylib.o a64_simple_class.s
7
8## Test arm64 + relative method lists
9# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -objc_relative_method_lists
10# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_REL
11
12## Test arm64 + relative method lists + dead-strip
13# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -objc_relative_method_lists -dead_strip
14# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_REL
15
16## Test arm64 + traditional method lists (no relative offsets)
17# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -no_objc_relative_method_lists
18# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_NO_REL
19
20
21CHK_REL: Contents of (__DATA_CONST,__objc_classlist) section
22CHK_REL-NEXT: _OBJC_CLASS_$_MyClass
23CHK_REL: baseMethods
24CHK_REL-NEXT: entsize 12 (relative)
25CHK_REL-NEXT: count 3
26CHK_REL-NEXT: name 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) instance_method_00
27CHK_REL-NEXT: types 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) v16@0:8
28CHK_REL-NEXT: imp 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) -[MyClass instance_method_00]
29CHK_REL-NEXT: name 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) instance_method_01
30CHK_REL-NEXT: types 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) v16@0:8
31CHK_REL-NEXT: imp 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) -[MyClass instance_method_01]
32CHK_REL-NEXT: name 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) instance_method_02
33CHK_REL-NEXT: types 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) v16@0:8
34CHK_REL-NEXT: imp 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) -[MyClass instance_method_02]
35
36CHK_REL: Meta Class
37CHK_REL-NEXT: isa 0x{{[0-9a-f]*}} _OBJC_METACLASS_$_MyClass
38CHK_REL: baseMethods 0x{{[0-9a-f]*}} (struct method_list_t *)
39CHK_REL-NEXT: entsize 12 (relative)
40CHK_REL-NEXT: count 3
41CHK_REL-NEXT: name 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) class_method_00
42CHK_REL-NEXT: types 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) v16@0:8
43CHK_REL-NEXT: imp 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) +[MyClass class_method_00]
44CHK_REL-NEXT: name 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) class_method_01
45CHK_REL-NEXT: types 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) v16@0:8
46CHK_REL-NEXT: imp 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) +[MyClass class_method_01]
47CHK_REL-NEXT: name 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) class_method_02
48CHK_REL-NEXT: types 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) v16@0:8
49CHK_REL-NEXT: imp 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) +[MyClass class_method_02]
50
51
52CHK_NO_REL-NOT: (relative)
53
54CHK_NO_REL: Contents of (__DATA_CONST,__objc_classlist) section
55CHK_NO_REL-NEXT: _OBJC_CLASS_$_MyClass
56
57CHK_NO_REL: baseMethods 0x{{[0-9a-f]*}} (struct method_list_t *)
58CHK_NO_REL-NEXT: entsize 24
59CHK_NO_REL-NEXT: count 3
60CHK_NO_REL-NEXT: name 0x{{[0-9a-f]*}} instance_method_00
61CHK_NO_REL-NEXT: types 0x{{[0-9a-f]*}} v16@0:8
62CHK_NO_REL-NEXT: imp -[MyClass instance_method_00]
63CHK_NO_REL-NEXT: name 0x{{[0-9a-f]*}} instance_method_01
64CHK_NO_REL-NEXT: types 0x{{[0-9a-f]*}} v16@0:8
65CHK_NO_REL-NEXT: imp -[MyClass instance_method_01]
66CHK_NO_REL-NEXT: name 0x{{[0-9a-f]*}} instance_method_02
67CHK_NO_REL-NEXT: types 0x{{[0-9a-f]*}} v16@0:8
68CHK_NO_REL-NEXT: imp -[MyClass instance_method_02]
69
70
71CHK_NO_REL: Meta Class
72CHK_NO_REL-NEXT: _OBJC_METACLASS_$_MyClass
73
74CHK_NO_REL: baseMethods 0x{{[0-9a-f]*}} (struct method_list_t *)
75CHK_NO_REL-NEXT: entsize 24
76CHK_NO_REL-NEXT: count 3
77CHK_NO_REL-NEXT: name 0x{{[0-9a-f]*}} class_method_00
78CHK_NO_REL-NEXT: types 0x{{[0-9a-f]*}} v16@0:8
79CHK_NO_REL-NEXT: imp +[MyClass class_method_00]
80CHK_NO_REL-NEXT: name 0x{{[0-9a-f]*}} class_method_01
81CHK_NO_REL-NEXT: types 0x{{[0-9a-f]*}} v16@0:8
82CHK_NO_REL-NEXT: imp +[MyClass class_method_01]
83CHK_NO_REL-NEXT: name 0x{{[0-9a-f]*}} class_method_02
84CHK_NO_REL-NEXT: types 0x{{[0-9a-f]*}} v16@0:8
85CHK_NO_REL-NEXT: imp +[MyClass class_method_02]
86
87
88######################## Generate a64_simple_class.s #########################
89# clang -c simple_class.mm -s -o a64_simple_class.s -target arm64-apple-macos -arch arm64 -Oz
90
91######################## simple_class.mm ########################
92# __attribute__((objc_root_class))
93# @interface MyClass
94# - (void)instance_method_00;
95# - (void)instance_method_01;
96# - (void)instance_method_02;
97# + (void)class_method_00;
98# + (void)class_method_01;
99# + (void)class_method_02;
100# @end
101#
102# @implementation MyClass
103# - (void)instance_method_00 {}
104# - (void)instance_method_01 {}
105# - (void)instance_method_02 {}
106# + (void)class_method_00 {}
107# + (void)class_method_01 {}
108# + (void)class_method_02 {}
109# @end
110#
111# void *_objc_empty_cache;
112# void *_objc_empty_vtable;
113#
114
115#--- objc-macros.s
116.macro .objc_selector_def name
117.p2align 2
118"\name":
119.cfi_startproc
120ret
121.cfi_endproc
122.endm
123
124#--- a64_simple_class.s
125.include "objc-macros.s"
126
127.section __TEXT,__text,regular,pure_instructions
128.build_version macos, 11, 0
129
130.objc_selector_def "-[MyClass instance_method_00]"
131.objc_selector_def "-[MyClass instance_method_01]"
132.objc_selector_def "-[MyClass instance_method_02]"
133
134.objc_selector_def "+[MyClass class_method_00]"
135.objc_selector_def "+[MyClass class_method_01]"
136.objc_selector_def "+[MyClass class_method_02]"
137
138.globl __objc_empty_vtable
139.zerofill __DATA,__common,__objc_empty_vtable,8,3
140.section __DATA,__objc_data
141.globl _OBJC_CLASS_$_MyClass
142.p2align 3, 0x0
143
144_OBJC_CLASS_$_MyClass:
145.quad _OBJC_METACLASS_$_MyClass
146.quad 0
147.quad __objc_empty_cache
148.quad __objc_empty_vtable
149.quad __OBJC_CLASS_RO_$_MyClass
150.globl _OBJC_METACLASS_$_MyClass
151.p2align 3, 0x0
152
153_OBJC_METACLASS_$_MyClass:
154.quad _OBJC_METACLASS_$_MyClass
155.quad _OBJC_CLASS_$_MyClass
156.quad __objc_empty_cache
157.quad __objc_empty_vtable
158.quad __OBJC_METACLASS_RO_$_MyClass
159
160.section __TEXT,__objc_classname,cstring_literals
161l_OBJC_CLASS_NAME_:
162.asciz "MyClass"
163.section __TEXT,__objc_methname,cstring_literals
164l_OBJC_METH_VAR_NAME_:
165.asciz "class_method_00"
166.section __TEXT,__objc_methtype,cstring_literals
167l_OBJC_METH_VAR_TYPE_:
168.asciz "v16@0:8"
169.section __TEXT,__objc_methname,cstring_literals
170l_OBJC_METH_VAR_NAME_.1:
171.asciz "class_method_01"
172l_OBJC_METH_VAR_NAME_.2:
173.asciz "class_method_02"
174.section __DATA,__objc_const
175.p2align 3, 0x0
176__OBJC_$_CLASS_METHODS_MyClass:
177.long 24
178.long 3
179.quad l_OBJC_METH_VAR_NAME_
180.quad l_OBJC_METH_VAR_TYPE_
181.quad "+[MyClass class_method_00]"
182.quad l_OBJC_METH_VAR_NAME_.1
183.quad l_OBJC_METH_VAR_TYPE_
184.quad "+[MyClass class_method_01]"
185.quad l_OBJC_METH_VAR_NAME_.2
186.quad l_OBJC_METH_VAR_TYPE_
187.quad "+[MyClass class_method_02]"
188.p2align 3, 0x0
189
190__OBJC_METACLASS_RO_$_MyClass:
191.long 3
192.long 40
193.long 40
194.space 4
195.quad 0
196.quad l_OBJC_CLASS_NAME_
197.quad __OBJC_$_CLASS_METHODS_MyClass
198.quad 0
199.quad 0
200.quad 0
201.quad 0
202
203.section __TEXT,__objc_methname,cstring_literals
204l_OBJC_METH_VAR_NAME_.3:
205.asciz "instance_method_00"
206l_OBJC_METH_VAR_NAME_.4:
207.asciz "instance_method_01"
208l_OBJC_METH_VAR_NAME_.5:
209.asciz "instance_method_02"
210
211.section __DATA,__objc_const
212.p2align 3, 0x0
213__OBJC_$_INSTANCE_METHODS_MyClass:
214.long 24
215.long 3
216.quad l_OBJC_METH_VAR_NAME_.3
217.quad l_OBJC_METH_VAR_TYPE_
218.quad "-[MyClass instance_method_00]"
219.quad l_OBJC_METH_VAR_NAME_.4
220.quad l_OBJC_METH_VAR_TYPE_
221.quad "-[MyClass instance_method_01]"
222.quad l_OBJC_METH_VAR_NAME_.5
223.quad l_OBJC_METH_VAR_TYPE_
224.quad "-[MyClass instance_method_02]"
225.p2align 3, 0x0
226
227__OBJC_CLASS_RO_$_MyClass:
228.long 2
229.long 0
230.long 0
231.space 4
232.quad 0
233.quad l_OBJC_CLASS_NAME_
234.quad __OBJC_$_INSTANCE_METHODS_MyClass
235.quad 0
236.quad 0
237.quad 0
238.quad 0
239.globl __objc_empty_cache
240
241.zerofill __DATA,__common,__objc_empty_cache,8,3
242.section __DATA,__objc_classlist,regular,no_dead_strip
243.p2align 3, 0x0
244l_OBJC_LABEL_CLASS_$:
245.quad _OBJC_CLASS_$_MyClass
246.section __DATA,__objc_imageinfo,regular,no_dead_strip
247L_OBJC_IMAGE_INFO:
248.long 0
249.long 64
250.subsections_via_symbols
251