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: rm -rf %t.dir && mkdir -p %t.dir 29# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.dir/filename-spec1.o 30# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ 31# RUN: %p/Inputs/filename-spec.s -o %t.dir/filename-spec2.o 32 33# RUN: echo "SECTIONS{.foo :{ \"%/t.dir/filename-spec2.o\"(.foo) \"%/t.dir/filename-spec1.o\"(.foo) }}" > %t5.script 34# RUN: ld.lld -o %t5 --script %t5.script \ 35# RUN: %/t.dir/filename-spec1.o %/t.dir/filename-spec2.o 36# RUN: llvm-objdump -s %t5 | FileCheck --check-prefix=SECONDFIRST %s 37 38# RUN: echo "SECTIONS{.foo :{ \"%/t.dir/filename-spec1.o\"(.foo) \"%/t.dir/filename-spec2.o\"(.foo) }}" > %t6.script 39# RUN: ld.lld -o %t6 --script %t6.script \ 40# RUN: %/t.dir/filename-spec1.o %/t.dir/filename-spec2.o 41# RUN: llvm-objdump -s %t6 | FileCheck --check-prefix=FIRSTY %s 42 43# RUN: mkdir -p %t.testdir1 %t.testdir2 44# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.testdir1/filename-spec1.o 45# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ 46# RUN: %p/Inputs/filename-spec.s -o %t.testdir2/filename-spec2.o 47# RUN: rm -f %t.testdir1/lib1.a %t.testdir2/lib2.a 48# RUN: llvm-ar rsc %t.testdir1/lib1.a %t.testdir1/filename-spec1.o 49# RUN: llvm-ar rsc %t.testdir2/lib2.a %t.testdir2/filename-spec2.o 50 51# Verify matching of archive library names. 52# RUN: echo "SECTIONS{.foo :{ *lib2*(.foo) *lib1*(.foo) }}" > %t7.script 53# RUN: ld.lld -o %t7 --script %t7.script --whole-archive \ 54# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a 55# RUN: llvm-objdump -s %t7 | FileCheck --check-prefix=SECONDFIRST %s 56 57# Verify matching directories. 58# RUN: echo "SECTIONS{.foo :{ *testdir2*(.foo) *testdir1*(.foo) }}" > %t8.script 59# RUN: ld.lld -o %t8 --script %t8.script --whole-archive \ 60# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a 61# RUN: llvm-objdump -s %t8 | FileCheck --check-prefix=SECONDFIRST %s 62 63# Verify matching of archive library names in KEEP. 64# RUN: echo "SECTIONS{.foo :{ KEEP(*lib2*(.foo)) KEEP(*lib1*(.foo)) }}" > %t9.script 65# RUN: ld.lld -o %t9 --script %t9.script --whole-archive \ 66# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a 67# RUN: llvm-objdump -s %t9 | FileCheck --check-prefix=SECONDFIRST %s 68 69# Verify matching directories in KEEP. 70# RUN: echo "SECTIONS{.foo :{ KEEP(*testdir2*(.foo)) KEEP(*testdir1*(.foo)) }}" > %t10.script 71# RUN: ld.lld -o %t10 --script %t10.script --whole-archive \ 72# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a 73# RUN: llvm-objdump -s %t10 | FileCheck --check-prefix=SECONDFIRST %s 74 75.global _start 76_start: 77 nop 78 79.section .foo,"a" 80 .quad 1 81