From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29817 invoked by alias); 31 May 2011 14:04:58 -0000 Received: (qmail 29806 invoked by uid 22791); 31 May 2011 14:04:57 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_40,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 May 2011 14:04:15 +0000 Received: (qmail 2244 invoked from network); 31 May 2011 14:04:14 -0000 Received: from unknown (HELO wren.localnet) (paul@127.0.0.2) by mail.codesourcery.com with ESMTPA; 31 May 2011 14:04:14 -0000 From: Paul Brook To: binutils@sourceware.org Subject: Thumb branches to an absolute address Date: Tue, 31 May 2011 14:11:00 -0000 User-Agent: KMail/1.13.7 (Linux/2.6.38-2-amd64; KDE/4.6.3; x86_64; ; ) MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_dVP5Np6Gr8vAtek" Message-Id: <201105311504.13361.paul@codesourcery.com> Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00391.txt.bz2 --Boundary-00=_dVP5Np6Gr8vAtek Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-length: 636 The attached patch fixes an assebler bug processing Thumb-2 branches to absolute addresses. We don't know how far away these really are, so if no size suffix is specified we must assume they require a long branch. Currently we end up with a narrow branch, which is almost never suficient. We also segfault in some circumstances. Tested on arm-none-eabi and arm-wrs-vxworks Applied to CVS head Paul 2011-05-31 Paul Brook gas/ * config/tc-arm.c (do_t_branch): Avoid relaxing branches to constant addresses. gas/testsuite/ * arm/t2-branch-global.d: New test. * arm/t2-branch-global.s: New test. --Boundary-00=_dVP5Np6Gr8vAtek Content-Type: text/x-patch; charset="us-ascii"; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch" Content-length: 1333 diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index a9839cd..b09bf81 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -9845,7 +9845,9 @@ do_t_branch (void) if (unified_syntax && (inst.size_req == 4 - || (inst.size_req != 2 && inst.operands[0].hasreloc))) + || (inst.size_req != 2 + && (inst.operands[0].hasreloc + || inst.reloc.exp.X_op == O_constant)))) { inst.instruction = THUMB_OP32(opcode); if (cond == COND_ALWAYS) diff --git a/gas/testsuite/gas/arm/t2-branch-global.d b/gas/testsuite/gas/arm/t2-branch-global.d new file mode 100644 index 0000000..5850d6b --- /dev/null +++ b/gas/testsuite/gas/arm/t2-branch-global.d @@ -0,0 +1,14 @@ +#name: Thumb-2 branch to constant address +#This test is only valid on ELF based ports. +#not-target: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix* +#objdump: -rd + + +.*: +file format.*arm.* + + +Disassembly of section .text: + +00000000 : + 0: f... b... b\.w .* + 0: R_ARM_THM_JUMP24 \*ABS\*.* diff --git a/gas/testsuite/gas/arm/t2-branch-global.s b/gas/testsuite/gas/arm/t2-branch-global.s new file mode 100644 index 0000000..223d924 --- /dev/null +++ b/gas/testsuite/gas/arm/t2-branch-global.s @@ -0,0 +1,5 @@ +.thumb +.arch armv7 +.syntax unified +foo: + b 0x10 @ Assembler must not relax this --Boundary-00=_dVP5Np6Gr8vAtek--