diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 3d7c748b0c5b..d7c82db2c823 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -391,14 +391,12 @@ void Writer::scanRelocs( // a relocation from an object file, but some relocations need no // load-time fixup when the final target is known. Skip such relocation. bool CBP = canBePreempted(Body, /*NeedsGot=*/false); - bool NoDynrel = Target->isRelRelative(Type) || Target->isSizeRel(Type) || - !Config->Shared; - if (!CBP && NoDynrel) - continue; - + bool Dynrel = Config->Shared && !Target->isRelRelative(Type) && + !Target->isSizeRel(Type); if (CBP) Body->setUsedInDynamicReloc(); - Out::RelaDyn->addReloc({&C, &RI}); + if (CBP || Dynrel) + Out::RelaDyn->addReloc({&C, &RI}); } }