[lld] r277838 - COFF ARM: Error out if 24 bit thumb branches are out of range
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 5 10:33:24 PDT 2016
Author: compnerd
Date: Fri Aug 5 12:33:24 2016
New Revision: 277838
URL: http://llvm.org/viewvc/llvm-project?rev=277838&view=rev
Log:
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ö!
Added:
lld/trunk/test/COFF/Inputs/far-arm-thumb-abs.s
lld/trunk/test/COFF/arm-thumb-branch-error.s
Modified:
lld/trunk/COFF/Chunks.cpp
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=277838&r1=277837&r2=277838&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Fri Aug 5 12:33:24 2016
@@ -99,6 +99,8 @@ static void applyBranch20T(uint8_t *Off,
}
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 J1 = ((~V >> 23) & 1) ^ S;
uint32_t J2 = ((~V >> 22) & 1) ^ S;
Added: lld/trunk/test/COFF/Inputs/far-arm-thumb-abs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/far-arm-thumb-abs.s?rev=277838&view=auto
==============================================================================
--- lld/trunk/test/COFF/Inputs/far-arm-thumb-abs.s (added)
+++ lld/trunk/test/COFF/Inputs/far-arm-thumb-abs.s Fri Aug 5 12:33:24 2016
@@ -0,0 +1,2 @@
+.global too_far1
+too_far1 = 0x1401004
Added: lld/trunk/test/COFF/arm-thumb-branch-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/arm-thumb-branch-error.s?rev=277838&view=auto
==============================================================================
--- lld/trunk/test/COFF/arm-thumb-branch-error.s (added)
+++ lld/trunk/test/COFF/arm-thumb-branch-error.s Fri Aug 5 12:33:24 2016
@@ -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
More information about the llvm-commits
mailing list