[PATCH] D45536: Do not keep shared symbols to garbage-collected eliminated DSOs.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 11 17:57:28 PDT 2018


ruiu added inline comments.


================
Comment at: lld/ELF/Driver.cpp:1069
+    if (auto *S = dyn_cast<SharedSymbol>(Sym))
+      if (S->isWeak() && !S->getFile<ELFT>().IsNeeded)
+        replaceSymbol<Undefined>(S, nullptr, S->getName(), STB_WEAK, S->StOther,
----------------
espindola wrote:
> Is this doing the right thing if the symbol in the shared library is weak? Is it necessary? Doesn't IsNeeded already include all the required information?
I believe this does the right thing for weak symbols in shared libraries, because if it is in use, IsNeeded will never be false. Otherwise, the symbol should be handled as if it weren't present from the beginning, so replacing it with an (unresolved) weak undefined seems like the right thing to do.

We could technically ignore shared symbols with a dead file everywhere, but I think purging such symbols all at once before processing further is less error-prone.


https://reviews.llvm.org/D45536





More information about the llvm-commits mailing list