Not emitting "blx address" on Cortex-M3

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Not emitting "blx address" on Cortex-M3

Samuel Tardieu
The ARM Cortex-M3 which uses the thumb2 instruction set can use "blx
register" but not "blx address".

When compiling calls to GCC helper functions (here a soft-float division
between doubles), this instruction is generated:

        .cpu cortex-m3
        [...]
        bl      __aeabi_ddiv
        bx      lr

compiles as

   [...]
   108:   f7ff fffe       bl      0 <__aeabi_ddiv>
   10c:   4770            bx      lr

and after the link phase contains

    8170:       f000 e94a       blx     8408 <__aeabi_ddiv>
    8174:       4770            bx      lr

This "blx" instruction is incorrect. Is there an extra flag I can give
to "ld" to avoid the bl to blx transformation?

The "ld" command line was:

/arm/stm32/lib/gcc/arm-none-eabi/4.5.0/../../../../arm-none-eabi/bin/ld
--sysroot=/arm/stm32/arm-none-eabi/sys-root -X -o t
/arm/stm32/lib/gcc/arm-none-eabi/4.5.0/thumb/crti.o
/arm/stm32/lib/gcc/arm-none-eabi/4.5.0/thumb/crtbegin.o
/arm/stm32/lib/gcc/arm-none-eabi/4.5.0/../../../../arm-none-eabi/lib/thumb/crt0.o
-L/arm/stm32/lib/gcc/arm-none-eabi/4.5.0/thumb
-L/arm/stm32/lib/gcc/arm-none-eabi/4.5.0/../../../../arm-none-eabi/lib/thumb
-L/arm/stm32/lib/gcc/arm-none-eabi/4.5.0
-L/arm/stm32/lib/gcc/arm-none-eabi/4.5.0/../../../../arm-none-eabi/lib
/tmp/cconBGlK.o -v --start-group -lgcc -lc --end-group
/arm/stm32/lib/gcc/arm-none-eabi/4.5.0/thumb/crtend.o
/arm/stm32/lib/gcc/arm-none-eabi/4.5.0/thumb/crtn.o

GNU ld (GNU Binutils) 2.19.51.20090502

  Sam
--
Samuel Tardieu -- [hidden email] -- http://www.rfc1149.net/

Reply | Threaded
Open this post in threaded view
|

Re: Not emitting "blx address" on Cortex-M3

Paul Brook
On Saturday 02 May 2009, Samuel Tardieu wrote:
> The ARM Cortex-M3 which uses the thumb2 instruction set can use "blx
> register" but not "blx address".

Not technically true. blx address is fine, you're just guaranteed to get a
fault afterwards.

> When compiling calls to GCC helper functions (here a soft-float division
> between doubles), this instruction is generated:

>     8170:       f000 e94a       blx     8408 <__aeabi_ddiv>

Almost certainly means you're linking against ARM libraries. Don't do that.

Paul
Reply | Threaded
Open this post in threaded view
|

Re: Not emitting "blx address" on Cortex-M3

Richard Earnshaw
On Mon, 2009-05-04 at 17:30 +0100, Paul Brook wrote:

> On Saturday 02 May 2009, Samuel Tardieu wrote:
> > The ARM Cortex-M3 which uses the thumb2 instruction set can use "blx
> > register" but not "blx address".
>
> Not technically true. blx address is fine, you're just guaranteed to get a
> fault afterwards.
>
> > When compiling calls to GCC helper functions (here a soft-float division
> > between doubles), this instruction is generated:
>
> >     8170:       f000 e94a       blx     8408 <__aeabi_ddiv>
>
> Almost certainly means you're linking against ARM libraries. Don't do that.

The linker ought to be able to detect this using the object
attributes... M-profile objects shouldn't be compatible with ARM
objects.

R.

Reply | Threaded
Open this post in threaded view
|

Re: Not emitting "blx address" on Cortex-M3

Samuel Tardieu
>>>>> "Richard" == Richard Earnshaw <[hidden email]> writes:

Richard> The linker ought to be able to detect this using the object
Richard> attributes... M-profile objects shouldn't be compatible with
Richard> ARM objects.

This would also help detect problems with GCC multilib construction
(which I suspect here, given that GCC finds the path to the library and
has been given the correct flags, and has been built in multilib mode).

  Sam
--
Samuel Tardieu -- [hidden email] -- http://www.rfc1149.net/