Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / weak-definition-in-main-file.s
blobdd8ab86609194bb63d60f3e2af49fb768eb192d0
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
4 ## Test that a weak symbol in a direct .o file wins over
5 ## a weak symbol in a .a file.
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
8 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weakfoo.s -o %t/weakfoo.o
10 # RUN: llvm-ar --format=darwin rcs %t/weakfoo.a %t/weakfoo.o
12 # PREFER-DIRECT-OBJECT-NOT: O __TEXT,weak __foo
14 # RUN: %lld -lSystem -o %t/out %t/weakfoo.a %t/test.o
15 # RUN: llvm-objdump --syms %t/out | FileCheck %s --check-prefix=PREFER-DIRECT-OBJECT
17 #--- weakfoo.s
18 .globl __baz
19 __baz:
20 ret
22 .section __TEXT,weak
23 .weak_definition __foo
24 .globl __foo
25 __foo:
26 ret
28 .subsections_via_symbols
30 #--- test.s
31 .globl __foo
32 .weak_definition __foo
33 __foo:
34 ret
36 .globl _main
37 _main:
38 # This pulls in weakfoo.a due to the __baz undef, but __foo should
39 # still be resolved against the weak symbol in this file.
40 callq __baz
41 callq __foo
42 ret
44 .subsections_via_symbols