xref: /llvm-project/llvm/test/tools/llvm-objdump/MachO/AArch64/macho-relative-method-lists.test (revision b59c2a0eb499d8daf8086cd9875083d32496cc58)
1RUN: llvm-objdump --macho --objc-meta-data    %p/Inputs/rel-method-lists-arm64_32.dylib | FileCheck %s --check-prefix=CHK32
2RUN: llvm-otool -ov                           %p/Inputs/rel-method-lists-arm64_32.dylib | FileCheck %s --check-prefix=CHK32
3
4RUN: llvm-objdump --macho --objc-meta-data    %p/Inputs/rel-method-lists-arm64.dylib    | FileCheck %s --check-prefix=CHK64
5RUN: llvm-otool -ov                           %p/Inputs/rel-method-lists-arm64.dylib    | FileCheck %s --check-prefix=CHK64
6
7CHK32:                 baseMethods 0x660 (struct method_list_t *)
8CHK32-NEXT:                 entsize 12 (relative)
9CHK32-NEXT:                   count 3
10CHK32-NEXT:                    name 0x144 (0x{{[0-9a-f]*}}) instance_method_00
11CHK32-NEXT:                   types 0x91 (0x{{[0-9a-f]*}}) v8@0:4
12CHK32-NEXT:                     imp 0xffffff18 (0x{{[0-9a-f]*}}) -[MyClass instance_method_00]
13CHK32-NEXT:                    name 0x13c (0x{{[0-9a-f]*}}) instance_method_01
14CHK32-NEXT:                   types 0x85 (0x{{[0-9a-f]*}}) v8@0:4
15CHK32-NEXT:                     imp 0xffffff28 (0x{{[0-9a-f]*}}) -[MyClass instance_method_01]
16CHK32-NEXT:                    name 0x134 (0x{{[0-9a-f]*}}) instance_method_02
17CHK32-NEXT:                   types 0x79 (0x{{[0-9a-f]*}}) v8@0:4
18CHK32-NEXT:                     imp 0xffffff38 (0x{{[0-9a-f]*}}) -[MyClass instance_method_02]
19
20CHK32:                 baseMethods 0x630 (struct method_list_t *)
21CHK32-NEXT:                 entsize 12 (relative)
22CHK32-NEXT:                   count 3
23CHK32-NEXT:                    name 0x180 (0x{{[0-9a-f]*}}) class_method_00
24CHK32-NEXT:                   types 0xc1 (0x{{[0-9a-f]*}}) v8@0:4
25CHK32-NEXT:                     imp 0xffffff9c (0x{{[0-9a-f]*}}) +[MyClass class_method_00]
26CHK32-NEXT:                    name 0x178 (0x{{[0-9a-f]*}}) class_method_01
27CHK32-NEXT:                   types 0xb5 (0x{{[0-9a-f]*}}) v8@0:4
28CHK32-NEXT:                     imp 0xffffffac (0x{{[0-9a-f]*}}) +[MyClass class_method_01]
29CHK32-NEXT:                    name 0x170 (0x{{[0-9a-f]*}}) class_method_02
30CHK32-NEXT:                   types 0xa9 (0x{{[0-9a-f]*}}) v8@0:4
31CHK32-NEXT:                     imp 0xffffffbc (0x{{[0-9a-f]*}}) +[MyClass class_method_02]
32
33CHK64:                  baseMethods 0x6e0 (struct method_list_t *)
34CHK64-NEXT:                  entsize 12 (relative)
35CHK64-NEXT:                    count 3
36CHK64-NEXT:                     name 0x188 (0x{{[0-9a-f]*}}) instance_method_00
37CHK64-NEXT:                    types 0x91 (0x{{[0-9a-f]*}}) v16@0:8
38CHK64-NEXT:                      imp 0xffffffa8 (0x{{[0-9a-f]*}}) -[MyClass instance_method_00]
39CHK64-NEXT:                     name 0x184 (0x{{[0-9a-f]*}}) instance_method_01
40CHK64-NEXT:                    types 0x85 (0x{{[0-9a-f]*}}) v16@0:8
41CHK64-NEXT:                      imp 0xffffffa0 (0x{{[0-9a-f]*}}) -[MyClass instance_method_01]
42CHK64-NEXT:                     name 0x180 (0x{{[0-9a-f]*}}) instance_method_02
43CHK64-NEXT:                    types 0x79 (0x{{[0-9a-f]*}}) v16@0:8
44CHK64-NEXT:                      imp 0xffffff98 (0x{{[0-9a-f]*}}) -[MyClass instance_method_02]
45
46CHK64:                  baseMethods 0x6b0 (struct method_list_t *)
47CHK64-NEXT:                  entsize 12 (relative)
48CHK64-NEXT:                    count 3
49CHK64-NEXT:                     name 0x1d0 (0x{{[0-9a-f]*}}) class_method_00
50CHK64-NEXT:                    types 0xc1 (0x{{[0-9a-f]*}}) v16@0:8
51CHK64-NEXT:                      imp 0xffffffe4 (0x{{[0-9a-f]*}}) +[MyClass class_method_00]
52CHK64-NEXT:                     name 0x1cc (0x{{[0-9a-f]*}}) class_method_01
53CHK64-NEXT:                    types 0xb5 (0x{{[0-9a-f]*}}) v16@0:8
54CHK64-NEXT:                      imp 0xffffffdc (0x{{[0-9a-f]*}}) +[MyClass class_method_01]
55CHK64-NEXT:                     name 0x1c8 (0x{{[0-9a-f]*}}) class_method_02
56CHK64-NEXT:                    types 0xa9 (0x{{[0-9a-f]*}}) v16@0:8
57CHK64-NEXT:                      imp 0xffffffd4 (0x{{[0-9a-f]*}}) +[MyClass class_method_02]
58
59######## Generate rel-method-lists-arm64.dylib ########
60// clang -c main.mm -o main.o -target arm64-apple-macos -arch arm64
61// ld64.ld64 -dylib -demangle -dynamic main.o -o rel-method-lists-arm64.dylib -syslibroot MacOSX14.2.sdk -segalign 0x10 -objc_relative_method_lists
62
63######## Generate rel-method-lists-arm64_32.dylib ########
64// clang -c main.mm -o main.o -target arm64_32-apple-watchos -arch arm64_32
65// ld64.ld64 -dylib -demangle -dynamic main.o -o rel-method-lists-arm64_32.dylib -syslibroot WatchOS.sdk -segalign 0x10 -objc_relative_method_lists
66
67// ~~~~~~~~~~~~~~~~~~~~~~~~~ main.mm ~~~~~~~~~~~~~~~~~~~~~~~~~
68__attribute__((objc_root_class))
69@interface MyClass
70- (void)instance_method_00;
71- (void)instance_method_01;
72- (void)instance_method_02;
73+ (void)class_method_00;
74+ (void)class_method_01;
75+ (void)class_method_02;
76@end
77@implementation MyClass
78- (void)instance_method_00 {}
79- (void)instance_method_01 {}
80- (void)instance_method_02 {}
81+ (void)class_method_00 {}
82+ (void)class_method_01 {}
83+ (void)class_method_02 {}
84@end
85void *_objc_empty_cache;
86void *_objc_empty_vtable;
87