summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
-rw-r--r--lld/ELF/LinkerScript.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 5cdee7082e1..b0a83d8d5cf 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -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);
OpenPOWER on IntegriCloud