Frederic Beaulieu wrote:
I need to produce a position independent C function (this function will be moved dynamically at different address in flash during code execution).
are you sure that code does not reference other code outside your function? > However, this function contain a big switch structure and my
problem is, when the switch became bigger than a certain threshold, the compiler use branch (br) function instead of the previous and more suitable jump (jmp, jz, etc) function. This happen even if I specify no optimization (-O0) in my makefile.
the jmp/jXX instructions can only jump +/- 1000 Bytes, larger jumps must be implemented differently e.g. with a br. it's possible to do relative jumps with br
but mspgcc does not generate position independed code by default.
Is there someone who know how I can force the compiler to keep the code (only this C funtion) position independent?
does "-f pic" work for mspgcc? i never tried it myself, but thats the usual thing to do for libraries on other platforms. if you want to do that to only one function, you have to put it in a separate file and compile it separately.
chris
