Call To External Thumb Code (BLX with set Thumb Bit)
I wan't to build a application for a cortex m.
the application should call a thumb function which address is defined in a linker script.
but the linker create always a call to an arm function. i've created a realy reduced example, that generates the same problem.
i've compiled following example:
content of test.c
==============
__asm(" .type extFunc, %function");
__asm("
extern void extFunc(void);
void main(void) {
extFunc();
}
content of link.ld
=============
extFunc = 0x1000 +1 ; /* Thumb Symbol */
I'm using following command lines:
arm-none-eabi-gcc -c -mthumb -mcpu=cortex-m3 -o test.o test.c
arm-none-eabi-gcc -nostartfiles -nostdlib -nodefaultlibs -mthumb -mcpu=cortex-m3 test.o -T link.ld -o Test.elf
arm-none-
arm-none-
The output of readelf looks great: The symbol address of the main function and extFunc is odd.
but when i'm looking at the dissasembly of objdump, there is a BLX <immidate> instruction to an even address. (this means it is arm code),
i'm expecting a BLX to an odd address or an a BL instruction.
what is missing in my example code? what am i doing wrong?
A workaround would be to replace
extern void extFunc(void);
by
#define extFunc() ((void(
it's not my prefered way, because i want to define the adresses in a linker script
My Versions:
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.7.3 20121207 (release) [ARM/embedded-
GNU objdump (GNU Tools for ARM Embedded Processors) 2.22.0.20121207
GNU readelf (GNU Tools for ARM Embedded Processors) 2.22.0.20121207
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Joey Ye
- Solved:
- Last query:
- Last reply: