mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 09:31:59 +08:00
[ELF] make KEEP command recognize file patterns
Differential revision: https://reviews.llvm.org/D25242 llvm-svn: 283305
This commit is contained in:
@@ -108,9 +108,15 @@ template <class ELFT> LinkerScript<ELFT>::~LinkerScript() {}
|
||||
|
||||
template <class ELFT>
|
||||
bool LinkerScript<ELFT>::shouldKeep(InputSectionBase<ELFT> *S) {
|
||||
for (Regex *Re : Opt.KeptSections)
|
||||
if (Re->match(S->Name))
|
||||
return true;
|
||||
for (InputSectionDescription *ID : Opt.KeptSections) {
|
||||
StringRef Filename = S->getFile()->getName();
|
||||
if (!ID->FileRe.match(sys::path::filename(Filename)))
|
||||
continue;
|
||||
|
||||
for (SectionPattern &P : ID->SectionPatterns)
|
||||
if (P.SectionRe.match(S->Name))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1247,8 +1253,7 @@ ScriptParser::readInputSectionDescription(StringRef Tok) {
|
||||
StringRef FilePattern = next();
|
||||
InputSectionDescription *Cmd = readInputSectionRules(FilePattern);
|
||||
expect(")");
|
||||
for (SectionPattern &Pat : Cmd->SectionPatterns)
|
||||
Opt.KeptSections.push_back(&Pat.SectionRe);
|
||||
Opt.KeptSections.push_back(Cmd);
|
||||
return Cmd;
|
||||
}
|
||||
return readInputSectionRules(Tok);
|
||||
|
||||
Reference in New Issue
Block a user