Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / nonweak-definition-override.s
blobb790821a25a87be7b69d838dd456058d09117f35
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libfoo.s -o %t/libfoo.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/nonweakdef.s -o %t/nonweakdef.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weakdef.s -o %t/weakdef.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/common.s -o %t/common.o
7 # RUN: %lld -dylib %t/libfoo.o -o %t/libfoo.dylib
9 ## Check that non-weak defined symbols override weak dylib symbols.
10 # RUN: %lld %t/nonweakdef.o -L%t -lfoo -o %t/nonweakdef -lSystem
11 # RUN: llvm-objdump --macho --weak-bind %t/nonweakdef | FileCheck %s
13 ## Test loading the dylib before the obj file.
14 # RUN: %lld -L%t -lfoo %t/nonweakdef.o -o %t/nonweakdef -lSystem
15 # RUN: llvm-objdump --macho --weak-bind %t/nonweakdef | FileCheck %s
17 # CHECK: Weak bind table:
18 # CHECK-NEXT: segment section address type addend symbol
19 # CHECK-NEXT: strong _weak_in_dylib
20 # CHECK-EMPTY:
22 ## Check that weak defined symbols do not override weak dylib symbols.
23 # RUN: %lld %t/weakdef.o -L%t -lfoo -o %t/weakdef -lSystem
24 # RUN: llvm-objdump --macho --weak-bind %t/weakdef | FileCheck %s --check-prefix=NO-WEAK-OVERRIDE
26 ## Test loading the dylib before the obj file.
27 # RUN: %lld -L%t -lfoo %t/weakdef.o -o %t/weakdef -lSystem
28 # RUN: llvm-objdump --macho --weak-bind %t/weakdef | FileCheck %s --check-prefix=NO-WEAK-OVERRIDE
30 # NO-WEAK-OVERRIDE: Weak bind table:
31 # NO-WEAK-OVERRIDE-NEXT: segment section address type addend symbol
32 # NO-WEAK-OVERRIDE-EMPTY:
34 ## Check that common symbols take precedence over weak dylib symbols, but do not
35 ## generate an overriding weak binding.
36 # RUN: %lld -L%t -lfoo %t/common.o -o %t/common -lSystem
37 # RUN: llvm-objdump --macho --weak-bind %t/common | FileCheck %s --check-prefix=NO-WEAK-OVERRIDE
38 # RUN: llvm-objdump --syms %t/common | FileCheck %s --check-prefix=COMMON
39 # COMMON-DAG: g O __DATA,__common _nonweak_in_dylib
40 # COMMON-DAG: g O __DATA,__common _weak_in_dylib
42 #--- libfoo.s
44 .globl _weak_in_dylib, _nonweak_in_dylib
45 .weak_definition _weak_in_dylib
47 _weak_in_dylib:
48 _nonweak_in_dylib:
50 #--- nonweakdef.s
52 .globl _main, _weak_in_dylib, _nonweak_in_dylib
54 _weak_in_dylib:
55 _nonweak_in_dylib:
57 _main:
58 ret
60 #--- weakdef.s
62 .globl _main, _weak_in_dylib, _nonweak_in_dylib
63 .weak_definition _weak_in_dylib, _nonweak_in_dylib
65 _weak_in_dylib:
66 _nonweak_in_dylib:
68 _main:
69 ret
71 #--- common.s
73 .globl _main
74 .comm _weak_in_dylib, 1
75 .comm _nonweak_in_dylib, 1
77 _main:
78 ret