Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / dyld-stub-binder.s
blob1d2e556607c79c671a8fa775596cd96be9da51dd
1 # REQUIRES: aarch64
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/foo.s -o %t/foo.o
4 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/bar.s -o %t/bar.o
5 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/test.s -o %t/test.o
7 ## Dylibs that don't do lazy dynamic calls don't need dyld_stub_binder.
8 # RUN: %no-lsystem-lld -arch arm64 -dylib %t/foo.o -o %t/libfoo.dylib
9 # RUN: llvm-nm -m %t/libfoo.dylib | FileCheck --check-prefix=NOSTUB %s
11 ## Binaries that don't do lazy dynamic calls but are linked against
12 ## libSystem.dylib get a reference to dyld_stub_binder even if it's
13 ## not needed.
14 # RUN: %lld -arch arm64 -lSystem -dylib %t/foo.o -o %t/libfoo.dylib
15 # RUN: llvm-nm -m %t/libfoo.dylib | FileCheck --check-prefix=STUB %s
18 ## Dylibs that do lazy dynamic calls do need dyld_stub_binder.
19 # RUN: not %no-lsystem-lld -arch arm64 -dylib %t/bar.o %t/libfoo.dylib \
20 # RUN: -o %t/libbar.dylib 2>&1 | FileCheck --check-prefix=MISSINGSTUB %s
21 # RUN: %lld -arch arm64 -lSystem -dylib %t/bar.o %t/libfoo.dylib \
22 # RUN: -o %t/libbar.dylib
23 # RUN: llvm-nm -m %t/libbar.dylib | FileCheck --check-prefix=STUB %s
25 ## As do executables.
26 # RUN: not %no-lsystem-lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
27 # RUN: -o %t/test 2>&1 | FileCheck --check-prefix=MISSINGSTUB %s
28 # RUN: %lld -arch arm64 -lSystem %t/libfoo.dylib %t/libbar.dylib %t/test.o \
29 # RUN: -o %t/test
30 # RUN: llvm-nm -m %t/test | FileCheck --check-prefix=STUB %s
32 ## Test dynamic lookup of dyld_stub_binder.
33 # RUN: %no-lsystem-lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
34 # RUN: -o %t/test -undefined dynamic_lookup
35 # RUN: llvm-nm -m %t/test | FileCheck --check-prefix=DYNSTUB %s
36 # RUN: %no-lsystem-lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
37 # RUN: -o %t/test -U dyld_stub_binder
38 # RUN: llvm-nm -m %t/test | FileCheck --check-prefix=DYNSTUB %s
40 # MISSINGSTUB: error: undefined symbol: dyld_stub_binder
41 # MISSINGSTUB-NEXT: >>> referenced by lazy binding (normally in libSystem.dylib)
43 # NOSTUB-NOT: dyld_stub_binder
44 # STUB: (undefined) external dyld_stub_binder (from libSystem)
45 # DYNSTUB: (undefined) external dyld_stub_binder (dynamically looked up)
47 #--- foo.s
48 .globl _foo
49 _foo:
51 #--- bar.s
52 .text
53 .globl _bar
54 _bar:
55 bl _foo
56 ret
58 #--- test.s
59 .text
60 .globl _main
62 .p2align 2
63 _main:
64 bl _foo
65 bl _bar
66 ret