2016-07-29 05:51:30 +08:00
|
|
|
# REQUIRES: x86
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tx.o
|
2016-07-29 05:51:30 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: %p/Inputs/filename-spec.s -o %ty.o
|
2016-07-29 05:51:30 +08:00
|
|
|
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ KEEP(*x.o(.foo)) KEEP(*y.o(.foo)) }}" > %t1.script
|
|
|
|
# RUN: ld.lld -o %t1 --script %t1.script %tx.o %ty.o
|
|
|
|
# RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=FIRSTY %s
|
|
|
|
# FIRSTY: Contents of section .foo:
|
|
|
|
# FIRSTY-NEXT: 01000000 00000000 11000000 00000000
|
2016-07-29 05:51:30 +08:00
|
|
|
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ KEEP(*y.o(.foo)) KEEP(*x.o(.foo)) }}" > %t2.script
|
|
|
|
# RUN: ld.lld -o %t2 --script %t2.script %tx.o %ty.o
|
2016-07-29 05:51:30 +08:00
|
|
|
# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SECONDFIRST %s
|
|
|
|
# SECONDFIRST: Contents of section .foo:
|
2016-09-20 23:08:24 +08:00
|
|
|
# SECONDFIRST-NEXT: 11000000 00000000 01000000 00000000
|
2016-07-29 05:51:30 +08:00
|
|
|
|
|
|
|
## Now the same tests but without KEEP. Checking that file name inside
|
|
|
|
## KEEP is parsed fine.
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ *x.o(.foo) *y.o(.foo) }}" > %t3.script
|
|
|
|
# RUN: ld.lld -o %t3 --script %t3.script %tx.o %ty.o
|
|
|
|
# RUN: llvm-objdump -s %t3 | FileCheck --check-prefix=FIRSTY %s
|
2016-07-29 05:51:30 +08:00
|
|
|
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ *y.o(.foo) *x.o(.foo) }}" > %t4.script
|
|
|
|
# RUN: ld.lld -o %t4 --script %t4.script %tx.o %ty.o
|
2016-07-29 05:51:30 +08:00
|
|
|
# RUN: llvm-objdump -s %t4 | FileCheck --check-prefix=SECONDFIRST %s
|
|
|
|
|
2019-10-30 01:17:22 +08:00
|
|
|
# RUN: rm -rf %t.dir && mkdir -p %t.dir
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.dir/filename-spec1.o
|
2016-08-30 17:46:59 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
|
2019-10-30 01:17:22 +08:00
|
|
|
# RUN: %p/Inputs/filename-spec.s -o %t.dir/filename-spec2.o
|
2016-08-30 17:46:59 +08:00
|
|
|
|
[lld/ELF] PR44498: Support input filename in double quote
Summary:
Linker scripts allow filenames to be put in double quotes to prevent
characters in filenames that are part of the linker script syntax from
having their special meaning. Case in point the * wildcard character.
Availability of double quoting filenames also allows to fix a failure in
ELF/linkerscript/filename-spec.s when the path contain a @ which the
lexer consider as a special characters and thus break up a filename
containing it. This may happens under Jenkins which createspath such as
pipeline@2.
To avoid the need for escaping GlobPattern metacharacters in filename
in double quotes, GlobPattern::create is augmented with a new parameter
to request literal matching instead of relying on the presence of a
wildcard character in the pattern.
Reviewers: jhenderson, MaskRay, evgeny777, espindola, alexshap
Reviewed By: MaskRay
Subscribers: peter.smith, grimar, ruiu, emaste, arichardson, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72517
2020-01-11 00:56:07 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ \"%/t.dir/filename-spec2.o\"(.foo) \"%/t.dir/filename-spec1.o\"(.foo) }}" > %t5.script
|
2016-08-30 17:46:59 +08:00
|
|
|
# RUN: ld.lld -o %t5 --script %t5.script \
|
2019-10-30 01:17:22 +08:00
|
|
|
# RUN: %/t.dir/filename-spec1.o %/t.dir/filename-spec2.o
|
2016-08-30 17:46:59 +08:00
|
|
|
# RUN: llvm-objdump -s %t5 | FileCheck --check-prefix=SECONDFIRST %s
|
|
|
|
|
[lld/ELF] PR44498: Support input filename in double quote
Summary:
Linker scripts allow filenames to be put in double quotes to prevent
characters in filenames that are part of the linker script syntax from
having their special meaning. Case in point the * wildcard character.
Availability of double quoting filenames also allows to fix a failure in
ELF/linkerscript/filename-spec.s when the path contain a @ which the
lexer consider as a special characters and thus break up a filename
containing it. This may happens under Jenkins which createspath such as
pipeline@2.
To avoid the need for escaping GlobPattern metacharacters in filename
in double quotes, GlobPattern::create is augmented with a new parameter
to request literal matching instead of relying on the presence of a
wildcard character in the pattern.
Reviewers: jhenderson, MaskRay, evgeny777, espindola, alexshap
Reviewed By: MaskRay
Subscribers: peter.smith, grimar, ruiu, emaste, arichardson, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72517
2020-01-11 00:56:07 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ \"%/t.dir/filename-spec1.o\"(.foo) \"%/t.dir/filename-spec2.o\"(.foo) }}" > %t6.script
|
2016-08-30 17:46:59 +08:00
|
|
|
# RUN: ld.lld -o %t6 --script %t6.script \
|
2019-10-30 01:17:22 +08:00
|
|
|
# RUN: %/t.dir/filename-spec1.o %/t.dir/filename-spec2.o
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: llvm-objdump -s %t6 | FileCheck --check-prefix=FIRSTY %s
|
2016-08-30 17:46:59 +08:00
|
|
|
|
2017-08-25 06:01:40 +08:00
|
|
|
# RUN: mkdir -p %t.testdir1 %t.testdir2
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.testdir1/filename-spec1.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
|
|
|
|
# RUN: %p/Inputs/filename-spec.s -o %t.testdir2/filename-spec2.o
|
2018-08-02 19:33:54 +08:00
|
|
|
# RUN: rm -f %t.testdir1/lib1.a %t.testdir2/lib2.a
|
2017-08-25 06:01:40 +08:00
|
|
|
# RUN: llvm-ar rsc %t.testdir1/lib1.a %t.testdir1/filename-spec1.o
|
|
|
|
# RUN: llvm-ar rsc %t.testdir2/lib2.a %t.testdir2/filename-spec2.o
|
|
|
|
|
|
|
|
# Verify matching of archive library names.
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ *lib2*(.foo) *lib1*(.foo) }}" > %t7.script
|
2017-08-25 06:01:40 +08:00
|
|
|
# RUN: ld.lld -o %t7 --script %t7.script --whole-archive \
|
|
|
|
# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a
|
|
|
|
# RUN: llvm-objdump -s %t7 | FileCheck --check-prefix=SECONDFIRST %s
|
|
|
|
|
|
|
|
# Verify matching directories.
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ *testdir2*(.foo) *testdir1*(.foo) }}" > %t8.script
|
2017-08-25 06:01:40 +08:00
|
|
|
# RUN: ld.lld -o %t8 --script %t8.script --whole-archive \
|
|
|
|
# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a
|
|
|
|
# RUN: llvm-objdump -s %t8 | FileCheck --check-prefix=SECONDFIRST %s
|
|
|
|
|
|
|
|
# Verify matching of archive library names in KEEP.
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ KEEP(*lib2*(.foo)) KEEP(*lib1*(.foo)) }}" > %t9.script
|
2017-08-25 06:01:40 +08:00
|
|
|
# RUN: ld.lld -o %t9 --script %t9.script --whole-archive \
|
|
|
|
# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a
|
|
|
|
# RUN: llvm-objdump -s %t9 | FileCheck --check-prefix=SECONDFIRST %s
|
|
|
|
|
|
|
|
# Verify matching directories in KEEP.
|
2018-03-01 12:21:42 +08:00
|
|
|
# RUN: echo "SECTIONS{.foo :{ KEEP(*testdir2*(.foo)) KEEP(*testdir1*(.foo)) }}" > %t10.script
|
2017-08-25 06:01:40 +08:00
|
|
|
# RUN: ld.lld -o %t10 --script %t10.script --whole-archive \
|
|
|
|
# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a
|
|
|
|
# RUN: llvm-objdump -s %t10 | FileCheck --check-prefix=SECONDFIRST %s
|
|
|
|
|
2016-07-29 05:51:30 +08:00
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
nop
|
|
|
|
|
|
|
|
.section .foo,"a"
|
|
|
|
.quad 1
|