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);
}
}
// 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
# RUN: ld.lld --warn-backrefs %t2.a %t1.o -o /dev/null 2>&1 | FileCheck %s
# RUN: ld.lld --warn-backrefs %t2.a '-(' %t1.o '-)' -o /dev/null 2>&1 | FileCheck %s
# RUN: ld.lld --warn-backrefs --warn-backrefs-exclude='*3.a' %t2.a %t1.o -o /dev/null 2>&1 | FileCheck %s
-# RUN: ld.lld --fatal-warnings --warn-backrefs --warn-backrefs-exclude='*2.a' %t2.a %t1.o -o /dev/null
-# RUN: ld.lld --fatal-warnings --warn-backrefs --warn-backrefs-exclude '*2.a' \
+# RUN: ld.lld --fatal-warnings --warn-backrefs --warn-backrefs-exclude='*2.a(*2.o)' %t2.a %t1.o -o /dev/null
+# RUN: ld.lld --fatal-warnings --warn-backrefs --warn-backrefs-exclude '*2.a(*2.o)' \
# RUN: --warn-backrefs-exclude not_exist %t2.a %t1.o -o /dev/null
## Without --warn-backrefs, --warn-backrefs-exclude is ignored.
# RUN: ld.lld --fatal-warnings --warn-backrefs-exclude=not_exist %t2.a %t1.o -o /dev/null
# RUN: echo 'GROUP("%t2.a")' > %t3.lds
# RUN: ld.lld --warn-backrefs %t3.lds %t1.o -o /dev/null 2>&1 | FileCheck %s
# RUN: ld.lld --fatal-warnings --warn-backrefs '-(' %t3.lds %t1.o '-)' -o /dev/null
-# RUN: ld.lld --fatal-warnings --warn-backrefs --warn-backrefs-exclude='*2.a' -o /dev/null %t3.lds %t1.o
+# RUN: ld.lld --fatal-warnings --warn-backrefs --warn-backrefs-exclude='*2.a(*2.o)' -o /dev/null %t3.lds %t1.o
## If a lazy definition appears after the backward reference, don't warn.
# RUN: ld.lld --fatal-warnings --warn-backrefs %t3.lds %t1.o %t3.lds -o /dev/null