[PATCH] D33838: [ARM] Create relocations for wide Thumb2 unconditional branches.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 2 09:19:22 PDT 2017


fhahn created this revision.
Herald added subscribers: javed.absar, aemerson.

The ARM ELF ABI requires the linker to do interworking for wide branches
from Thumb code to ARM code. The range for Thumb2 unconditional branches
is the same as for BL.

That was pointed out by @peter.smith in the comments for https://reviews.llvm.org/D33436.


https://reviews.llvm.org/D33838

Files:
  lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  test/MC/ARM/thumb2-wide-branch-fixup.s


Index: test/MC/ARM/thumb2-wide-branch-fixup.s
===================================================================
--- /dev/null
+++ test/MC/ARM/thumb2-wide-branch-fixup.s
@@ -0,0 +1,50 @@
+@ RUN: llvm-mc < %s -triple armv7-linux-gnueabi -filetype=obj -o - \
+@ RUN:   | llvm-readobj -r | FileCheck %s
+
+  .code  16
+  .thumb_func
+thumb_caller:
+  b.w internal_arm_fn
+  b.w global_arm_fn
+  b.w global_thumb_fn
+  b.w internal_thumb_fn
+  b.w far_thumb_fn
+
+  .type  internal_arm_fn,%function
+  .code  32
+internal_arm_fn:
+  bx  lr
+
+  .globl  global_arm_fn
+  .type  global_arm_fn,%function
+  .code  32
+global_arm_fn:
+  bx  lr
+
+  .type  internal_thumb_fn,%function
+  .code  16
+  .thumb_func
+internal_thumb_fn:
+  bx  lr
+
+  .globl  global_thumb_fn
+  .type  global_thumb_fn,%function
+  .code  16
+  .thumb_func
+global_thumb_fn:
+  bx  lr
+  .space 0x400004
+
+  .type  far_thumb_fn,%function
+  .code  16
+  .thumb_func
+far_thumb_fn:
+  bx  lr
+
+
+@ CHECK: Section (3) .rel.text
+@ CHECK-NEXT: 0x0 R_ARM_THM_JUMP24 internal_arm_fn 0x0
+@ CHECK-NEXT: 0x4 R_ARM_THM_JUMP24 global_arm_fn 0x0
+@ CHECK-NEXT: 0x8 R_ARM_THM_JUMP24 global_thumb_fn 0x0
+@ CHECK-NEXT: 0x10 R_ARM_THM_JUMP24 far_thumb_fn 0x0
+@ CHECK-NEXT: }
Index: lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
===================================================================
--- lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
+++ lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
@@ -719,7 +719,8 @@
         Value |= 1;
     }
   }
-  if (IsResolved && (unsigned)Fixup.getKind() == ARM::fixup_arm_thumb_bl) {
+  if (IsResolved && ((unsigned)Fixup.getKind() == ARM::fixup_arm_thumb_bl ||
+                     (unsigned)Fixup.getKind() == ARM::fixup_t2_uncondbranch)) {
     assert(Sym && "How did we resolve this?");
 
     // If the symbol is external the linker will handle it.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33838.101218.patch
Type: text/x-patch
Size: 1858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170602/53325a6c/attachment.bin>


More information about the llvm-commits mailing list