This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: GAS compiling problem on ARM
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Mats Liljegren <mlil at enea dot se>
- Cc: binutils <binutils at sourceware dot org>, Richard dot Earnshaw at arm dot com
- Date: Thu, 03 Jul 2003 18:30:35 +0100
- Subject: Re: GAS compiling problem on ARM
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> Hi,
>
> I'm using binutils-2.13.92, configured with:
> ../binutils-2.13.92/configure
> --prefix=/homedirectories/home6/mlil/proj_links/mingw/cross_arm
> --target=arm-elf -v
>
> When compiling, I get the following error messages which I do not
> understand:
>
> /homedirectories/home6/mlil/proj_links/mingw/cross_arm/lib/gcc-lib/arm-elf/3.3/../../../../arm-elf/bin/as
> --gdwarf2 -EL -mcpu=arm7tdmi -mthumb-interwork -o inthdlr_gnu.o
> /var/tmp//cc2yfq0p.s
> ../src/inthdlr_gnu.S: Assembler messages:
> ../src/inthdlr_gnu.S:249: Error: invalid immediate for address
> calculation (value = 0xFFFFFFD0)
> ../src/inthdlr_gnu.S:249: Error: cannot represent THUMB_ADD relocation
> in this object file format
>
> The relevant code looks like:
>
> 244 .thumb
> 245
> 246 .globl arm_lock
> 247 .globl arm_lock32
> 248 arm_lock:
> 249 adr r0,arm_lock32
> 250 bx r0
> 251 .align 2
> 252 .arm
> 253 arm_lock32:
>
> I compiling using GCC 3.3, which in turn invokes "as" as seen above.
>
> What am I doing wrong here?
Because the symbol arm_lock32 is exported, gas is refusing to resolve the
offset at assembly time. Since it has no way of representing the
relocation in the object file it is then generating an error. You can
work around the problem by defining an alternative local symbol as follows:
.thumb
.globl arm_lock
.globl arm_lock32
arm_lock:
adr r0,.Larm_lock32_internal
bx r0
.align 2
.arm
arm_lock32:
.Larm_lock32_internal:
Note, if all you want to do is switch to ARM state from thumb state (eg
add a Thumb veneer to an ARM function, then the following trick will also
work:
.thumb
.align 2
arm_lock:
bx pc // PC is (. + 4), bit 0 == 0, '.' is word aligned.
nop
.arm
arm_lock32:
...
Note that for this to work, the bx instruction must be word aligned (hence
the ".align 2" before the Thumb code sequence.
R.