COFF ARM: Error out if 24 bit thumb branches are out of range

In the ELF linker, the same situation already errors out with "relocation
R_ARM_THM_CALL out of range".

Patch by Martin Storsjö!

llvm-svn: 277838
This commit is contained in:
Saleem Abdulrasool 2016-08-05 17:33:24 +00:00
parent 73ff4d08dc
commit eea45bc478
3 changed files with 14 additions and 0 deletions

View File

@ -99,6 +99,8 @@ static void applyBranch20T(uint8_t *Off, int32_t V) {
} }
static void applyBranch24T(uint8_t *Off, int32_t V) { static void applyBranch24T(uint8_t *Off, int32_t V) {
if (!isInt<25>(V))
fatal("relocation out of range");
uint32_t S = V < 0 ? 1 : 0; uint32_t S = V < 0 ? 1 : 0;
uint32_t J1 = ((~V >> 23) & 1) ^ S; uint32_t J1 = ((~V >> 23) & 1) ^ S;
uint32_t J2 = ((~V >> 22) & 1) ^ S; uint32_t J2 = ((~V >> 22) & 1) ^ S;

View File

@ -0,0 +1,2 @@
.global too_far1
too_far1 = 0x1401004

View File

@ -0,0 +1,10 @@
// RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %s -o %t
// RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %S/Inputs/far-arm-thumb-abs.s -o %tfar
// RUN: not lld-link -entry:_start -subsystem:console %t %tfar -out:%t2 2>&1 | FileCheck %s
// REQUIRES: arm
.syntax unified
.globl _start
_start:
bl too_far1
// CHECK: relocation out of range