[lld] r280366 - Sign extend a value before passing it to the Target.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 1 06:52:53 PDT 2016
Author: rafael
Date: Thu Sep 1 08:52:52 2016
New Revision: 280366
URL: http://llvm.org/viewvc/llvm-project?rev=280366&view=rev
Log:
Sign extend a value before passing it to the Target.
This is what InputSectionBase<ELFT>::relocate does and we need to be
consistent. The other option would be to be more explicit about which
relocations are signed and which are not, and sign extend only when
appropriated. That would require extending the target interface.
Added:
lld/trunk/test/ELF/arm-thumb-interwork-thunk-range.s
Modified:
lld/trunk/ELF/Thunks.cpp
Modified: lld/trunk/ELF/Thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.cpp?rev=280366&r1=280365&r2=280366&view=diff
==============================================================================
--- lld/trunk/ELF/Thunks.cpp (original)
+++ lld/trunk/ELF/Thunks.cpp Thu Sep 1 08:52:52 2016
@@ -100,7 +100,8 @@ public:
// ARM Target Thunks
template <class ELFT> static uint64_t getARMThunkDestVA(const SymbolBody &S) {
- return S.isInPlt() ? S.getPltVA<ELFT>() : S.getVA<ELFT>();
+ uint64_t V = S.isInPlt() ? S.getPltVA<ELFT>() : S.getVA<ELFT>();
+ return SignExtend64<32>(V);
}
template <class ELFT>
Added: lld/trunk/test/ELF/arm-thumb-interwork-thunk-range.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/arm-thumb-interwork-thunk-range.s?rev=280366&view=auto
==============================================================================
--- lld/trunk/test/ELF/arm-thumb-interwork-thunk-range.s (added)
+++ lld/trunk/test/ELF/arm-thumb-interwork-thunk-range.s Thu Sep 1 08:52:52 2016
@@ -0,0 +1,14 @@
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
+// RUN: ld.lld %t.o -o %t -image-base=0x80000000
+
+// Test that when the thunk is at a high address we don't get confused with it
+// being out of range.
+
+.thumb
+.global _start
+_start:
+b.w foo
+
+.arm
+.weak foo
+foo:
More information about the llvm-commits
mailing list