[ELF] Fix ARM and Thumb V7PILongThunk overflow behavior.
authorPeter Smith <peter.smith@linaro.org>
Thu, 10 Jan 2019 16:08:23 +0000 (16:08 +0000)
committerPeter Smith <peter.smith@linaro.org>
Thu, 10 Jan 2019 16:08:23 +0000 (16:08 +0000)
commit1811e48b7b5ce217b9999a85a90a194d13be36ff
tree2a40571c46957e88eca729f5c0d40f91bb84bf69
parent62df5eed16a07c4dd183c71d69d6858b5fa19652
[ELF] Fix ARM and Thumb V7PILongThunk overflow behavior.

When the range between the source and target of a V7PILongThunk exceeded an
int32 we would trigger a relocation out of range error for the
R_ARM_MOVT_PREL or R_ARM_THM_MOVT_PREL relocation. This case can happen when
linking the linux kernel as it is loaded above 0xf0000000.

There are two parts to the fix.
- Remove the overflow check for R_ARM_MOVT_PREL or R_ARM_THM_MOVT_PREL. The
ELF for the ARM Architecture document defines these relocations as having no
overflow checking so the check was spurious.
- Use int64_t for the offset calculation, in line with similar thunks so
that PC + (S - P) < 32-bits. This results in less surprising disassembly.

Differential Revision: https://reviews.llvm.org/D56396

llvm-svn: 350836
lld/ELF/Arch/ARM.cpp
lld/ELF/Thunks.cpp
lld/test/ELF/arm-extreme-range-pi-thunk.s [new file with mode: 0644]