Adding support for building position independent code would make it easier to build images for online firmware updates, since the binary can be relocated by the bootloader to a suitable location depending on available memory. Running binaries from RAM should also be possible without any special linker scripts.
I have not investigated the details but the a rough draft of the changes needed are:
- Add -fPIC to CFLAGS, possibly -fpie as well.
- add linker script handling of .got (global offset table) and .got.plt (procedure linkage table)
- fill GOT during boot (I don't know if gcc provides code for this or if we need to write our own)
Adding support for building position independent code would make it easier to build images for online firmware updates, since the binary can be relocated by the bootloader to a suitable location depending on available memory. Running binaries from RAM should also be possible without any special linker scripts.
I have not investigated the details but the a rough draft of the changes needed are: