[PATCH] D41163: [LLD] [COFF] Error out if 20 bit thumb branches are out of range

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 00:57:22 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL320677: [COFF] Error out if 20 bit thumb branches are out of range (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41163?vs=126699&id=126908#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41163

Files:
  lld/trunk/COFF/Chunks.cpp
  lld/trunk/test/COFF/Inputs/far-arm-thumb-abs20.s
  lld/trunk/test/COFF/arm-thumb-branch20-error.s


Index: lld/trunk/test/COFF/arm-thumb-branch20-error.s
===================================================================
--- lld/trunk/test/COFF/arm-thumb-branch20-error.s
+++ lld/trunk/test/COFF/arm-thumb-branch20-error.s
@@ -0,0 +1,10 @@
+// REQUIRES: arm
+// RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %s -o %t.obj
+// RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %S/Inputs/far-arm-thumb-abs20.s -o %t.far.obj
+// RUN: not lld-link -entry:_start -subsystem:console %t.obj %t.far.obj -out:%t.exe 2>&1 | FileCheck %s
+ .syntax unified
+ .globl _start
+_start:
+ bne too_far20
+
+// CHECK: relocation out of range
Index: lld/trunk/test/COFF/Inputs/far-arm-thumb-abs20.s
===================================================================
--- lld/trunk/test/COFF/Inputs/far-arm-thumb-abs20.s
+++ lld/trunk/test/COFF/Inputs/far-arm-thumb-abs20.s
@@ -0,0 +1,2 @@
+.global too_far20
+too_far20 = 0x501004
Index: lld/trunk/COFF/Chunks.cpp
===================================================================
--- lld/trunk/COFF/Chunks.cpp
+++ lld/trunk/COFF/Chunks.cpp
@@ -129,6 +129,8 @@
 }
 
 static void applyBranch20T(uint8_t *Off, int32_t V) {
+  if (!isInt<21>(V))
+    fatal("relocation out of range");
   uint32_t S = V < 0 ? 1 : 0;
   uint32_t J1 = (V >> 19) & 1;
   uint32_t J2 = (V >> 18) & 1;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41163.126908.patch
Type: text/x-patch
Size: 1323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171214/cb694950/attachment.bin>


More information about the llvm-commits mailing list