summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2016-09-21 08:53:21 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2016-09-21 08:53:21 +0000
commit601e9898797f2b5969c5dd2814f9c4fb2e298535 (patch)
tree1708610f75da95c355d0fed7151d807ef0f04973
parentfda467b252413898b40d4db55ea7bbdbb3e535e3 (diff)
downloadbcm5719-llvm-601e9898797f2b5969c5dd2814f9c4fb2e298535.tar.gz
bcm5719-llvm-601e9898797f2b5969c5dd2814f9c4fb2e298535.zip
[ELF] - Linkerscript: reimplement readSectionExcludes()
It is not only a bit more straightforward now, but also next 2 issues are solved: * It just crashed on ".foo : { *(EXCLUDE_FILE (*file1.o)) }" before. * It accepted multiple EXCLUDE_FILEs in a row. Differential revision: https://reviews.llvm.org/D24726 llvm-svn: 282060
-rw-r--r--lld/ELF/LinkerScript.cpp30
-rw-r--r--lld/test/ELF/linkerscript/exclude-multiple.s9
2 files changed, 21 insertions, 18 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 7101c7fa433..a0bffce6383 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -1072,30 +1072,24 @@ SortSectionPolicy ScriptParser::readSortKind() {
// * Include .foo.2 from every file but a.o
// * Include .foo.3 from every file but b.o
void ScriptParser::readSectionExcludes(InputSectionDescription *Cmd) {
- Regex ExcludeFileRe;
- std::vector<StringRef> V;
-
- while (!Error) {
- if (skip(")")) {
- Cmd->SectionPatterns.push_back(
- {std::move(ExcludeFileRe), compileGlobPatterns(V)});
- return;
- }
-
+ while (!Error && peek() != ")") {
+ Regex ExcludeFileRe;
if (skip("EXCLUDE_FILE")) {
- if (!V.empty()) {
- Cmd->SectionPatterns.push_back(
- {std::move(ExcludeFileRe), compileGlobPatterns(V)});
- V.clear();
- }
-
expect("(");
ExcludeFileRe = readFilePatterns();
- continue;
}
- V.push_back(next());
+ std::vector<StringRef> V;
+ while (!Error && peek() != ")" && peek() != "EXCLUDE_FILE")
+ V.push_back(next());
+
+ if (!V.empty())
+ Cmd->SectionPatterns.push_back(
+ {std::move(ExcludeFileRe), compileGlobPatterns(V)});
+ else
+ setError("section pattern is expected");
}
+ expect(")");
}
InputSectionDescription *
diff --git a/lld/test/ELF/linkerscript/exclude-multiple.s b/lld/test/ELF/linkerscript/exclude-multiple.s
index 14272bf4b02..46ec18cfa12 100644
--- a/lld/test/ELF/linkerscript/exclude-multiple.s
+++ b/lld/test/ELF/linkerscript/exclude-multiple.s
@@ -18,6 +18,15 @@
# CHECK-NEXT: Contents of section .foo.3:
# CHECK-NEXT: 06000000 00000000
+# RUN: echo "SECTIONS { .foo : { *(EXCLUDE_FILE (*file1.o) EXCLUDE_FILE (*file2.o) .foo.3) } }" > %t2.script
+# RUN: not ld.lld -script %t2.script %tfile1.o %tfile2.o %tfile3.o -o %t2.o 2>&1 | \
+# RUN: FileCheck %s --check-prefix=ERR
+# ERR: section pattern is expected
+
+# RUN: echo "SECTIONS { .foo : { *(EXCLUDE_FILE (*file1.o)) } }" > %t3.script
+# RUN: not ld.lld -script %t3.script %tfile1.o %tfile2.o %tfile3.o -o %t2.o 2>&1 | \
+# RUN: FileCheck %s --check-prefix=ERR
+
.section .foo.1,"a"
.quad 1
OpenPOWER on IntegriCloud