authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-11 18:02:27-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-11 18:15:33-04:00
log2b86ffe34a7a03b20544b13f541f61bbc50ae015
tree74e309b9a524a5115a381fc37eb1312b42301b36
parented1b028276bc1d17ee5e99863dd5bf150c8aa2f7

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

1 files changed, 9 insertions(+), 0 deletions(-)

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