[LinkerScript] Refactor KEEP handling in a separate function

This will grow because I have a patch to support more complex
constructs, e.g.:

KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))

Let's make this a separate function.

llvm-svn: 276695
This commit is contained in:
Davide Italiano 2016-07-25 21:47:13 +00:00
parent bef810ff95
commit 0ed42b0ca0
1 changed files with 15 additions and 10 deletions

View File

@ -426,6 +426,7 @@ private:
void readEntry();
void readExtern();
void readGroup();
void readKeep(OutputSectionCommand *Cmd);
void readInclude();
void readNothing() {}
void readOutput();
@ -665,6 +666,19 @@ static int precedence(StringRef Op) {
.Default(-1);
}
void ScriptParser::readKeep(OutputSectionCommand *Cmd) {
expect("(");
expect("*");
expect("(");
auto *InCmd = new InputSectionDescription();
Cmd->Commands.emplace_back(InCmd);
while (!Error && !skip(")")) {
Opt.KeptSections.push_back(peek());
InCmd->Patterns.push_back(next());
}
expect(")");
}
void ScriptParser::readOutputSectionDescription(StringRef OutSec) {
OutputSectionCommand *Cmd = new OutputSectionCommand(OutSec);
Opt.Commands.emplace_back(Cmd);
@ -692,16 +706,7 @@ void ScriptParser::readOutputSectionDescription(StringRef OutSec) {
while (!Error && !skip(")"))
InCmd->Patterns.push_back(next());
} else if (Tok == "KEEP") {
expect("(");
expect("*");
expect("(");
auto *InCmd = new InputSectionDescription();
Cmd->Commands.emplace_back(InCmd);
while (!Error && !skip(")")) {
Opt.KeptSections.push_back(peek());
InCmd->Patterns.push_back(next());
}
expect(")");
readKeep(Cmd);
} else if (Tok == "PROVIDE") {
readProvide(false);
} else if (Tok == "PROVIDE_HIDDEN") {