Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / weak-definition-over-dysym.s
blobff677a9d4a3f5b1d357de8a9977041a09be2e8e6
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
4 ## This test demonstrates that when an archive file is fetched, its symbols
5 ## always override any conflicting dylib symbols, regardless of any weak
6 ## definition flags.
8 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
9 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libfoo.s -o %t/libfoo.o
10 # RUN: %lld -dylib -install_name @executable_path/libfoo.dylib %t/libfoo.o -o %t/libfoo.dylib
12 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
13 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
14 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weakfoo.s -o %t/weakfoo.o
16 # RUN: llvm-ar --format=darwin rcs %t/foo.a %t/foo.o
17 # RUN: llvm-ar --format=darwin rcs %t/weakfoo.a %t/weakfoo.o
19 # PREFER-WEAK-OBJECT: O __TEXT,weak _foo
20 # PREFER-NONWEAK-OBJECT: O __TEXT,nonweak _foo
22 # RUN: %lld -lSystem -o %t/nonweak-dylib-weak-ar -L%t -lfoo %t/weakfoo.a %t/test.o
23 # RUN: llvm-objdump --macho --lazy-bind --syms %t/nonweak-dylib-weak-ar | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT
24 # RUN: %lld -lSystem -o %t/weak-ar-nonweak-dylib -L%t %t/weakfoo.a -lfoo %t/test.o
25 # RUN: llvm-objdump --macho --lazy-bind --syms %t/weak-ar-nonweak-dylib | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT
27 # RUN: %lld -lSystem -o %t/weak-obj-nonweak-dylib -L%t %t/weakfoo.o -lfoo %t/test.o
28 # RUN: llvm-objdump --macho --lazy-bind --syms %t/weak-obj-nonweak-dylib | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT
29 # RUN: %lld -lSystem -o %t/nonweak-dylib-weak-obj -L%t -lfoo %t/weakfoo.o %t/test.o
30 # RUN: llvm-objdump --macho --lazy-bind --syms %t/nonweak-dylib-weak-obj | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT
32 #--- libfoo.s
33 .globl _foo
34 _foo:
36 #--- foo.s
37 .globl _foo, _bar
38 .section __TEXT,nonweak
39 _bar:
40 _foo:
42 #--- weakfoo.s
43 .globl _foo, _bar
44 .weak_definition _foo
45 .section __TEXT,weak
46 _bar:
47 _foo:
49 #--- test.s
50 .globl _main
51 _main:
52 callq _foo
53 callq _bar
54 ret