What is "relocation truncated to fit" error means ?

I'm using GNU-ld to link my ARM application. I'm using AT91R40008 and arm-none-eabi-gcc compiler.

I have an error during linking my CRT0.s / C start-up file to my main() in main.c

The error were like this : at91r40008_start_gcc.o: at91r40008_start_gcc.s:281: relocation truncated to fit: R_ARM_PC24 against symbol `main' defined in .text section in MAIN.o

What's happened here ? How do I handle this ?

I already add ".global main" syntax in my C start-up file, so the linker would recognize the main(), but it doesnt help.

Thank You

-kunil

Reply to
kunil
Loading thread data ...

Try -fPIC option

cheers Sagar

Reply to
Sagar

The linker thinks that the branch instruction in your .s file and its destination are too far apart. It might think that one is in RAM and the other in flash, possibly because of errors in the linker script file.

Karl Olsen

Reply to
Karl Olsen

The ARM branch instructions (b, bl) have a 23 bit offset part in the instruction. If the trasfer target is farther away from the jump/call then the offset allows, you'll get the warning (and the code does not work).

Are you attempting to jump into a totally separate memory segment (from where to where)?

The way to solve the dilemma is to use an indirect transfer, in C, a function call via a pointer.

Where is your crt0 located and where MAIN?

--

Tauno Voipio
tauno voipio (at) iki fi

PS. Are you using ld directly or via the gcc wrapper?
Reply to
Tauno Voipio

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.