This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [ARM] gas miscompiles ADR statement
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Enrico Scholz <enrico dot scholz at sigma-chemnitz dot de>
- Cc: bug-binutils at gnu dot org, binutils at sources dot redhat dot com
- Date: Tue, 3 Dec 2002 10:31:10 +1030
- Subject: Re: [ARM] gas miscompiles ADR statement
- References: <ly1y50fjow.fsf@ensc-pc.intern.sigma-chemnitz.de>
On Mon, Dec 02, 2002 at 05:51:27PM +0100, Enrico Scholz wrote:
> Hello,
>
> when using the most recent and for linux-kernel compilation
> recommended snapshot of binutils from [1], I get miscompilations
> of ADR statements. The following code is a minimal example:
>
> | $ cat x.s
> | .space 0x0298
> | adral lr, X
> | .space 0x0168
> | adral lr, X1
> |
> | .globl X;
> | X:
> | X1:
> |
> | $ /usr/arm-linux/bin/as-2.13.90.0.16 x.s && objdump -d a.out
> |
> | a.out: file format elf32-littlearm
> |
> | Disassembly of section .text:
> |
> | 00000000 <X-0x408>:
> | ...
> | 298: e24fee2a sub lr, pc, #672 ; 0x2a0
> | ...
> | 404: e24fe004 sub lr, pc, #4 ; 0x4
>
>
> Obviously, the 'sub' at 0x298 is wrong. When using gas-2.13.90.0.4,
> the first line is:
>
> | 298: e28fef5a add lr, pc, #360 ; 0x168
>
> 'gas' was build with './configure --host=i386-redhat-linux
> --target=arm-linux --disable-shared'.
I'm guilty. The problem was introduced with my gas reloc rewrite.
The following should fix it, but I'd like one of the ARM maintainers
to OK it before I commit.
* config/tc-arm.c (arm_force_relocation): Return 0 for IMMEDIATE
and ADRL_IMMEDIATE.
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.132
diff -u -p -r1.132 tc-arm.c
--- gas/config/tc-arm.c 30 Nov 2002 08:39:42 -0000 1.132
+++ gas/config/tc-arm.c 2 Dec 2002 23:47:44 -0000
@@ -11526,6 +11526,11 @@ arm_force_relocation (fixp)
|| fixp->fx_r_type == BFD_RELOC_THUMB_PCREL_BRANCH23)
return 1;
+ /* Resolve immediate relocations even if the symbol is extern or weak. */
+ if (fixp->fx_r_type == BFD_RELOC_ARM_IMMEDIATE
+ || fixp->fx_r_type == BFD_RELOC_ARM_ADRL_IMMEDIATE)
+ return 0;
+
return S_FORCE_RELOC (fixp->fx_addsy);
}
--
Alan Modra
IBM OzLabs - Linux Technology Centre