I am experiencing relocation truncated to fit kind of error for my embedded ARM application compiled and linked with with GCC 4.9.3. I am using code relocation for this function from external flash (0x70000000)
to internal RAM (0x08000000)
to improve performance of my application, and this is one of the causes of the problem.
I have a small inline-assembly naked function to perform a short loop:
void ThreeCycleDelay(uint32_t count) __attribute__((naked))
{
__asm(" subs r0, #1\n"
" bne ThreeCycleDelay\n"
" bx lr");
}
But when linking, I receive the following error from ld:
D:/app/app.a(app_utils.obj):(.ARM.exidx.text.ThreeCycleDelay+0x0): relocation truncated to fit: R_ARM_PREL31 against `.text.ThreeCycleDelay'
I have seen suggestions on the internet to solve this issue, but none of them were helpful. Trying to "remove" .ARM.exidx section by -funwind-tables -fno-exceptions
made no difference.
The error disappears when I perform no code relocation, and it does not show for any other function. Removing the __attribute__((naked))
does not solve the issue either, so I was suspicious it is linekd with the inline assembly jump, but the real question is - how can I solve this issue?