summaryrefslogtreecommitdiff
path: root/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
-rw-r--r--lld/ELF/LinkerScript.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 7d24c6750b0d..a8e3d6486353 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -402,33 +402,30 @@ void LinkerScript::assignSymbol(SymbolAssignment *cmd, bool inSec) {
cmd->sym->type = v.type;
}
-static inline StringRef getFilename(const InputFile *file) {
- return file ? file->getNameForScript() : StringRef();
-}
-
-bool InputSectionDescription::matchesFile(const InputFile *file) const {
+bool InputSectionDescription::matchesFile(const InputFile &file) const {
if (filePat.isTrivialMatchAll())
return true;
- if (!matchesFileCache || matchesFileCache->first != file)
- matchesFileCache.emplace(file, filePat.match(getFilename(file)));
+ if (!matchesFileCache || matchesFileCache->first != &file)
+ matchesFileCache.emplace(&file, filePat.match(file.getNameForScript()));
return matchesFileCache->second;
}
-bool SectionPattern::excludesFile(const InputFile *file) const {
+bool SectionPattern::excludesFile(const InputFile &file) const {
if (excludedFilePat.empty())
return false;
- if (!excludesFileCache || excludesFileCache->first != file)
- excludesFileCache.emplace(file, excludedFilePat.match(getFilename(file)));
+ if (!excludesFileCache || excludesFileCache->first != &file)
+ excludesFileCache.emplace(&file,
+ excludedFilePat.match(file.getNameForScript()));
return excludesFileCache->second;
}
bool LinkerScript::shouldKeep(InputSectionBase *s) {
for (InputSectionDescription *id : keptSections)
- if (id->matchesFile(s->file))
+ if (id->matchesFile(*s->file))
for (SectionPattern &p : id->sectionPatterns)
if (p.sectionPat.match(s->name) &&
(s->flags & id->withFlags) == id->withFlags &&
@@ -557,7 +554,7 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
if (!pat.sectionPat.match(sec->name))
continue;
- if (!cmd->matchesFile(sec->file) || pat.excludesFile(sec->file) ||
+ if (!cmd->matchesFile(*sec->file) || pat.excludesFile(*sec->file) ||
sec->parent == &outCmd || !flagsMatch(sec))
continue;