I am working on a project with the CodeWarrior for MCU v10.6 IDE
. It is an Eclipse based IDE from NXP. The project targets a K21 SoC from NXP (precisely a MK21FN1M0M12
, which embeds a cortex-m4
, armv7-m
).
CodeWarrior is configured to use the ARM toolchain.
I am running into a crash related to thumb-interwork. This feature is enabled by the IDE and cannot be deactivated.
Since armv7-m
only supports thumb2, using thumb-interwork does not seem to make sense in the first place. But I probably am missing something here.
All the code is properly generated in thumb instructions.
I get trouble when making an indirect function call, through a pointer. The function code gets an odd address at link stage, which is OK (this indicates it is thumb code). However, when calling it through a pointer, a BLX instruction gets generated (I suppose the linker updates the original BL into a BLX here) AND the function pointer's value remains even! Since the pointer's value is even, the jump instructs the core to switch to ARM mode. Hence the crash.
I think the linker upgrades the BL into a BLX because of the thumb-interwork feature being activated. On CodeWarrior for MCU v10.6
, this is forced, I cannot disable it. I am told that this is "required for processor" by the tool and cannot click the related checkbox (Properties->C/C++ Build->Settings
, ARM CPU. The processor is set to "cortex-m4"
).
I do not understand why, since this is armv7-m
. Moreover it seems to lead me into trouble. I think I am missing something here.
Could you please help me understand what is going on and/or tell me if there is a way to disable thumb-interwork on CodeWarrior?
Thanks and best regards,
Pierre
bx
/blx
required? I am going to try to produce such an example out of the project which is quite large. – Pierre Baudemontbl
andblx
, only the latter can use a register as operand. Thus I now understand whyblx
is required and why removing thumb-interworking would break function calls. – Pierre Baudemonttypedef struct { int (*fct)(void *param); void *param; } event_item_t;
Thefct
pointer is wrong when calling aregister
function like:int event_register(int id, int (*fct)(void *), void *param)
fct
is even – Pierre Baudemont