xref: /llvm-project/lld/test/MachO/arm64-32-stubs.s (revision 9a8b0407fc16af4ca6f79a2583297318a645d88a)
1# REQUIRES: aarch64
2
3## FIXME: This test is very similar to arm64-stubs.s, but has been split into a
4## separate file because llvm-objdump doesn't correctly symbolize arm64_32. In
5## particular, the "literal pool symbol address" comments are missing (PR49944).
6
7# RUN: rm -rf %t; split-file %s %t
8# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/foo.s -o %t/foo.o
9# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/bar.s -o %t/bar.o
10# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/test.s -o %t/test.o
11# RUN: %lld-watchos -dylib -install_name @executable_path/libfoo.dylib %t/foo.o -o %t/libfoo.dylib
12# RUN: %lld-watchos -dylib -install_name @executable_path/libbar.dylib %t/bar.o -o %t/libbar.dylib
13# RUN: %lld-watchos -lSystem %t/libfoo.dylib %t/libbar.dylib %t/test.o -o %t/test -no_fixup_chains
14
15# RUN: llvm-objdump --no-print-imm-hex --macho -d --no-show-raw-insn --section="__TEXT,__stubs" --section="__TEXT,__stub_helper" %t/test | FileCheck %s
16
17# CHECK:       _main:
18# CHECK-NEXT:  bl 0x[[#%x,FOO:]] ; symbol stub for: _foo
19# CHECK-NEXT:  bl 0x[[#%x,BAR:]] ; symbol stub for: _bar
20# CHECK-NEXT:  ret
21
22# CHECK-LABEL: Contents of (__TEXT,__stubs) section
23# CHECK-NEXT:  [[#BAR]]: adrp x16
24# CHECK-NEXT:            ldr w16, [x16{{.*}}]
25# CHECK-NEXT:            br x16
26# CHECK-NEXT:  [[#FOO]]: adrp x16
27# CHECK-NEXT:            ldr w16, [x16{{.*}}]
28# CHECK-NEXT:            br x16
29
30# CHECK-LABEL: Contents of (__TEXT,__stub_helper) section
31# CHECK-NEXT:  [[#%x,HELPER_HEADER:]]: adrp x17
32# CHECK-NEXT:                          add x17, x17
33# CHECK-NEXT:                          stp x16, x17, [sp, #-16]!
34# CHECK-NEXT:                          adrp x16
35# CHECK-NEXT:                          ldr w16, [x16]
36# CHECK-NEXT:                          br x16
37# CHECK-NEXT:                          ldr w16, 0x[[#%x,BAR_BIND_OFF_ADDR:]]
38# CHECK-NEXT:                          b 0x[[#HELPER_HEADER]]
39# CHECK-NEXT:  [[#BAR_BIND_OFF_ADDR]]: udf #0
40# CHECK-NEXT:                          ldr w16, 0x[[#%x,FOO_BIND_OFF_ADDR:]]
41# CHECK-NEXT:                          b 0x[[#HELPER_HEADER]]
42# CHECK-NEXT:  [[#FOO_BIND_OFF_ADDR]]: udf #11
43
44#--- foo.s
45.globl _foo
46_foo:
47
48#--- bar.s
49.globl _bar
50_bar:
51
52#--- test.s
53.text
54.globl _main
55
56.p2align 2
57_main:
58  bl _foo
59  bl _bar
60  ret
61