lld: do not report undefined weak references in shared libraries
authornaddy <naddy@openbsd.org>
Tue, 28 Dec 2021 21:13:20 +0000 (21:13 +0000)
committernaddy <naddy@openbsd.org>
Tue, 28 Dec 2021 21:13:20 +0000 (21:13 +0000)
https://github.com/llvm/llvm-project/commit/52bfd2c1ccd86ff813ee6df5a6700690acdd912f

This fixes an issue introduced in D101996.

A weak reference in a shared library could be incorrectly reported if
there is another library that has a strong reference to the same symbol.

Differential Revision: https://reviews.llvm.org/D115041

ok patrick@ kettenis@

gnu/llvm/lld/ELF/InputFiles.cpp

index d5b9efb..ab65571 100644 (file)
@@ -1567,7 +1567,7 @@ template <class ELFT> void SharedFile::parse() {
       Symbol *s = symtab->addSymbol(
           Undefined{this, name, sym.getBinding(), sym.st_other, sym.getType()});
       s->exportDynamic = true;
-      if (s->isUndefined() && !s->isWeak() &&
+      if (s->isUndefined() && sym.getBinding() != STB_WEAK &&
           config->unresolvedSymbolsInShlib != UnresolvedPolicy::Ignore)
         requiredSymbols.push_back(s);
       continue;