[LLD][ELF] - Handle quoted strings in the linker scripts correctly.

This is the https://bugs.llvm.org/show_bug.cgi?id=41356,

Seems it is kind of unusual case but it is possible to
have sections that require quotes for their namings.
Like "aaa bbb".

This patch adds support for those.

Differential revision: https://reviews.llvm.org/D60901

llvm-svn: 358874
This commit is contained in:
George Rimar
2019-04-22 07:57:07 +00:00
parent ee12a75e38
commit f902250fc1
2 changed files with 14 additions and 1 deletions

View File

@@ -636,7 +636,7 @@ std::vector<SectionPattern> ScriptParser::readInputSectionsList() {
std::vector<StringRef> V;
while (!errorCount() && peek() != ")" && peek() != "EXCLUDE_FILE")
V.push_back(next());
V.push_back(unquote(next()));
if (!V.empty())
Ret.push_back({std::move(ExcludeFilePat), StringMatcher(V)});

View File

@@ -0,0 +1,13 @@
# REQUIRES: x86
## Handling of quotes is tricky sometimes. Check we do that right and include
## "foo bar" section into .data as expected.
# RUN: echo '.section "foo bar", "aw"; nop' | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t
# RUN: ld.lld %t --script %s -o %t2 --print-map | FileCheck %s
# CHECK: .data
# CHECK-NEXT: {{.*}}(foo bar)
SECTIONS {
.data : { *("foo bar") }
}