[lld] r250424 - [ELF2/PPC64] Error on R_PPC64_ADDR16 overflow
Hal Finkel via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 15 09:17:31 PDT 2015
Author: hfinkel
Date: Thu Oct 15 11:17:30 2015
New Revision: 250424
URL: http://llvm.org/viewvc/llvm-project?rev=250424&view=rev
Log:
[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.
Added:
lld/trunk/test/elf2/ppc64-addr16-error.s
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=250424&r1=250423&r2=250424&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Oct 15 11:17:30 2015
@@ -465,7 +465,9 @@ void PPC64TargetInfo::relocateOne(uint8_
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))
Added: lld/trunk/test/elf2/ppc64-addr16-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/ppc64-addr16-error.s?rev=250424&view=auto
==============================================================================
--- lld/trunk/test/elf2/ppc64-addr16-error.s (added)
+++ lld/trunk/test/elf2/ppc64-addr16-error.s Thu Oct 15 11:17:30 2015
@@ -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
More information about the llvm-commits
mailing list