Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / implicit-dylibs.s
blobf469240103511fe7ad2d54c170a19890f140c8bc
1 # REQUIRES: x86
2 ## FIXME: We appear to emit LC_LOAD_DYLIBs in a different order on Windows.
3 # UNSUPPORTED: system-windows
4 # RUN: rm -rf %t; split-file %s %t
5 # RUN: mkdir -p %t/usr/lib/system
6 # RUN: mkdir -p %t/System/Library/Frameworks/Foo.framework/Versions/A
7 # RUN: mkdir -p %t/System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Versions/A
8 # RUN: mkdir -p %t/Baz.framework/Versions/A
10 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libfoo.s -o %t/libfoo.o
11 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libtoplevel.s -o %t/libtoplevel.o
12 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libsublevel.s -o %t/libsublevel.o
13 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/framework-foo.s -o %t/framework-foo.o
14 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/framework-bar.s -o %t/framework-bar.o
15 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/framework-baz.s -o %t/framework-baz.o
16 ## libunused will be used to verify that we load implicit dylibs even if we
17 ## don't use any symbols they contain.
18 # RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/libunused.o
19 # RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/reexporter.o
21 # RUN: %lld -dylib -lSystem %t/libfoo.o -o %t/libfoo.dylib
22 # RUN: %lld -dylib -lSystem %t/libtoplevel.o -o %t/usr/lib/libtoplevel.dylib -install_name /usr/lib/libtoplevel.dylib
23 # RUN: %lld -dylib -lSystem %t/libsublevel.o -o %t/usr/lib/system/libsublevel.dylib -install_name /usr/lib/system/libsublevel.dylib
24 # RUN: %lld -dylib -lSystem %t/libunused.o -o %t/usr/lib/libunused.dylib -install_name /usr/lib/libunused.dylib
26 ## Bar.framework is nested within Foo.framework.
27 # RUN: %lld -dylib -lSystem %t/framework-bar.o -o %t/System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Versions/A/Bar \
28 # RUN: -install_name /System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Versions/A/Bar
29 # RUN: ln -sf Versions/A/Bar \
30 # RUN: %t/System/Library/Frameworks/Foo.framework/Frameworks/Bar.framework/Bar
32 ## Have Foo re-export Bar.
33 # RUN: %lld -dylib -F %t/System/Library/Frameworks/Foo.framework/Frameworks \
34 # RUN: -framework Bar -sub_umbrella Bar -lSystem %t/framework-foo.o -o %t/System/Library/Frameworks/Foo.framework/Versions/A/Foo \
35 # RUN: -install_name /System/Library/Frameworks/Foo.framework/Versions/A/Foo
36 # RUN: ln -sf Versions/A/Foo %t/System/Library/Frameworks/Foo.framework/Foo
38 # RUN: %lld -dylib -lSystem %t/framework-baz.o -o %t/Baz.framework/Versions/A/Baz \
39 # RUN: -install_name %t/Baz.framework/Versions/A/Baz
40 # RUN: ln -sf Versions/A/Baz %t/Baz.framework/Baz
42 # RUN: %lld -dylib -syslibroot %t -framework Foo -F %t -framework Baz \
43 # RUN: -lc++ -ltoplevel -lunused %t/usr/lib/system/libsublevel.dylib %t/libfoo.dylib \
44 # RUN: -sub_library libc++ -sub_library libfoo -sub_library libtoplevel \
45 # RUN: -sub_library libsublevel -sub_library libunused \
46 # RUN: -sub_umbrella Baz -sub_umbrella Foo \
47 # RUN: %t/reexporter.o -o %t/libreexporter.dylib
49 # RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %t/test.s -o %t/test.o
50 # RUN: %lld -syslibroot %t -o %t/test -lSystem -L%t -lreexporter %t/test.o
51 # RUN: llvm-objdump --bind --no-show-raw-insn -d %t/test | FileCheck %s
52 # CHECK: Bind table:
53 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libreexporter _foo
54 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libtoplevel _toplevel
55 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libreexporter _sublevel
56 # CHECK-DAG: __DATA __data {{.*}} pointer 0 Foo _framework_foo
57 # CHECK-DAG: __DATA __data {{.*}} pointer 0 Foo _framework_bar
58 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libreexporter _framework_baz
59 # CHECK-DAG: __DATA __data {{.*}} pointer 0 libc++abi ___gxx_personality_v0
61 # RUN: llvm-otool -l %t/test | FileCheck %s \
62 # RUN: --check-prefix=LOAD -DDIR=%t --implicit-check-not LC_LOAD_DYLIB
63 ## Check that we don't create duplicate LC_LOAD_DYLIBs.
64 # RUN: %lld -syslibroot %t -o %t/test -lSystem -L%t -lreexporter -ltoplevel %t/test.o
65 # RUN: llvm-otool -l %t/test | FileCheck %s \
66 # RUN: --check-prefix=LOAD -DDIR=%t --implicit-check-not LC_LOAD_DYLIB
68 # LOAD: cmd LC_LOAD_DYLIB
69 # LOAD-NEXT: cmdsize
70 # LOAD-NEXT: name /usr/lib/libSystem.dylib
71 # LOAD: cmd LC_LOAD_DYLIB
72 # LOAD-NEXT: cmdsize
73 # LOAD-NEXT: name [[DIR]]/libreexporter.dylib
74 # LOAD: cmd LC_LOAD_DYLIB
75 # LOAD-NEXT: cmdsize
76 # LOAD-NEXT: name /System/Library/Frameworks/Foo.framework/Versions/A/Foo
77 # LOAD: cmd LC_LOAD_DYLIB
78 # LOAD-NEXT: cmdsize
79 # LOAD-NEXT: name /usr/lib/libc++abi.dylib
80 # LOAD: cmd LC_LOAD_DYLIB
81 # LOAD-NEXT: cmdsize
82 # LOAD-NEXT: name /usr/lib/libtoplevel.dylib
84 # RUN: %lld -no_implicit_dylibs -syslibroot %t -o %t/no-implicit -lSystem -L%t -lreexporter %t/test.o
85 # RUN: llvm-objdump --bind --no-show-raw-insn -d %t/no-implicit | FileCheck %s --check-prefix=NO-IMPLICIT
86 # NO-IMPLICIT: Bind table:
87 # NO-IMPLICIT-DAG: __DATA __data {{.*}} pointer 0 libreexporter _foo
88 # NO-IMPLICIT-DAG: __DATA __data {{.*}} pointer 0 libreexporter _toplevel
89 # NO-IMPLICIT-DAG: __DATA __data {{.*}} pointer 0 libreexporter _sublevel
90 # NO-IMPLICIT-DAG: __DATA __data {{.*}} pointer 0 libreexporter _framework_foo
91 # NO-IMPLICIT-DAG: __DATA __data {{.*}} pointer 0 libreexporter _framework_bar
92 # NO-IMPLICIT-DAG: __DATA __data {{.*}} pointer 0 libreexporter _framework_baz
93 # NO-IMPLICIT-DAG: __DATA __data {{.*}} pointer 0 libreexporter ___gxx_personality_v0
95 #--- libfoo.s
96 .data
97 .globl _foo
98 _foo:
100 #--- libtoplevel.s
101 .data
102 .globl _toplevel
103 _toplevel:
105 #--- libsublevel.s
106 .data
107 .globl _sublevel
108 _sublevel:
110 #--- framework-foo.s
111 .data
112 .globl _framework_foo
113 _framework_foo:
115 #--- framework-bar.s
116 .data
117 .globl _framework_bar
118 _framework_bar:
120 #--- framework-baz.s
121 .data
122 .globl _framework_baz
123 _framework_baz:
125 #--- test.s
126 .text
127 .globl _main
129 _main:
132 .data
133 .quad _foo
134 .quad _toplevel
135 .quad _sublevel
136 .quad _framework_foo
137 .quad _framework_bar
138 .quad _framework_baz
139 .quad ___gxx_personality_v0