Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / archive-symbol-resolution.s
blobc41a09d8951dd82ded6392543bac5d94e83879c1
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/g.s -o %t/g.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/f1.s -o %t/f1.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/f2.s -o %t/f2.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/fg.s -o %t/fg.o
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
8 # RUN: %lld -dylib -o %t/libf1.dylib %t/f1.o -lSystem
10 # RUN: llvm-ar rcs %t/libf2_g.a %t/f2.o %t/g.o
11 # RUN: llvm-ar rcs %t/libfg.a %t/fg.o
13 ## (Strong) dylib symbols and archive symbols have equal precedence.
15 # RUN: %lld %t/libf1.dylib %t/libf2_g.a %t/test.o -o %t/test.out -lSystem
16 # RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix DYLIB-FIRST
17 # DYLIB-FIRST: SYMBOL TABLE:
18 # DYLIB-FIRST-DAG: __TEXT,test_g g
19 # DYLIB-FIRST: Lazy bind table:
20 # DYLIB-FIRST-NEXT: segment section address dylib symbol
21 # DYLIB-FIRST-NEXT: __DATA __la_symbol_ptr {{[0-9a-z]+}} libf1 f
23 # RUN: %lld %t/libf2_g.a %t/libf1.dylib %t/test.o -o %t/test.out -lSystem
24 # RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST
25 # ARCHIVE-FIRST: SYMBOL TABLE:
26 # ARCHIVE-FIRST-DAG: __TEXT,test_f2 f
27 # ARCHIVE-FIRST-DAG: __TEXT,test_g g
28 # ARCHIVE-FIRST: Lazy bind table:
29 # ARCHIVE-FIRST-NEXT: segment section address dylib symbol
30 # ARCHIVE-FIRST-EMPTY:
32 ## Once an archive member is fetched, all the extern symbols in that member
33 ## take precedence over dylib symbols of the same name.
34 # RUN: %lld %t/libf1.dylib %t/libfg.a %t/test.o -o %t/test.out -lSystem
35 # RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-PRIORITY
36 # ARCHIVE-PRIORITY: SYMBOL TABLE:
37 # ARCHIVE-PRIORITY-DAG: __TEXT,test_fg f
38 # ARCHIVE-PRIORITY-DAG: __TEXT,test_fg g
39 # ARCHIVE-PRIORITY: Lazy bind table:
40 # ARCHIVE-PRIORITY-NEXT: segment section address dylib symbol
41 # ARCHIVE-PRIORITY-EMPTY:
43 #--- g.s
44 .global f, g
45 .section __TEXT,test_g
47 callq f
49 #--- f1.s
50 .global f
51 .section __TEXT,test_f1
53 ret
55 #--- f2.s
56 .global f
57 .section __TEXT,test_f2
59 ret
61 #--- fg.s
62 .global f, g
63 .section __TEXT,test_fg
65 ret
67 callq f
69 #--- test.s
70 .global g
71 .global _main
72 _main:
73 callq g
74 ret