Thumb2 code in LD veneers?
Will Newton
will.newton@linaro.org
Thu Jun 12 16:15:00 GMT 2014
On 12 June 2014 16:38, Jonathan Brandmeyer
<Jonathan.Brandmeyer@boulderwindpower.com> wrote:
> Is there a way to get GNU ld to use Thumb2 instructions for veneers? Here is an example of a veneer that ld creates to insert a long call:
>
> 0800b170 <__sinf_veneer>:
> 800b170: b401 push {r0}
> 800b172: 4802 ldr r0, [pc, #8] ; (800b17c <__sinf_veneer+0xc>)
> 800b174: 4684 mov ip, r0
> 800b176: bc01 pop {r0}
> 800b178: 4760 bx ip
> 800b17a: bf00 nop
> 800b17c: 00000169 .word 0x00000169
>
> In Thumb2 mode, the ldr instruction could have loaded the target address directly to the ip register. This would save the push, pop, and mov instructions.
I believe this is supported in the master branch of binutils but not
in any released versions yet.
> In this example, the linker is invoked by GCC [1]. I'm using GNU ld version 2.32.2 as packaged by ARM Ltd through Launchpad [2].
>
>
> [1] arm-none-eabi-gcc $(object_files) -mcpu=cortex-m4 -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -fno-math-errno -fstack-usage -fstack-protector -ffunction-sections -fdata-sections -fno-common -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -nostartfiles -L. -Wl,-Map=build/ch.map,--cref,--no-warn-mismatch,--library-path=../../os/ports/GCC/ARMCMx,--script=../../os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG_CCM_REMAPPED.ld,--gc-sections -mno-thumb-interwork -mthumb -lm -o build/ch.elf
>
>
> [2] https://launchpad.net/gcc-arm-embedded, release 4.8-2014-q1-update
You could try filing a bug against this package in launchpad and see
if the maintainers may be willing to backport the change.
--
Will Newton
Toolchain Working Group, Linaro
More information about the Binutils
mailing list