zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 2b86ffe34a7a03b20544b13f541f61bbc50ae015 (tree)
parent ed1b028276bc1d17ee5e99863dd5bf150c8aa2f7
Author: Andrew Kelley <superjoe30@gmail.com>
Date:   Wed, 11 Apr 2018 18:02:27 -0400

LLD patch: Do not keep shared symbols to garbage...

-collected eliminated DSOs.

This applies https://reviews.llvm.org/D45536 to the embedded
LLD.

Closes #883

Diffstat:
Mdeps/lld/ELF/MarkLive.cpp | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/deps/lld/ELF/MarkLive.cpp b/deps/lld/ELF/MarkLive.cpp @@ -301,6 +301,15 @@ template <class ELFT> void elf::markLive() { // Follow the graph to mark all live sections. doGcSections<ELFT>(); + // If all references to a DSO happen to be weak, the DSO is removed from + // DT_NEEDED, which creates dangling shared symbols to non-existent DSO. + // We'll replace such symbols with undefined ones to fix it. + for (Symbol *Sym : Symtab->getSymbols()) + if (auto *S = dyn_cast<SharedSymbol>(Sym)) + if (S->isWeak() && !S->getFile<ELFT>().IsNeeded) + replaceSymbol<Undefined>(S, nullptr, S->getName(), STB_WEAK, S->StOther, + S->Type); + // Report garbage-collected sections. if (Config->PrintGcSections) for (InputSectionBase *Sec : InputSections)