[ELF2/PPC64] Error on R_PPC64_ADDR16 overflow

R_PPC64_ADDR16 is not a truncated relocation, and should error if the address
cannot be represented in 16 bits.

llvm-svn: 250424
This commit is contained in:
Hal Finkel 2015-10-15 16:17:30 +00:00
parent 000561c2f5
commit 33e17a7c73
2 changed files with 10 additions and 1 deletions

View File

@ -465,7 +465,9 @@ void PPC64TargetInfo::relocateOne(uint8_t *Buf, uint8_t *BufEnd,
switch (Type) {
case R_PPC64_ADDR16:
write16be(L, applyPPCLo(R));
if (!isInt<16>(R))
error("Relocation R_PPC64_ADDR16 overflow");
write16be(L, R);
break;
case R_PPC64_ADDR16_DS:
if (!isInt<16>(R))

View File

@ -0,0 +1,7 @@
// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t
// RUN: not ld.lld2 -shared %t -o %t2 2>&1 | FileCheck %s
// REQUIRES: ppc
.short sym+65539
// CHECK: Relocation R_PPC64_ADDR16 overflow