Handle dynamic relocs to weak undefined when possible.
llvm-svn: 250311
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 179e2f0..3af58b2 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -191,20 +191,22 @@
if (Body)
Body = Body->repl();
+ bool NeedsGot = false;
if (Body) {
if (Target->relocNeedsPlt(Type, *Body)) {
if (Body->isInPlt())
continue;
Out<ELFT>::Plt->addEntry(Body);
}
- if (Target->relocNeedsGot(Type, *Body)) {
+ NeedsGot = Target->relocNeedsGot(Type, *Body);
+ if (NeedsGot) {
if (Body->isInGot())
continue;
Out<ELFT>::Got->addEntry(Body);
}
}
- bool CBP = canBePreempted(Body);
+ bool CBP = canBePreempted(Body, NeedsGot);
if (!CBP && (!Config->Shared || Target->isRelRelative(Type)))
continue;
if (CBP)