Go Down

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


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 Gray aka the GRAYnomad www.robgray.com


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


Do you mean position-independent code?

Yes I guess I do.

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 Gray aka the GRAYnomad www.robgray.com

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131