[lld] r252169 - Check the range of R_X86_64_TPOFF32.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 5 07:22:26 PST 2015
Author: rafael
Date: Thu Nov 5 09:22:26 2015
New Revision: 252169
URL: http://llvm.org/viewvc/llvm-project?rev=252169&view=rev
Log:
Check the range of R_X86_64_TPOFF32.
Added:
lld/trunk/test/elf2/tls-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=252169&r1=252168&r2=252169&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Nov 5 09:22:26 2015
@@ -339,9 +339,13 @@ void X86_64TargetInfo::relocateOne(uint8
error("R_X86_64_32S out of range");
write32le(Loc, SA);
break;
- case R_X86_64_TPOFF32:
- write32le(Loc, SA - Out<llvm::object::ELF64LE>::TlsInitImageAlignedSize);
+ case R_X86_64_TPOFF32: {
+ uint64_t Val = SA - Out<llvm::object::ELF64LE>::TlsInitImageAlignedSize;
+ if (!isInt<32>(Val))
+ error("R_X86_64_TPOFF32 out of range");
+ write32le(Loc, Val);
break;
+ }
default:
error("unrecognized reloc " + Twine(Type));
}
Added: lld/trunk/test/elf2/tls-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/tls-error.s?rev=252169&view=auto
==============================================================================
--- lld/trunk/test/elf2/tls-error.s (added)
+++ lld/trunk/test/elf2/tls-error.s Thu Nov 5 09:22:26 2015
@@ -0,0 +1,12 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+// RUN: not ld.lld2 %t -o %tout 2>&1 | FileCheck %s
+// CHECK: R_X86_64_TPOFF32 out of range
+
+.global _start
+_start:
+ movl %fs:a at tpoff, %eax
+.global a
+.section .tbss,"awT", at nobits
+a:
+.zero 0x80000001
More information about the llvm-commits
mailing list