I'm getting the "relocation truncated to fit: R_ARM_PC24 against symbol" error message when linking, what does this mean?
You will get this error message when you are calling an external function that is too far for the ARM's branch and link instruction to reach. The maximum branch is +/- 32Mbytes in ARM mode and +/- 4Mbytes in Thumb mode.
You will typically get this when you have code placed into two memory segments that are located further apart than the maximum branch and link distance.
If the call is being made from C/C++ code then the solution is to either declare the function with the __long_call__ attribute, for example:
void __attribute__((__long_call__)) foo(int n);
void bar(int n)
{
foo(n);
}
Or alternatively enable the Code Generation Options > Long Calls project property for the module containing the caller function. Note that the long calls option only applies to calls to external functions, therefore in order for this option to work the caller and callee functions must be located in separate modules.
If the call is being made from assembly code you will need to construct the long call yourself, for example the following assembly code will make a long call to the function func:
ldr r4, =func mov lr, pc bx r4
Comments
1 comment
Isn't there a directive I can write at the call to switch on long call there?
Only there I can know if the call needs to be long.
Please sign in to leave a comment.