Index: ELF/LTO.cpp =================================================================== --- ELF/LTO.cpp +++ ELF/LTO.cpp @@ -144,7 +144,11 @@ // be removed. R.Prevailing = !ObjSym.isUndefined() && B->getFile() == &F; - R.VisibleToRegularObj = Sym->IsUsedInRegularObj || + // Don't strip external symbols in relocatable links. + bool ExternalReloc = Config->Relocatable && Sym->computeBinding() != STB_LOCAL && + Sym->Visibility == STV_DEFAULT; + + R.VisibleToRegularObj = ExternalReloc || Sym->IsUsedInRegularObj || (R.Prevailing && Sym->includeInDynsym()) || UsedStartStop.count(ObjSym.getSectionName()); if (R.Prevailing)