| ... | ... | @@ -301,6 +301,15 @@ template <class ELFT> void elf::markLive() { |
| 301 | 301 | // Follow the graph to mark all live sections. |
| 302 | 302 | doGcSections<ELFT>(); |
| 303 | 303 | |
| 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 | |
| 304 | 313 | // Report garbage-collected sections. |
| 305 | 314 | if (Config->PrintGcSections) |
| 306 | 315 | for (InputSectionBase *Sec : InputSections) |