diff --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp --- a/lld/ELF/Arch/PPC64.cpp +++ b/lld/ELF/Arch/PPC64.cpp @@ -1373,6 +1373,10 @@ if (s.isUndefWeak() && !config->shared) return false; + // Local undefined. + if (s.isUndefined() && s.isLocal()) + return false; + // If the offset exceeds the range of the branch type then it will need // a range-extending thunk. // See the comment in getRelocTargetVA() about R_PPC64_CALL. diff --git a/lld/test/ELF/ppc64-weak-hidden-undef.s b/lld/test/ELF/ppc64-weak-hidden-undef.s new file mode 100644 --- /dev/null +++ b/lld/test/ELF/ppc64-weak-hidden-undef.s @@ -0,0 +1,17 @@ +# REQUIRES: ppc +# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o +# RUN: ld.lld %t.o -o %t +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s + +# CHECK-LABEL:
: +# CHECK: bl +# CHECK-NEXT: nop +# CHECK-NEXT: blr + +main: + bl callee + nop + blr + + .hidden callee + .weak callee