mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
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
This commit is contained in:
parent
ed1b028276
commit
2b86ffe34a
9
deps/lld/ELF/MarkLive.cpp
vendored
9
deps/lld/ELF/MarkLive.cpp
vendored
@ -301,6 +301,15 @@ template <class ELFT> void elf::markLive() {
|
|||||||
// Follow the graph to mark all live sections.
|
// Follow the graph to mark all live sections.
|
||||||
doGcSections<ELFT>();
|
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.
|
// Report garbage-collected sections.
|
||||||
if (Config->PrintGcSections)
|
if (Config->PrintGcSections)
|
||||||
for (InputSectionBase *Sec : InputSections)
|
for (InputSectionBase *Sec : InputSections)
|
||||||
|
Loading…
Reference in New Issue
Block a user