This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Fix assembly of Thumb pcrel LDRs against global symbols
- From: Dave Martin <dave dot martin at linaro dot org>
- To: binutils at sourceware dot org, patches at linaro dot org, richard dot sandiford at linaro dot org
- Date: Tue, 1 Mar 2011 11:23:01 +0000
- Subject: Re: Fix assembly of Thumb pcrel LDRs against global symbols
- References: <g4tyfoxqlj.fsf@linaro.org>
Hi,
On Mon, Feb 28, 2011 at 12:59:04PM +0000, Richard Sandiford wrote:
> The PC-relative LDR instructions have no associated relocation,
> so even LDRs for global symbols should be resolved by the assembler.
> We currently handle this correctly for single-register ARM loads,
> but we're missing the associated relocation types for LDRD and Thumb.
> This leads to errors like:
>
> Error: invalid offset, value too big (0xFFFFFFFFFFFFFFFC)
>
> or:
>
> Error: cannot represent T32_OFFSET_IMM relocation in this object file format
>
> Tested on arm-linux-gnueabi. OK to install?
This seems to work for me for some simple ldrs on locally-
defined global symbols in Thumb.
Note that the annotation of ldrd instructions in Thumb during
disassembly appears incomplete: the target label is not
annotated, whereas for ldr, or for ldr or ldrd in ARM, the
instruction is annotated with the target label in the
disassembly.
I believe the generated instruction encoding is right in the case
shown below, but it might be a good idea to double-check.
Cheers
---Dave
binutils$ cat <<EOF >ldr-tst.s
.syntax unified
.globl d
d: .quad 0
.type f, %function
f: ldrd r0, r1, d
nop
ldrd r0, r1, d
ldr r0, d
nop
ldr r0, d
EOF
binutils$ binutils/objdump -mthumb -o ldr-tst.o ldr-tst.s && arm-linux-gnueabi-objdump -dr ldr-tst.o
[...]
Disassembly of section .text:
00000000 <d>:
...
00000008 <f>:
8: e95f 0103 ldrd r0, r1, [pc, #-12]
c: 46c0 nop ; (mov r8, r8)
e: e95f 0104 ldrd r0, r1, [pc, #-16]
12: f85f 0014 ldr.w r0, [pc, #-20] ; 0 <d>
16: 46c0 nop ; (mov r8, r8)
18: f85f 001c ldr.w r0, [pc, #-28] ; 0 <d>