Revert "r250372 - [ELF2/PPC64] Remove now-dead weak/undef check"

Unfortunately, the check was not as dead as I had thought, and adjusting the
starting VA again exposed the problem. We end up trying to relocate the bl
(using a 24-bit relative offset) to a symbol address of zero, and in general,
that does not fit.

Thus, reverting for now, and adding a test case.

llvm-svn: 250423
This commit is contained in:
Hal Finkel 2015-10-15 16:12:35 +00:00
parent 2cd92f1cc7
commit 000561c2f5
2 changed files with 24 additions and 1 deletions

View File

@ -416,7 +416,7 @@ bool PPC64TargetInfo::relocNeedsPlt(uint32_t Type, const SymbolBody &S) const {
return false;
// These are function calls that need to be redirected through a PLT stub.
return S.isShared();
return S.isShared() || (S.isUndefined() && S.isWeak());
}
bool PPC64TargetInfo::isRelRelative(uint32_t Type) const {

View File

@ -0,0 +1,23 @@
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t
# RUN: ld.lld2 %t -o %t2
# RUN: llvm-objdump -d %t2 | FileCheck %s
# REQUIRES: ppc
# CHECK: Disassembly of section .text:
.section ".opd","aw"
.global _start
_start:
.quad .Lfoo,.TOC.@tocbase,0
.text
.Lfoo:
bl weakfunc
nop
blr
.weak weakfunc
# It does not really matter how we fixup the bl, if at all, because it needs to
# be unreachable. But, we should link successfully.
# CHECK: 10010008: 4e 80 00 20 blr