Go Down

Topic: Relocatable code (Read 746 times) previous topic - next topic

Graynomad

Does anyone know if the GCC compiler we all know and love produces relocatable code? By that I guess I mean all jumps have to be relative etc. and if so is there a limit to the distance a jump/call can go?

Why? I'm thinking of adding plug-in modules to a system and maybe it would be nice to have them plug-n-play in the sense that the driver code for each module is held on the module itself and loaded into internal or external RAM by the SAM processor. As the load address would not be known until the time the loading is done the code needs to be relocatable.

There would be a lot of details to work out and I'm not even convinced it's a good idea, but I'd like to know if it's at least possible before I spend any real time on it.

_____
Rob
Rob Gray aka the GRAYnomad www.robgray.com

stimmer

Do you mean position-independent code? 'Relocatable' code means code with absolutes and relocation tables and is what GCC generates already. Position-independent code is code with all relative jumps and PC-offset/register-offset addressing and has no or minimal relocation tables. The relevant GCC option is -fpic. ARM code is highly position-independent anyway and there is little or no restriction on branch distance.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

Graynomad

Quote
Do you mean position-independent code?

Yes I guess I do.

Quote
The relevant GCC option is -fpic.

So I can generate such code should I decide this is a worthwhile feature.

I would expect ARM code to lend itself to this but wasn't sure if the compiler would support it.

So I could grab a binary from an EEPROM on a module, load it into RAM somewhere, set some pointers and call functions in that block of code, presumably through a table at a fixed location.

_____
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Go Up