From bd91b7fe65a92f2def9fe85276b1b647d1f10a98 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 22 Jun 2017 15:32:41 +0000 Subject: [PATCH] [ARM] Create relocations for beq.w branches to ARM function syms. Summary: The ARM ELF ABI requires the linker to do interworking for wide conditional branches from Thumb code to ARM code. That was pointed out by @peter.smith in the comments for D33436. Reviewers: rafael, peter.smith, echristo Reviewed By: peter.smith Subscribers: aemerson, javed.absar, kristof.beyls, llvm-commits, peter.smith Differential Revision: https://reviews.llvm.org/D34447 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306009 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp | 1 + test/MC/ARM/thumb2-beq-fixup.s | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/MC/ARM/thumb2-beq-fixup.s diff --git a/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp b/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp index 1e76f107a84..e06f23a91f5 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp @@ -759,6 +759,7 @@ void ARMAsmBackend::processFixupValue(const MCAssembler &Asm, IsResolved = false; if (!Asm.isThumbFunc(Sym) && (FixupKind == ARM::fixup_arm_thumb_br || FixupKind == ARM::fixup_arm_thumb_bl || + FixupKind == ARM::fixup_t2_condbranch || FixupKind == ARM::fixup_t2_uncondbranch)) IsResolved = false; } diff --git a/test/MC/ARM/thumb2-beq-fixup.s b/test/MC/ARM/thumb2-beq-fixup.s new file mode 100644 index 00000000000..e6d43e8fed9 --- /dev/null +++ b/test/MC/ARM/thumb2-beq-fixup.s @@ -0,0 +1,39 @@ +@ RUN: llvm-mc < %s -triple armv7-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -r | FileCheck %s + + .code 16 + .thumb_func +thumb_caller: + beq.w internal_arm_fn + beq.w global_arm_fn + beq.w global_thumb_fn + beq.w internal_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 + +@ CHECK: Section (3) .rel.text +@ CHECK-NEXT: 0x0 R_ARM_THM_JUMP19 internal_arm_fn 0x0 +@ CHECK-NEXT: 0x4 R_ARM_THM_JUMP19 global_arm_fn 0x0 +@ CHECK-NEXT: } -- 2.40.0