1# REQUIRES: aarch64 2 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 13 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. 18 19# CHECK: Contents of (__TEXT,__objc_stubs) section 20 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] 26# CHECK-NEXT: br x16 27# CHECK-NEXT: brk #0x1 28# CHECK-NEXT: brk #0x1 29# CHECK-NEXT: brk #0x1 30 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] 36# CHECK-NEXT: br x16 37# CHECK-NEXT: brk #0x1 38# CHECK-NEXT: brk #0x1 39# CHECK-NEXT: brk #0x1 40 41# CHECK-EMPTY: 42 43# STUB: Contents of (__TEXT,__stubs) section 44# STUB-NEXT: adrp x16, 8 ; 0x100008000 45# STUB-NEXT: ldr x16, [x16] 46# STUB-NEXT: br x16 47 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] 52# SMALL-NEXT: b 53# SMALL-NEXT: _objc_msgSend$length: 54# SMALL-NEXT: adrp x1, 8 ; 0x100008000 55# SMALL-NEXT: ldr x1, [x1, #0x20] 56# SMALL-NEXT: b 57 58.section __TEXT,__objc_methname,cstring_literals 59lselref1: 60 .asciz "foo" 61lselref2: 62 .asciz "bar" 63 64.section __DATA,__objc_selrefs,literal_pointers,no_dead_strip 65.p2align 3 66.quad lselref1 67.quad lselref2 68 69.text 70 71.globl _main 72_main: 73 bl _objc_msgSend$length 74 bl _objc_msgSend$foo 75 bl _objc_msgSend$foo 76 ret 77