Skip to content

Commit f902250

Browse files
author
George Rimar
committedApr 22, 2019
[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
1 parent ee12a75 commit f902250

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎lld/ELF/ScriptParser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ std::vector<SectionPattern> ScriptParser::readInputSectionsList() {
636636

637637
std::vector<StringRef> V;
638638
while (!errorCount() && peek() != ")" && peek() != "EXCLUDE_FILE")
639-
V.push_back(next());
639+
V.push_back(unquote(next()));
640640

641641
if (!V.empty())
642642
Ret.push_back({std::move(ExcludeFilePat), StringMatcher(V)});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# REQUIRES: x86
2+
3+
## Handling of quotes is tricky sometimes. Check we do that right and include
4+
## "foo bar" section into .data as expected.
5+
6+
# RUN: echo '.section "foo bar", "aw"; nop' | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t
7+
# RUN: ld.lld %t --script %s -o %t2 --print-map | FileCheck %s
8+
# CHECK: .data
9+
# CHECK-NEXT: {{.*}}(foo bar)
10+
11+
SECTIONS {
12+
.data : { *("foo bar") }
13+
}

0 commit comments

Comments
 (0)
Please sign in to comment.