[PATCH] D24726: [ELF] - Linkerscript: reimplement readSectionExcludes()
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 20 02:44:40 PDT 2016
grimar updated this revision to Diff 71909.
grimar added a comment.
- Addressed review comments.
https://reviews.llvm.org/D24726
Files:
ELF/LinkerScript.cpp
test/ELF/linkerscript/exclude-multiple.s
Index: test/ELF/linkerscript/exclude-multiple.s
===================================================================
--- test/ELF/linkerscript/exclude-multiple.s
+++ test/ELF/linkerscript/exclude-multiple.s
@@ -18,6 +18,15 @@
# CHECK-NEXT: Contents of section .foo.3:
# CHECK-NEXT: 0160 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
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -1064,30 +1064,24 @@
// * 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 *
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24726.71909.patch
Type: text/x-patch
Size: 2175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160920/847efa35/attachment.bin>
More information about the llvm-commits
mailing list