]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/linkerscript/filename-spec.s
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / test / ELF / linkerscript / filename-spec.s
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tx.o
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
4 # RUN:   %p/Inputs/filename-spec.s -o %ty.o
5
6 # RUN: echo "SECTIONS{.foo :{ KEEP(*x.o(.foo)) KEEP(*y.o(.foo)) }}" > %t1.script
7 # RUN: ld.lld -o %t1 --script %t1.script %tx.o %ty.o
8 # RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=FIRSTY %s
9 # FIRSTY:      Contents of section .foo:
10 # FIRSTY-NEXT:   01000000 00000000 11000000 00000000
11
12 # RUN: echo "SECTIONS{.foo :{ KEEP(*y.o(.foo)) KEEP(*x.o(.foo)) }}" > %t2.script
13 # RUN: ld.lld -o %t2 --script %t2.script %tx.o %ty.o
14 # RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SECONDFIRST %s
15 # SECONDFIRST:      Contents of section .foo:
16 # SECONDFIRST-NEXT:   11000000 00000000 01000000 00000000
17
18 ## Now the same tests but without KEEP. Checking that file name inside
19 ## KEEP is parsed fine.
20 # RUN: echo "SECTIONS{.foo :{ *x.o(.foo) *y.o(.foo) }}" > %t3.script
21 # RUN: ld.lld -o %t3 --script %t3.script %tx.o %ty.o
22 # RUN: llvm-objdump -s %t3 | FileCheck --check-prefix=FIRSTY %s
23
24 # RUN: echo "SECTIONS{.foo :{ *y.o(.foo) *x.o(.foo) }}" > %t4.script
25 # RUN: ld.lld -o %t4 --script %t4.script %tx.o %ty.o
26 # RUN: llvm-objdump -s %t4 | FileCheck --check-prefix=SECONDFIRST %s
27
28 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %T/filename-spec1.o
29 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
30 # RUN:   %p/Inputs/filename-spec.s -o %T/filename-spec2.o
31
32 # RUN: echo "SECTIONS{.foo :{ %T/filename-spec2.o(.foo) %T/filename-spec1.o(.foo) }}" > %t5.script
33 # RUN: ld.lld -o %t5 --script %t5.script \
34 # RUN:   %T/filename-spec1.o %T/filename-spec2.o
35 # RUN: llvm-objdump -s %t5 | FileCheck --check-prefix=SECONDFIRST %s
36
37 # RUN: echo "SECTIONS{.foo :{ %T/filename-spec1.o(.foo) %T/filename-spec2.o(.foo) }}" > %t6.script
38 # RUN: ld.lld -o %t6 --script %t6.script \
39 # RUN:   %T/filename-spec1.o %T/filename-spec2.o
40 # RUN: llvm-objdump -s %t6 | FileCheck --check-prefix=FIRSTY %s
41
42 # RUN: mkdir -p %t.testdir1 %t.testdir2
43 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.testdir1/filename-spec1.o
44 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
45 # RUN:   %p/Inputs/filename-spec.s -o %t.testdir2/filename-spec2.o
46 # RUN: llvm-ar rsc %t.testdir1/lib1.a %t.testdir1/filename-spec1.o
47 # RUN: llvm-ar rsc %t.testdir2/lib2.a %t.testdir2/filename-spec2.o
48
49 # Verify matching of archive library names.
50 # RUN: echo "SECTIONS{.foo :{ *lib2*(.foo) *lib1*(.foo) }}" > %t7.script
51 # RUN: ld.lld -o %t7 --script %t7.script --whole-archive \
52 # RUN:   %t.testdir1/lib1.a %t.testdir2/lib2.a
53 # RUN: llvm-objdump -s %t7 | FileCheck --check-prefix=SECONDFIRST %s
54
55 # Verify matching directories.
56 # RUN: echo "SECTIONS{.foo :{  *testdir2*(.foo) *testdir1*(.foo) }}" > %t8.script
57 # RUN: ld.lld -o %t8 --script %t8.script --whole-archive \
58 # RUN:   %t.testdir1/lib1.a %t.testdir2/lib2.a
59 # RUN: llvm-objdump -s %t8 | FileCheck --check-prefix=SECONDFIRST %s
60
61 # Verify matching of archive library names in KEEP.
62 # RUN: echo "SECTIONS{.foo :{ KEEP(*lib2*(.foo)) KEEP(*lib1*(.foo)) }}" > %t9.script
63 # RUN: ld.lld -o %t9 --script %t9.script --whole-archive \
64 # RUN:   %t.testdir1/lib1.a %t.testdir2/lib2.a
65 # RUN: llvm-objdump -s %t9 | FileCheck --check-prefix=SECONDFIRST %s
66
67 # Verify matching directories in KEEP.
68 # RUN: echo "SECTIONS{.foo :{ KEEP(*testdir2*(.foo)) KEEP(*testdir1*(.foo)) }}" > %t10.script
69 # RUN: ld.lld -o %t10 --script %t10.script --whole-archive \
70 # RUN:   %t.testdir1/lib1.a %t.testdir2/lib2.a
71 # RUN: llvm-objdump -s %t10 | FileCheck --check-prefix=SECONDFIRST %s
72
73 .global _start
74 _start:
75  nop
76
77 .section .foo,"a"
78  .quad 1