xref: /llvm-project/lld/test/MachO/arm64-objc-stubs.s (revision 77e204c7b04f1f516db9a1dd5602e4a853bb0d1c)
1# REQUIRES: aarch64
2
3# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o
4# RUN: %lld -arch arm64 -lSystem -o %t.out %t.o
5# RUN: llvm-otool -vs __TEXT __objc_stubs %t.out | FileCheck %s
6# RUN: %lld -arch arm64 -lSystem -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 -o %t.out %t.o -objc_stubs_fast
9# RUN: llvm-otool -vs __TEXT __objc_stubs %t.out | FileCheck %s
10# RUN: llvm-otool -l %t.out | FileCheck %s --check-prefix=FASTALIGN
11# RUN: %lld -arch arm64 -lSystem -o %t.out %t.o -objc_stubs_small
12# RUN: llvm-otool -vs __TEXT __objc_stubs  %t.out | FileCheck %s --check-prefix=SMALL
13# RUN: llvm-otool -l %t.out | FileCheck %s --check-prefix=SMALLALIGN
14
15# CHECK: Contents of (__TEXT,__objc_stubs) section
16
17# CHECK-NEXT: _objc_msgSend$foo:
18# CHECK-NEXT: adrp    x1, 8 ; 0x100008000
19# CHECK-NEXT: ldr     x1, [x1, #0x10]
20# CHECK-NEXT: adrp    x16, 4 ; 0x100004000
21# CHECK-NEXT: ldr     x16, [x16]
22# CHECK-NEXT: br      x16
23# CHECK-NEXT: brk     #0x1
24# CHECK-NEXT: brk     #0x1
25# CHECK-NEXT: brk     #0x1
26
27# CHECK-NEXT: _objc_msgSend$length:
28# CHECK-NEXT: adrp    x1, 8 ; 0x100008000
29# CHECK-NEXT: ldr     x1, [x1, #0x18]
30# CHECK-NEXT: adrp    x16, 4 ; 0x100004000
31# CHECK-NEXT: ldr     x16, [x16]
32# CHECK-NEXT: br      x16
33# CHECK-NEXT: brk     #0x1
34# CHECK-NEXT: brk     #0x1
35# CHECK-NEXT: brk     #0x1
36
37# CHECK-EMPTY:
38
39# FASTALIGN:       sectname __objc_stubs
40# FASTALIGN-NEXT:   segname __TEXT
41# FASTALIGN-NEXT:      addr
42# FASTALIGN-NEXT:      size
43# FASTALIGN-NEXT:    offset
44# FASTALIGN-NEXT:     align 2^5 (32)
45
46# SMALL: _objc_msgSend$foo:
47# SMALL-NEXT: adrp    x1, 4 ; 0x100004000
48# SMALL-NEXT: ldr     x1, [x1, #0x10]
49# SMALL-NEXT: b
50
51# SMALL-NEXT: _objc_msgSend$length:
52# SMALL-NEXT: adrp    x1, 4 ; 0x100004000
53# SMALL-NEXT: ldr     x1, [x1, #0x18]
54# SMALL-NEXT: b
55
56# SMALLALIGN:       sectname __objc_stubs
57# SMALLALIGN-NEXT:   segname __TEXT
58# SMALLALIGN-NEXT:      addr
59# SMALLALIGN-NEXT:      size
60# SMALLALIGN-NEXT:    offset
61# SMALLALIGN-NEXT:     align 2^2 (4)
62
63.section  __TEXT,__objc_methname,cstring_literals
64lselref1:
65  .asciz  "foo"
66lselref2:
67  .asciz  "bar"
68
69.section  __DATA,__objc_selrefs,literal_pointers,no_dead_strip
70.p2align  3
71.quad lselref1
72.quad lselref2
73
74.text
75.globl _objc_msgSend
76_objc_msgSend:
77  ret
78
79.globl _main
80_main:
81  bl  _objc_msgSend$length
82  bl  _objc_msgSend$foo
83  bl  _objc_msgSend$foo
84  ret
85