3 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o
4 # RUN: %lld -arch arm64 -lSystem -U _objc_msgSend -o %t.out %t.o
5 # RUN: llvm-otool -vs __TEXT __objc_stubs %t.out | FileCheck %s
6 # RUN: %lld -arch arm64 -lSystem -U _objc_msgSend -o %t.out %t.o -dead_strip
7 # RUN: llvm-otool -vs __TEXT __objc_stubs %t.out | FileCheck %s
8 # RUN: %lld -arch arm64 -lSystem -U _objc_msgSend -o %t.out %t.o -objc_stubs_fast
9 # RUN: llvm-otool -vs __TEXT __objc_stubs %t.out | FileCheck %s
10 # RUN: %lld -arch arm64 -lSystem -U _objc_msgSend -o %t.out %t.o -objc_stubs_small
11 # RUN: llvm-otool -vs __TEXT __stubs %t.out | FileCheck %s --check-prefix=STUB
12 # RUN: llvm-otool -vs __TEXT __objc_stubs %t.out | FileCheck %s --check-prefix=SMALL
14 # Unlike arm64-objc-stubs.s, in this test, _objc_msgSend is not defined,
15 # which usually binds with libobjc.dylib.
16 # 1. -objc_stubs_fast: No change as it uses GOT.
17 # 2. -objc_stubs_small: Create a (shared) stub to invoke _objc_msgSend, to minimize the size.
19 # CHECK: Contents of (__TEXT,__objc_stubs) section
21 # CHECK-NEXT: _objc_msgSend$foo:
22 # CHECK-NEXT: adrp x1, 8 ; 0x100008000
23 # CHECK-NEXT: ldr x1, [x1, #0x10]
24 # CHECK-NEXT: adrp x16, 4 ; 0x100004000
25 # CHECK-NEXT: ldr x16, [x16]
27 # CHECK-NEXT: brk #0x1
28 # CHECK-NEXT: brk #0x1
29 # CHECK-NEXT: brk #0x1
31 # CHECK-NEXT: _objc_msgSend$length:
32 # CHECK-NEXT: adrp x1, 8 ; 0x100008000
33 # CHECK-NEXT: ldr x1, [x1, #0x18]
34 # CHECK-NEXT: adrp x16, 4 ; 0x100004000
35 # CHECK-NEXT: ldr x16, [x16]
37 # CHECK-NEXT: brk #0x1
38 # CHECK-NEXT: brk #0x1
39 # CHECK-NEXT: brk #0x1
43 # STUB: Contents of (__TEXT,__stubs) section
44 # STUB-NEXT: adrp x16, 8 ; 0x100008000
45 # STUB-NEXT: ldr x16, [x16]
48 # SMALL: Contents of (__TEXT,__objc_stubs) section
49 # SMALL-NEXT: _objc_msgSend$foo:
50 # SMALL-NEXT: adrp x1, 8 ; 0x100008000
51 # SMALL-NEXT: ldr x1, [x1, #0x18]
53 # SMALL-NEXT: _objc_msgSend$length:
54 # SMALL-NEXT: adrp x1, 8 ; 0x100008000
55 # SMALL-NEXT: ldr x1, [x1, #0x20]
58 .section __TEXT,__objc_methname,cstring_literals
64 .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip
73 bl _objc_msgSend$length