This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Thumb2 code in LD veneers?
- From: Jonathan Brandmeyer <Jonathan dot Brandmeyer at Boulderwindpower dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 12 Jun 2014 15:38:48 +0000
- Subject: Thumb2 code in LD veneers?
- Authentication-results: sourceware.org; auth=none
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.
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