Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / weak-import.s
blobe71ad4f1304ddd0f5b7ff9ee35fcbc798f56123d
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weak-ref-only.s -o %t/weak-ref-only.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weak-ref-sub-library.s -o %t/weak-ref-sub-library.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/mixed-ref.s -o %t/mixed-ref.o
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
8 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/bar.s -o %t/bar.o
9 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weak-reexport.s -o %t/weak-reexport.o
11 # RUN: %lld -lSystem -dylib %t/bar.o -o %t/libbar.dylib
12 # RUN: %lld -lSystem -dylib %t/foo.o %t/libbar.dylib -sub_library libbar -o %t/libfoo.dylib
14 # RUN: %lld -weak-lSystem %t/test.o -weak_framework CoreFoundation -weak_library %t/libfoo.dylib -o %t/basic
15 # RUN: llvm-objdump --macho --all-headers %t/basic | FileCheck %s -DDIR=%t --check-prefixes=WEAK-SYS,WEAK-FOO
16 # RUN: %lld -weak-lSystem %t/test.o \
17 # RUN: -framework CoreFoundation -weak_framework CoreFoundation -framework CoreFoundation \
18 # RUN: %t/libfoo.dylib -weak_library %t/libfoo.dylib %t/libfoo.dylib -o %t/basic-weak-strong
19 # RUN: llvm-objdump --macho --all-headers %t/basic-weak-strong | FileCheck %s -DDIR=%t --check-prefixes=WEAK-SYS,WEAK-FOO
20 # RUN: %lld -lSystem -dylib %t/libfoo.dylib %t/weak-ref-only.o -o %t/weak-ref-only
21 # RUN: llvm-objdump --macho --all-headers %t/weak-ref-only | FileCheck %s -DDIR=%t --check-prefixes=SYS,WEAK-FOO
22 # RUN: %lld -lSystem -dylib %t/libfoo.dylib %t/weak-ref-sub-library.o -o %t/weak-ref-sub-library
23 # RUN: llvm-objdump --macho --all-headers %t/weak-ref-sub-library | FileCheck %s -DDIR=%t --check-prefixes=SYS,WEAK-FOO
24 # RUN: %lld -lSystem -dylib %t/libfoo.dylib %t/mixed-ref.o -o %t/mixed-ref
25 # RUN: llvm-objdump --macho --all-headers %t/mixed-ref | FileCheck %s -DDIR=%t --check-prefixes=SYS,FOO
27 # RUN: %lld -framework CoreFoundation %t/test.o -weak_framework CoreFoundation -o %t/strong-weak-import.out
28 # RUN: llvm-objdump --macho --bind %t/strong-weak-import.out | FileCheck %s --check-prefix=WEAK-IMP
29 # RUN: llvm-objdump --macho --bind %t/basic-weak-strong | FileCheck %s --check-prefix=WEAK-IMP
31 ## This references the gxx_personality_v0 symbol, which is defined in libc++abi, which is then
32 ## reexported by libc++.
33 ## Check that reexported symbols from weak libraries are also weakly-referenced.
34 # RUN: %lld -weak-lc++ %t/weak-reexport.o -o %t/weak-reexport.out
35 # RUN: llvm-objdump --macho --bind %t/weak-reexport.out | FileCheck %s --check-prefix=WEAK-REEXPORT
37 # WEAK-SYS: cmd LC_LOAD_WEAK_DYLIB
38 # WEAK-SYS-NEXT: cmdsize
39 # WEAK-SYS-NEXT: name /usr/lib/libSystem.dylib
41 # WEAK-SYS: cmd LC_LOAD_WEAK_DYLIB
42 # WEAK-SYS-NEXT: cmdsize
43 # WEAK-SYS-NEXT: name /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
45 # SYS: cmd LC_LOAD_DYLIB
46 # SYS-NEXT: cmdsize
47 # SYS-NEXT: name /usr/lib/libSystem.dylib
49 # WEAK-FOO: cmd LC_LOAD_WEAK_DYLIB
50 # WEAK-FOO-NEXT: cmdsize
51 # WEAK-FOO-NEXT: name [[DIR]]/libfoo.dylib
53 # FOO: cmd LC_LOAD_DYLIB
54 # FOO-NEXT: cmdsize
55 # FOO-NEXT: name [[DIR]]/libfoo.dylib
57 # WEAK-IMP: {{.+}} pointer 0 CoreFoundation __CFBigNumGetInt128 (weak_import)
58 # WEAK-REEXPORT: {{.+}} pointer 0 libc++abi ___gxx_personality_v0 (weak_import)
59 #--- foo.s
60 .globl _foo
61 _foo:
63 #--- bar.s
64 .globl _bar
65 _bar:
67 #--- weak-ref-only.s
68 .weak_reference _foo
69 .data
70 .quad _foo
72 #--- weak-ref-sub-library.s
73 .weak_reference _bar
74 .data
75 .quad _bar
77 #--- mixed-ref.s
78 .weak_definition _foo
79 .data
80 .quad _foo
81 .quad _bar
83 #--- test.s
84 .globl _main
85 _main:
86 movq __CFBigNumGetInt128@GOTPCREL(%rip), %rax
87 ret
89 #--- weak-reexport.s
90 .globl _main
91 _main:
93 .data
94 .quad ___gxx_personality_v0