[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
This commit is contained in:
George Rimar
2016-09-21 08:53:21 +00:00
parent fda467b252
commit 601e989879
2 changed files with 21 additions and 18 deletions

View File

@@ -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 *