[PATCH] D24726: [ELF] - Linkerscript: reimplement readSectionExcludes()
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 19 07:59:40 PDT 2016
grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
It is not only a bit more straightforward now, but also next 2 issues are solved:
1) It just crashed on ".foo : { *(EXCLUDE_FILE (*file1.o)) }" before.
2) It accepted multiple EXCLUDE_FILEs in a row.
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: no section globs found
+
+# 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
@@ -1070,30 +1070,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;
+ std::vector<StringRef> V;
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());
+ while (!Error && peek() != ")" && peek() != "EXCLUDE_FILE")
+ V.push_back(next());
+
+ if (!V.empty())
+ Cmd->SectionPatterns.push_back(
+ {std::move(ExcludeFileRe), compileGlobPatterns(V)});
+ else
+ setError("no section globs found");
}
+ expect(")");
}
InputSectionDescription *
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24726.71822.patch
Type: text/x-patch
Size: 2108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160919/73d8f9ab/attachment.bin>
More information about the llvm-commits
mailing list