[ELF] --warn-backrefs-exclude: use toString to match the documentation
The pattern should patch `a.a(a.o)` instead of `a.a`
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index eed0251..f38d9fa 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -377,9 +377,18 @@
void elf::reportBackrefs() {
for (auto &it : backwardReferences) {
const Symbol &sym = *it.first;
- warn("backward reference detected: " + sym.getName() + " in " +
- toString(it.second.first) + " refers to " +
- toString(it.second.second));
+ std::string to = toString(it.second.second);
+ // Some libraries have known problems and can cause noise. Filter them out
+ // with --warn-backrefs-exclude=. to may look like *.o or *.a(*.o).
+ bool exclude = false;
+ for (const llvm::GlobPattern &pat : config->warnBackrefsExclude)
+ if (pat.match(to)) {
+ exclude = true;
+ break;
+ }
+ if (!exclude)
+ warn("backward reference detected: " + sym.getName() + " in " +
+ toString(it.second.first) + " refers to " + to);
}
}
@@ -515,17 +524,6 @@
// group assignment rule simulates the traditional linker's semantics.
bool backref = config->warnBackrefs && other.file &&
file->groupId < other.file->groupId;
- if (backref) {
- // Some libraries have known problems and can cause noise. Filter them out
- // with --warn-backrefs-exclude=.
- StringRef name =
- !file->archiveName.empty() ? file->archiveName : file->getName();
- for (const llvm::GlobPattern &pat : config->warnBackrefsExclude)
- if (pat.match(name)) {
- backref = false;
- break;
- }
- }
fetch();
// We don't report backward references to weak symbols as they can be