Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / linkerscript / filename-spec.s
blob4fc4f2f4217528485769a22b5fd78a0a64032abb
1 # REQUIRES: x86
2 # RUN: rm -rf %t && split-file %s %t
3 # RUN: cd %t && mkdir dir0 dir1 dir2
4 # RUN: llvm-mc -filetype=obj -triple=x86_64 tx.s -o tx.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64 ty.s -o ty.o
7 # RUN: echo 'SECTIONS{.foo :{ KEEP(*x.o(.foo)) KEEP(*y.o(.foo)) }}' > 1.t
8 # RUN: ld.lld -o 1 -T 1.t tx.o ty.o
9 # RUN: llvm-objdump -s 1 | FileCheck --check-prefix=FIRSTY %s
10 # FIRSTY: Contents of section .foo:
11 # FIRSTY-NEXT: 01000000 00000000 11000000 00000000
13 # RUN: echo 'SECTIONS{.foo :{ KEEP(*y.o(.foo)) KEEP(*x.o(.foo)) }}' > 2.t
14 # RUN: ld.lld -o 2 -T 2.t tx.o ty.o
15 # RUN: llvm-objdump -s 2 | FileCheck --check-prefix=SECONDFIRST %s
16 # SECONDFIRST: Contents of section .foo:
17 # SECONDFIRST-NEXT: 11000000 00000000 01000000 00000000
19 ## Now the same tests but without KEEP. Checking that file name inside
20 ## KEEP is parsed fine.
21 # RUN: echo 'SECTIONS{.foo :{ *x.o(.foo) *y.o(.foo) }}' > 3.t
22 # RUN: ld.lld -o 3 -T 3.t tx.o ty.o
23 # RUN: llvm-objdump -s 3 | FileCheck --check-prefix=FIRSTY %s
25 # RUN: echo 'SECTIONS{.foo :{ *y.o(.foo) *x.o(.foo) }}' > 4.t
26 # RUN: ld.lld -o 4 -T 4.t tx.o ty.o
27 # RUN: llvm-objdump -s 4 | FileCheck --check-prefix=SECONDFIRST %s
29 # RUN: cp tx.o dir0/filename-spec1.o
30 # RUN: cp ty.o dir0/filename-spec2.o
32 # RUN: echo 'SECTIONS{.foo :{ "dir0/filename-spec2.o"(.foo) "dir0/filename-spec1.o"(.foo) }}' > 5.t
33 # RUN: ld.lld -o 5 -T 5.t dir0/filename-spec1.o dir0/filename-spec2.o
34 # RUN: llvm-objdump -s 5 | FileCheck --check-prefix=SECONDFIRST %s
36 # RUN: echo 'SECTIONS{.foo :{ "dir0/filename-spec1.o"(.foo) "dir0/filename-spec2.o"(.foo) }}' > 6.t
37 # RUN: ld.lld -o 6 -T 6.t dir0/filename-spec1.o dir0/filename-spec2.o
38 # RUN: llvm-objdump -s 6 | FileCheck --check-prefix=FIRSTY %s
40 # RUN: cp tx.o dir1/filename-spec1.o
41 # RUN: cp ty.o dir2/filename-spec2.o
42 # RUN: llvm-ar rc dir1/lib1.a dir1/filename-spec1.o
43 # RUN: llvm-ar rc dir2/lib2.a dir2/filename-spec2.o
45 ## Verify matching of archive library names.
46 # RUN: echo 'SECTIONS{.foo :{ *lib2*(.foo) *lib1*(.foo) }}' > 7.t
47 # RUN: ld.lld -o 7 -T 7.t --whole-archive \
48 # RUN: dir1/lib1.a dir2/lib2.a
49 # RUN: llvm-objdump -s 7 | FileCheck --check-prefix=SECONDFIRST %s
51 ## Verify matching directories.
52 # RUN: echo 'SECTIONS{.foo :{ *dir2*(.foo) *dir1*(.foo) }}' > 8.t
53 # RUN: ld.lld -o 8 -T 8.t --whole-archive \
54 # RUN: dir1/lib1.a dir2/lib2.a
55 # RUN: llvm-objdump -s 8 | FileCheck --check-prefix=SECONDFIRST %s
57 ## Verify matching of archive library names in KEEP.
58 # RUN: echo 'SECTIONS{.foo :{ KEEP(*lib2*(.foo)) KEEP(*lib1*(.foo)) }}' > 9.t
59 # RUN: ld.lld -o 9 -T 9.t --whole-archive \
60 # RUN: dir1/lib1.a dir2/lib2.a
61 # RUN: llvm-objdump -s 9 | FileCheck --check-prefix=SECONDFIRST %s
63 ## Verify matching directories in KEEP.
64 # RUN: echo 'SECTIONS{.foo :{ KEEP(*dir2*(.foo)) KEEP(*dir1*(.foo)) }}' > 10.t
65 # RUN: ld.lld -o 10 -T 10.t --whole-archive \
66 # RUN: dir1/lib1.a dir2/lib2.a
67 # RUN: llvm-objdump -s 10 | FileCheck --check-prefix=SECONDFIRST %s
69 ## () can appear in a quoted filename pattern.
70 # RUN: cp dir1/lib1.a 'lib1().a'
71 # RUN: echo 'SECTIONS{.foo :{ KEEP(*dir2*(.foo)) KEEP("lib1().a"(.foo)) }}' > 11.t
72 # RUN: ld.lld -o 11 -T 11.t --whole-archive 'lib1().a' dir2/lib2.a
73 # RUN: llvm-objdump -s 11 | FileCheck --check-prefix=SECONDFIRST %s
75 #--- tx.s
76 .global _start
77 _start:
78 nop
80 .section .foo,"a"
81 .quad 1
83 #--- ty.s
84 .section .foo,"a"
85 .quad 0x11