Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -201,7 +201,8 @@ } bool CBP = canBePreempted(Body, NeedsGot); - if (!CBP && (!Config->Shared || Target->isRelRelative(Type))) + if (!CBP && (!Config->Shared || Target->isRelRelative(Type) || + (Body && Body->isWeak() && Body->isUndefined()))) continue; if (CBP) Body->setUsedInDynamicReloc(); Index: test/elf2/ppc64-weak-undef-call-shared.s =================================================================== --- /dev/null +++ test/elf2/ppc64-weak-undef-call-shared.s @@ -0,0 +1,11 @@ +# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o +# RUN: ld.lld2 -shared %t.o -o %t.so +# RUN: llvm-readobj -t -r -dyn-symbols %t.so | FileCheck %s +# REQUIRES: ppc + +.section ".toc","aw" +.quad weakfunc +// CHECK-NOT: R_PPC64_RELATIVE + +.weak weakfunc +